aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorloli10K <[email protected]>2019-01-18 20:14:01 +0100
committerBrian Behlendorf <[email protected]>2019-01-18 11:14:01 -0800
commit0a10863194b0e7c1c64f702f868c10d5dac45ea5 (patch)
tree8837609aae223a7baeb635427861974541b6f449 /module
parentad635071355255a43469daa41fd411881407d861 (diff)
ztest: creates partially initialized root dataset
Since d8fdfc2 was integrated dsl_pool_create() does not call dmu_objset_create_impl() for the root dataset when running in userland (ztest): this creates a pool with a partially initialized root dataset. Trying to import and use this pool results in both zpool and zfs executables dumping core. Fix this by adopting an alternative change suggested in OpenZFS 8607 code review. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed by: Tom Caputi <[email protected]> Original-patch-by: Robert Mustacchi <[email protected]> Signed-off-by: loli10K <[email protected]> Closes #8277
Diffstat (limited to 'module')
-rw-r--r--module/zfs/dsl_pool.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/module/zfs/dsl_pool.c b/module/zfs/dsl_pool.c
index e159a5d1b..78e782c81 100644
--- a/module/zfs/dsl_pool.c
+++ b/module/zfs/dsl_pool.c
@@ -457,6 +457,11 @@ dsl_pool_create(spa_t *spa, nvlist_t *zplprops, dsl_crypto_params_t *dcp,
int err;
dsl_pool_t *dp = dsl_pool_open_impl(spa, txg);
dmu_tx_t *tx = dmu_tx_create_assigned(dp, txg);
+#ifdef _KERNEL
+ objset_t *os;
+#else
+ objset_t *os __attribute__((unused));
+#endif
dsl_dataset_t *ds;
uint64_t obj;
@@ -520,15 +525,12 @@ dsl_pool_create(spa_t *spa, nvlist_t *zplprops, dsl_crypto_params_t *dcp,
/* create the root objset */
VERIFY0(dsl_dataset_hold_obj_flags(dp, obj,
DS_HOLD_FLAG_DECRYPT, FTAG, &ds));
+ rrw_enter(&ds->ds_bp_rwlock, RW_READER, FTAG);
+ os = dmu_objset_create_impl(dp->dp_spa, ds,
+ dsl_dataset_get_blkptr(ds), DMU_OST_ZFS, tx);
+ rrw_exit(&ds->ds_bp_rwlock, FTAG);
#ifdef _KERNEL
- {
- objset_t *os;
- rrw_enter(&ds->ds_bp_rwlock, RW_READER, FTAG);
- os = dmu_objset_create_impl(dp->dp_spa, ds,
- dsl_dataset_get_blkptr(ds), DMU_OST_ZFS, tx);
- rrw_exit(&ds->ds_bp_rwlock, FTAG);
- zfs_create_fs(os, kcred, zplprops, tx);
- }
+ zfs_create_fs(os, kcred, zplprops, tx);
#endif
dsl_dataset_rele_flags(ds, DS_HOLD_FLAG_DECRYPT, FTAG);