From 6aee0ad76969eb0027131b3a338f2d94ae86f728 Mon Sep 17 00:00:00 2001 From: Matthew Ahrens Date: Fri, 18 May 2018 15:56:13 -0700 Subject: [PATCH] 9681 ztest failure in spa_history_log_internal due to spa_rename() Reviewed by: Prakash Surya Reviewed by: Serapheim Dimitropoulos Approved by: Robert Mustacchi --- usr/src/cmd/ztest/ztest.c | 74 ------------------------------------ usr/src/uts/common/fs/zfs/spa_misc.c | 53 -------------------------- usr/src/uts/common/fs/zfs/sys/spa.h | 1 - 3 files changed, 128 deletions(-) diff --git a/usr/src/cmd/ztest/ztest.c b/usr/src/cmd/ztest/ztest.c index c10186aa38..ca1c7a3cc0 100644 --- a/usr/src/cmd/ztest/ztest.c +++ b/usr/src/cmd/ztest/ztest.c @@ -334,7 +334,6 @@ ztest_func_t ztest_spa_create_destroy; ztest_func_t ztest_fault_inject; ztest_func_t ztest_ddt_repair; ztest_func_t ztest_dmu_snapshot_hold; -ztest_func_t ztest_spa_rename; ztest_func_t ztest_scrub; ztest_func_t ztest_dsl_dataset_promote_busy; ztest_func_t ztest_vdev_attach_detach; @@ -379,7 +378,6 @@ ztest_info_t ztest_info[] = { { ztest_ddt_repair, 1, &zopt_sometimes }, { ztest_dmu_snapshot_hold, 1, &zopt_sometimes }, { ztest_reguid, 1, &zopt_rarely }, - { ztest_spa_rename, 1, &zopt_rarely }, { ztest_scrub, 1, &zopt_rarely }, { ztest_spa_upgrade, 1, &zopt_rarely }, { ztest_dsl_dataset_promote_busy, 1, &zopt_rarely }, @@ -5423,59 +5421,6 @@ ztest_reguid(ztest_ds_t *zd, uint64_t id) VERIFY3U(load, ==, spa_load_guid(spa)); } -/* - * Rename the pool to a different name and then rename it back. - */ -/* ARGSUSED */ -void -ztest_spa_rename(ztest_ds_t *zd, uint64_t id) -{ - char *oldname, *newname; - spa_t *spa; - - rw_enter(&ztest_name_lock, RW_WRITER); - - oldname = ztest_opts.zo_pool; - newname = umem_alloc(strlen(oldname) + 5, UMEM_NOFAIL); - (void) strcpy(newname, oldname); - (void) strcat(newname, "_tmp"); - - /* - * Do the rename - */ - VERIFY3U(0, ==, spa_rename(oldname, newname)); - - /* - * Try to open it under the old name, which shouldn't exist - */ - VERIFY3U(ENOENT, ==, spa_open(oldname, &spa, FTAG)); - - /* - * Open it under the new name and make sure it's still the same spa_t. - */ - VERIFY3U(0, ==, spa_open(newname, &spa, FTAG)); - - ASSERT(spa == ztest_spa); - spa_close(spa, FTAG); - - /* - * Rename it back to the original - */ - VERIFY3U(0, ==, spa_rename(newname, oldname)); - - /* - * Make sure it can still be opened - */ - VERIFY3U(0, ==, spa_open(oldname, &spa, FTAG)); - - ASSERT(spa == ztest_spa); - spa_close(spa, FTAG); - - umem_free(newname, strlen(newname) + 1); - - rw_exit(&ztest_name_lock); -} - static vdev_t * ztest_random_concrete_vdev_leaf(vdev_t *vd) { @@ -6529,7 +6474,6 @@ main(int argc, char **argv) ztest_shared_callstate_t *zc; char timebuf[100]; char numbuf[NN_NUMBUF_SZ]; - spa_t *spa; char *cmd; boolean_t hasalt; char *fd_data_str = getenv("ZTEST_FD_DATA"); @@ -6704,24 +6648,6 @@ main(int argc, char **argv) (void) printf("\n"); } - /* - * It's possible that we killed a child during a rename test, - * in which case we'll have a 'ztest_tmp' pool lying around - * instead of 'ztest'. Do a blind rename in case this happened. - */ - kernel_init(FREAD); - if (spa_open(ztest_opts.zo_pool, &spa, FTAG) == 0) { - spa_close(spa, FTAG); - } else { - char tmpname[ZFS_MAX_DATASET_NAME_LEN]; - kernel_fini(); - kernel_init(FREAD | FWRITE); - (void) snprintf(tmpname, sizeof (tmpname), "%s_tmp", - ztest_opts.zo_pool); - (void) spa_rename(tmpname, ztest_opts.zo_pool); - } - kernel_fini(); - ztest_run_zdb(ztest_opts.zo_pool); } diff --git a/usr/src/uts/common/fs/zfs/spa_misc.c b/usr/src/uts/common/fs/zfs/spa_misc.c index 87a95f0a36..8ba49fed41 100644 --- a/usr/src/uts/common/fs/zfs/spa_misc.c +++ b/usr/src/uts/common/fs/zfs/spa_misc.c @@ -222,9 +222,6 @@ * vdev state is protected by spa_vdev_state_enter() / spa_vdev_state_exit(). * Like spa_vdev_enter/exit, these are convenience wrappers -- the actual * locking is, always, based on spa_namespace_lock and spa_config_lock[]. - * - * spa_rename() is also implemented within this file since it requires - * manipulation of the namespace. */ static avl_tree_t spa_namespace_avl; @@ -1334,56 +1331,6 @@ spa_deactivate_mos_feature(spa_t *spa, const char *feature) } /* - * Rename a spa_t. - */ -int -spa_rename(const char *name, const char *newname) -{ - spa_t *spa; - int err; - - /* - * Lookup the spa_t and grab the config lock for writing. We need to - * actually open the pool so that we can sync out the necessary labels. - * It's OK to call spa_open() with the namespace lock held because we - * allow recursive calls for other reasons. - */ - mutex_enter(&spa_namespace_lock); - if ((err = spa_open(name, &spa, FTAG)) != 0) { - mutex_exit(&spa_namespace_lock); - return (err); - } - - spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER); - - avl_remove(&spa_namespace_avl, spa); - (void) strlcpy(spa->spa_name, newname, sizeof (spa->spa_name)); - avl_add(&spa_namespace_avl, spa); - - /* - * Sync all labels to disk with the new names by marking the root vdev - * dirty and waiting for it to sync. It will pick up the new pool name - * during the sync. - */ - vdev_config_dirty(spa->spa_root_vdev); - - spa_config_exit(spa, SCL_ALL, FTAG); - - txg_wait_synced(spa->spa_dsl_pool, 0); - - /* - * Sync the updated config cache. - */ - spa_write_cachefile(spa, B_FALSE, B_TRUE); - - spa_close(spa, FTAG); - - mutex_exit(&spa_namespace_lock); - - return (0); -} - -/* * Return the spa_t associated with given pool_guid, if it exists. If * device_guid is non-zero, determine whether the pool exists *and* contains * a device with the specified device_guid. diff --git a/usr/src/uts/common/fs/zfs/sys/spa.h b/usr/src/uts/common/fs/zfs/sys/spa.h index 1acbe31377..dc5da8fd77 100644 --- a/usr/src/uts/common/fs/zfs/sys/spa.h +++ b/usr/src/uts/common/fs/zfs/sys/spa.h @@ -821,7 +821,6 @@ extern void spa_load_note(spa_t *spa, const char *fmt, ...); extern void spa_activate_mos_feature(spa_t *spa, const char *feature, dmu_tx_t *tx); extern void spa_deactivate_mos_feature(spa_t *spa, const char *feature); -extern int spa_rename(const char *oldname, const char *newname); extern spa_t *spa_by_guid(uint64_t pool_guid, uint64_t device_guid); extern boolean_t spa_guid_exists(uint64_t pool_guid, uint64_t device_guid); extern char *spa_strdup(const char *); -- 2.11.4.GIT