6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
6577336 6572465 didn't update comments for zpool_stage_history()
--- a/usr/src/cmd/zfs/zfs_main.c Tue Jul 24 07:26:05 2007 -0700
+++ b/usr/src/cmd/zfs/zfs_main.c Tue Jul 24 09:34:17 2007 -0700
@@ -1384,7 +1384,7 @@
* to log this history once to each pool.
*/
zpool_stage_history(g_zfs, first_argc, first_argv,
- B_TRUE, B_FALSE);
+ B_TRUE);
}
if (zfs_prop_set(zhp, "version", verstr) == 0)
cb->cb_numupgraded++;
@@ -3783,7 +3783,7 @@
return (1);
}
- zpool_stage_history(g_zfs, argc, argv, B_TRUE, B_FALSE);
+ zpool_stage_history(g_zfs, argc, argv, B_TRUE);
libzfs_print_on_error(g_zfs, B_TRUE);
--- a/usr/src/cmd/zpool/zpool_main.c Tue Jul 24 07:26:05 2007 -0700
+++ b/usr/src/cmd/zpool/zpool_main.c Tue Jul 24 09:34:17 2007 -0700
@@ -3804,9 +3804,9 @@
/* Handle special case of pool create for staging history */
if (strcmp(cmdname, "create") != 0)
- zpool_stage_history(g_zfs, argc, argv, B_FALSE, B_FALSE);
+ zpool_stage_history(g_zfs, argc, argv, B_FALSE);
else
- zpool_stage_history(g_zfs, argc, argv, B_FALSE, B_TRUE);
+ zpool_stage_history(g_zfs, argc, argv, B_FALSE);
/*
* Special case '-?'
--- a/usr/src/cmd/ztest/ztest.c Tue Jul 24 07:26:05 2007 -0700
+++ b/usr/src/cmd/ztest/ztest.c Tue Jul 24 09:34:17 2007 -0700
@@ -782,7 +782,7 @@
* Attempt to create using a bad file.
*/
nvroot = make_vdev_root(0, 0, 0, 0, 1);
- error = spa_create("ztest_bad_file", nvroot, NULL);
+ error = spa_create("ztest_bad_file", nvroot, NULL, NULL);
nvlist_free(nvroot);
if (error != ENOENT)
fatal(0, "spa_create(bad_file) = %d", error);
@@ -791,7 +791,7 @@
* Attempt to create using a bad mirror.
*/
nvroot = make_vdev_root(0, 0, 0, 2, 1);
- error = spa_create("ztest_bad_mirror", nvroot, NULL);
+ error = spa_create("ztest_bad_mirror", nvroot, NULL, NULL);
nvlist_free(nvroot);
if (error != ENOENT)
fatal(0, "spa_create(bad_mirror) = %d", error);
@@ -802,7 +802,7 @@
*/
(void) rw_rdlock(&ztest_shared->zs_name_lock);
nvroot = make_vdev_root(0, 0, 0, 0, 1);
- error = spa_create(za->za_pool, nvroot, NULL);
+ error = spa_create(za->za_pool, nvroot, NULL, NULL);
nvlist_free(nvroot);
if (error != EEXIST)
fatal(0, "spa_create(whatever) = %d", error);
@@ -3296,7 +3296,7 @@
(void) spa_destroy(pool);
ztest_shared->zs_vdev_primaries = 0;
nvroot = make_vdev_root(zopt_vdev_size, 0, zopt_raidz, zopt_mirrors, 1);
- error = spa_create(pool, nvroot, NULL);
+ error = spa_create(pool, nvroot, NULL, NULL);
nvlist_free(nvroot);
if (error)
--- a/usr/src/lib/libzfs/common/libzfs.h Tue Jul 24 07:26:05 2007 -0700
+++ b/usr/src/lib/libzfs/common/libzfs.h Tue Jul 24 09:34:17 2007 -0700
@@ -299,7 +299,7 @@
extern int zpool_upgrade(zpool_handle_t *);
extern int zpool_get_history(zpool_handle_t *, nvlist_t **);
extern void zpool_stage_history(libzfs_handle_t *, int, char **,
- boolean_t zfs_cmd, boolean_t pool_create);
+ boolean_t zfs_cmd);
extern void zpool_obj_to_path(zpool_handle_t *, uint64_t, uint64_t, char *,
size_t len);
extern int zfs_ioctl(libzfs_handle_t *, int, struct zfs_cmd *);
--- a/usr/src/lib/libzfs/common/libzfs_impl.h Tue Jul 24 07:26:05 2007 -0700
+++ b/usr/src/lib/libzfs/common/libzfs_impl.h Tue Jul 24 09:34:17 2007 -0700
@@ -56,7 +56,6 @@
char libzfs_action[1024];
char libzfs_desc[1024];
char *libzfs_log_str;
- int libzfs_log_type;
int libzfs_printerr;
void *libzfs_sharehdl; /* libshare handle */
};
--- a/usr/src/lib/libzfs/common/libzfs_pool.c Tue Jul 24 07:26:05 2007 -0700
+++ b/usr/src/lib/libzfs/common/libzfs_pool.c Tue Jul 24 09:34:17 2007 -0700
@@ -1795,27 +1795,23 @@
/*
* Log command history.
*
- * 'pool' is B_TRUE if we are logging a command for 'zpool'; B_FALSE
- * otherwise ('zfs'). 'pool_create' is B_TRUE if we are logging the creation
- * of the pool; B_FALSE otherwise. 'path' is the pathname containing the
- * poolname. 'argc' and 'argv' are used to construct the command string.
+ * 'zfs_cmd' is B_TRUE if we are logging a command for 'zfs'; B_FALSE
+ * otherwise ('zpool'). 'argc' and 'argv' are used to construct the
+ * command string.
*/
void
zpool_stage_history(libzfs_handle_t *hdl, int argc, char **argv,
- boolean_t zfs_cmd, boolean_t pool_create)
+ boolean_t zfs_cmd)
{
char *cmd_buf;
int i;
- if (hdl->libzfs_log_str != NULL) {
+ if (hdl->libzfs_log_str != NULL)
free(hdl->libzfs_log_str);
- }
if ((hdl->libzfs_log_str = zfs_alloc(hdl, HIS_MAX_RECORD_LEN)) == NULL)
return;
- hdl->libzfs_log_type =
- (pool_create == B_TRUE) ? LOG_CMD_POOL_CREATE : LOG_CMD_NORMAL;
cmd_buf = hdl->libzfs_log_str;
/* construct the command string */
--- a/usr/src/lib/libzfs/common/libzfs_util.c Tue Jul 24 07:26:05 2007 -0700
+++ b/usr/src/lib/libzfs/common/libzfs_util.c Tue Jul 24 09:34:17 2007 -0700
@@ -892,14 +892,12 @@
int error;
zc->zc_history = (uint64_t)(uintptr_t)hdl->libzfs_log_str;
- zc->zc_history_offset = hdl->libzfs_log_type;
error = ioctl(hdl->libzfs_fd, request, zc);
if (hdl->libzfs_log_str) {
free(hdl->libzfs_log_str);
hdl->libzfs_log_str = NULL;
}
zc->zc_history = 0;
- zc->zc_history_offset = 0;
return (error);
}
--- a/usr/src/uts/common/fs/zfs/spa.c Tue Jul 24 07:26:05 2007 -0700
+++ b/usr/src/uts/common/fs/zfs/spa.c Tue Jul 24 09:34:17 2007 -0700
@@ -1137,7 +1137,8 @@
* Pool Creation
*/
int
-spa_create(const char *pool, nvlist_t *nvroot, const char *altroot)
+spa_create(const char *pool, nvlist_t *nvroot, const char *altroot,
+ const char *history_str)
{
spa_t *spa;
vdev_t *rvd;
@@ -1276,6 +1277,9 @@
spa_config_sync();
+ if (history_str != NULL)
+ (void) spa_history_log(spa, history_str, LOG_CMD_POOL_CREATE);
+
mutex_exit(&spa_namespace_lock);
return (0);
--- a/usr/src/uts/common/fs/zfs/sys/spa.h Tue Jul 24 07:26:05 2007 -0700
+++ b/usr/src/uts/common/fs/zfs/sys/spa.h Tue Jul 24 09:34:17 2007 -0700
@@ -318,7 +318,8 @@
extern int spa_open(const char *pool, spa_t **, void *tag);
extern int spa_get_stats(const char *pool, nvlist_t **config,
char *altroot, size_t buflen);
-extern int spa_create(const char *pool, nvlist_t *config, const char *altroot);
+extern int spa_create(const char *pool, nvlist_t *config, const char *altroot,
+ const char *history_str);
extern int spa_import(const char *pool, nvlist_t *config, const char *altroot);
extern nvlist_t *spa_tryimport(nvlist_t *tryconfig);
extern int spa_destroy(char *pool);
--- a/usr/src/uts/common/fs/zfs/zfs_ioctl.c Tue Jul 24 07:26:05 2007 -0700
+++ b/usr/src/uts/common/fs/zfs/zfs_ioctl.c Tue Jul 24 09:34:17 2007 -0700
@@ -127,37 +127,46 @@
}
static void
+history_str_free(char *buf)
+{
+ kmem_free(buf, HIS_MAX_RECORD_LEN);
+}
+
+static char *
+history_str_get(zfs_cmd_t *zc)
+{
+ char *buf;
+
+ if (zc->zc_history == NULL)
+ return (NULL);
+
+ buf = kmem_alloc(HIS_MAX_RECORD_LEN, KM_SLEEP);
+ if (copyinstr((void *)(uintptr_t)zc->zc_history,
+ buf, HIS_MAX_RECORD_LEN, NULL) != 0) {
+ history_str_free(buf);
+ return (NULL);
+ }
+
+ buf[HIS_MAX_RECORD_LEN -1] = '\0';
+
+ return (buf);
+}
+
+static void
zfs_log_history(zfs_cmd_t *zc)
{
spa_t *spa;
char *buf;
- if (zc->zc_history == NULL)
- return;
-
- if (zc->zc_history_offset != LOG_CMD_POOL_CREATE &&
- zc->zc_history_offset != LOG_CMD_NORMAL)
+ if ((buf = history_str_get(zc)) == NULL)
return;
- buf = kmem_alloc(HIS_MAX_RECORD_LEN, KM_SLEEP);
- if (copyinstr((void *)(uintptr_t)zc->zc_history,
- buf, HIS_MAX_RECORD_LEN, NULL) != 0) {
- kmem_free(buf, HIS_MAX_RECORD_LEN);
- return;
+ if (spa_open(zc->zc_name, &spa, FTAG) == 0) {
+ if (spa_version(spa) >= SPA_VERSION_ZPOOL_HISTORY)
+ (void) spa_history_log(spa, buf, LOG_CMD_NORMAL);
+ spa_close(spa, FTAG);
}
-
- buf[HIS_MAX_RECORD_LEN -1] = '\0';
-
- if (spa_open(zc->zc_name, &spa, FTAG) != 0) {
- kmem_free(buf, HIS_MAX_RECORD_LEN);
- return;
- }
-
- if (spa_version(spa) >= SPA_VERSION_ZPOOL_HISTORY)
- (void) spa_history_log(spa, buf, zc->zc_history_offset);
-
- spa_close(spa, FTAG);
- kmem_free(buf, HIS_MAX_RECORD_LEN);
+ history_str_free(buf);
}
/*
@@ -650,14 +659,21 @@
{
int error;
nvlist_t *config;
+ char *buf;
- if ((error = get_nvlist(zc, &config)) != 0)
+ if ((buf = history_str_get(zc)) == NULL)
+ return (EINVAL);
+
+ if ((error = get_nvlist(zc, &config)) != 0) {
+ history_str_free(buf);
return (error);
+ }
error = spa_create(zc->zc_name, config, zc->zc_value[0] == '\0' ?
- NULL : zc->zc_value);
+ NULL : zc->zc_value, buf);
nvlist_free(config);
+ history_str_free(buf);
return (error);
}
@@ -2108,7 +2124,7 @@
* of those commands.
*/
static zfs_ioc_vec_t zfs_ioc_vec[] = {
- { zfs_ioc_pool_create, zfs_secpolicy_config, POOL_NAME, B_TRUE },
+ { zfs_ioc_pool_create, zfs_secpolicy_config, POOL_NAME, B_FALSE },
{ zfs_ioc_pool_destroy, zfs_secpolicy_config, POOL_NAME, B_FALSE },
{ zfs_ioc_pool_import, zfs_secpolicy_config, POOL_NAME, B_TRUE },
{ zfs_ioc_pool_export, zfs_secpolicy_config, POOL_NAME, B_FALSE },