summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndriy Gapon <[email protected]>2018-02-21 14:55:55 +0200
committerBrian Behlendorf <[email protected]>2018-03-30 12:00:40 -0700
commit5e00213e430fe9103e263514490d55d10075908e (patch)
tree7447d888344a6afcf29932f84dfd0b5bc8490d8d
parent99f505a4d743976d8879595d20beb66a6cbc3af1 (diff)
OpenZFS 9164 - assert: newds == os->os_dsl_dataset
Authored by: Andriy Gapon <[email protected]> Reviewed by: Matt Ahrens <[email protected]> Reviewed by: Don Brady <[email protected]> Reviewed-by: loli10K <[email protected]> Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Approved by: Richard Lowe <[email protected]> Ported-by: Giuseppe Di Natale <[email protected]> Porting Notes: * Re-enabled and tweaked the zpool_upgrade_007_pos test case to successfully run in under 5 minutes. OpenZFS-issue: https://www.illumos.org/issues/9164 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/0e776dc06a Closes #6112 Closes #7336
-rw-r--r--include/sys/dmu_objset.h4
-rw-r--r--module/zfs/dmu_objset.c12
-rw-r--r--module/zfs/zfs_ioctl.c6
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade.kshlib23
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib5
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_007_pos.ksh7
6 files changed, 32 insertions, 25 deletions
diff --git a/include/sys/dmu_objset.h b/include/sys/dmu_objset.h
index 0060efd51..54fe37e61 100644
--- a/include/sys/dmu_objset.h
+++ b/include/sys/dmu_objset.h
@@ -194,8 +194,8 @@ int dmu_objset_own(const char *name, dmu_objset_type_t type,
int dmu_objset_own_obj(struct dsl_pool *dp, uint64_t obj,
dmu_objset_type_t type, boolean_t readonly, boolean_t decrypt,
void *tag, objset_t **osp);
-void dmu_objset_refresh_ownership(objset_t *os, boolean_t key_needed,
- void *tag);
+void dmu_objset_refresh_ownership(struct dsl_dataset *ds,
+ struct dsl_dataset **newds, boolean_t decrypt, void *tag);
void dmu_objset_rele(objset_t *os, void *tag);
void dmu_objset_rele_flags(objset_t *os, boolean_t decrypt, void *tag);
void dmu_objset_disown(objset_t *os, boolean_t decrypt, void *tag);
diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c
index c2dd31a8b..de7bbf894 100644
--- a/module/zfs/dmu_objset.c
+++ b/module/zfs/dmu_objset.c
@@ -791,24 +791,22 @@ dmu_objset_rele(objset_t *os, void *tag)
* same name so that it can be partially torn down and reconstructed.
*/
void
-dmu_objset_refresh_ownership(objset_t *os, boolean_t decrypt, void *tag)
+dmu_objset_refresh_ownership(dsl_dataset_t *ds, dsl_dataset_t **newds,
+ boolean_t decrypt, void *tag)
{
dsl_pool_t *dp;
- dsl_dataset_t *ds, *newds;
char name[ZFS_MAX_DATASET_NAME_LEN];
- ds = os->os_dsl_dataset;
VERIFY3P(ds, !=, NULL);
VERIFY3P(ds->ds_owner, ==, tag);
VERIFY(dsl_dataset_long_held(ds));
dsl_dataset_name(ds, name);
- dp = dmu_objset_pool(os);
+ dp = ds->ds_dir->dd_pool;
dsl_pool_config_enter(dp, FTAG);
- dmu_objset_disown(os, decrypt, tag);
+ dsl_dataset_disown(ds, decrypt, tag);
VERIFY0(dsl_dataset_own(dp, name,
- (decrypt) ? DS_HOLD_FLAG_DECRYPT : 0, tag, &newds));
- VERIFY3P(newds, ==, os->os_dsl_dataset);
+ (decrypt) ? DS_HOLD_FLAG_DECRYPT : 0, tag, newds));
dsl_pool_config_exit(dp, FTAG);
}
diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c
index 92bdec4b9..8ef4cc46f 100644
--- a/module/zfs/zfs_ioctl.c
+++ b/module/zfs/zfs_ioctl.c
@@ -5290,14 +5290,14 @@ zfs_ioc_userspace_upgrade(zfs_cmd_t *zc)
* objset needs to be closed & reopened (to grow the
* objset_phys_t). Suspend/resume the fs will do that.
*/
- dsl_dataset_t *ds;
+ dsl_dataset_t *ds, *newds;
ds = dmu_objset_ds(zfsvfs->z_os);
error = zfs_suspend_fs(zfsvfs);
if (error == 0) {
- dmu_objset_refresh_ownership(zfsvfs->z_os,
+ dmu_objset_refresh_ownership(ds, &newds,
B_TRUE, zfsvfs);
- error = zfs_resume_fs(zfsvfs, ds);
+ error = zfs_resume_fs(zfsvfs, newds);
}
}
if (error == 0)
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade.kshlib
index c540e0851..9c7d273b3 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade.kshlib
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade.kshlib
@@ -42,11 +42,22 @@ set -A spa_create_versions 9 15 24
set -A zpl_upgrade_versions 3 4 5
set -A spa_upgrade_versions 9 15 24
+function get_pool_version #pool
+{
+ ver=$(get_pool_prop version $1)
+
+ if [ "$ver" = "-" ]; then
+ ver="5000"
+ fi
+
+ echo "$ver"
+}
+
function default_setup_datasets #rootfs
{
typeset rootfs=$1
typeset pool=${rootfs%%/*}
- typeset -i vp=$(get_pool_prop version $pool)
+ typeset -i vp=$(get_pool_version $pool)
typeset -i version
typeset -i m
typeset -i spa_version
@@ -107,7 +118,7 @@ function default_cleanup_datasets #rootfs
typeset rootfs=$1
if datasetexists $rootfs ; then
- log_must zfs destroy -Rf $rootfs
+ log_must_busy zfs destroy -Rf $rootfs
fi
if datasetnonexists $rootfs ; then
@@ -119,7 +130,7 @@ function default_check_zfs_upgrade #rootfs
{
typeset rootfs=$1
typeset pool=${rootfs%%/*}
- typeset -i vp=$(get_pool_prop version $pool)
+ typeset -i vp=$(get_pool_version $pool)
typeset -i m
typeset -i spa_version
typeset -i zpl_version
@@ -150,9 +161,9 @@ function default_check_zfs_upgrade #rootfs
if (( df_ret != 0 )); then
if (( spa_version != 0 )) && (( vp < spa_version )); then
- log_mustnot zfs upgrade $opt -a >/dev/null
- log_must zpool upgrade $pool >/dev/null
- vp=$(get_pool_prop version $pool)
+ log_mustnot eval "zfs upgrade $opt -a >/dev/null"
+ log_must eval "zpool upgrade $pool >/dev/null"
+ vp=$(get_pool_version $pool)
fi
log_must zfs upgrade $opt -a
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib
index d4d229cc9..238d4ae38 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib
@@ -93,9 +93,8 @@ function destroy_upgraded_pool
typeset -n pool_files=ZPOOL_VERSION_${vers}_FILES
typeset -n pool_name=ZPOOL_VERSION_${vers}_NAME
- if poolexists $pool_name; then
- log_must zpool destroy $pool_name
- fi
+ destroy_pool $pool_name
+
for file in $pool_files; do
rm -f $TEST_BASE_DIR/$file
done
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_007_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_007_pos.ksh
index 429377f15..adc1ba47f 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_007_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_007_pos.ksh
@@ -48,19 +48,18 @@
verify_runnable "global"
-https://github.com/zfsonlinux/zfs/issues/6112
-log_unsupported "Known issue #6112"
-
function cleanup
{
destroy_upgraded_pool $config
}
+POOL_CONFIGS="1raidz 1mirror 2raidz 2mirror 3raidz 3mirror"
+
log_assert "Import pools of all versions - 'zfs upgrade' on each pool works"
log_onexit cleanup
# $CONFIGS gets set in the .cfg script
-for config in $CONFIGS; do
+for config in $POOL_CONFIGS; do
typeset -n pool_name=ZPOOL_VERSION_${config}_NAME
create_old_pool $config