mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-17 15:27:36 +00:00
MFV r289185: 6250 zvol_dump_init() can hold txg open
Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Prakash Surya <prakash.surya@delphix.com> Reviewed by: Albert Lee <trisk@omniti.com> Reviewed by: Xin Li <delphij@freebsd.org> Approved by: Garrett D'Amore <garrett@damore.org> Author: George Wilson <george.wilson@delphix.com> illumos/illumos-gate@b10bba7246
This commit is contained in:
commit
72b6ad9bb5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=289190
@ -2335,13 +2335,15 @@ zvol_dump_init(zvol_state_t *zv, boolean_t resize)
|
||||
vdev_t *vd = spa->spa_root_vdev;
|
||||
nvlist_t *nv = NULL;
|
||||
uint64_t version = spa_version(spa);
|
||||
enum zio_checksum checksum;
|
||||
uint64_t checksum, compress, refresrv, vbs, dedup;
|
||||
|
||||
ASSERT(MUTEX_HELD(&zfsdev_state_lock));
|
||||
ASSERT(vd->vdev_ops == &vdev_root_ops);
|
||||
|
||||
error = dmu_free_long_range(zv->zv_objset, ZVOL_OBJ, 0,
|
||||
DMU_OBJECT_END);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
/* wait for dmu_free_long_range to actually free the blocks */
|
||||
txg_wait_synced(dmu_objset_pool(zv->zv_objset), 0);
|
||||
|
||||
@ -2365,23 +2367,41 @@ zvol_dump_init(zvol_state_t *zv, boolean_t resize)
|
||||
2, ZFS_SPACE_CHECK_RESERVED);
|
||||
}
|
||||
|
||||
if (!resize) {
|
||||
error = dsl_prop_get_integer(zv->zv_name,
|
||||
zfs_prop_to_name(ZFS_PROP_COMPRESSION), &compress, NULL);
|
||||
if (error == 0) {
|
||||
error = dsl_prop_get_integer(zv->zv_name,
|
||||
zfs_prop_to_name(ZFS_PROP_CHECKSUM), &checksum,
|
||||
NULL);
|
||||
}
|
||||
if (error == 0) {
|
||||
error = dsl_prop_get_integer(zv->zv_name,
|
||||
zfs_prop_to_name(ZFS_PROP_REFRESERVATION),
|
||||
&refresrv, NULL);
|
||||
}
|
||||
if (error == 0) {
|
||||
error = dsl_prop_get_integer(zv->zv_name,
|
||||
zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), &vbs,
|
||||
NULL);
|
||||
}
|
||||
if (version >= SPA_VERSION_DEDUP && error == 0) {
|
||||
error = dsl_prop_get_integer(zv->zv_name,
|
||||
zfs_prop_to_name(ZFS_PROP_DEDUP), &dedup, NULL);
|
||||
}
|
||||
}
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
tx = dmu_tx_create(os);
|
||||
dmu_tx_hold_zap(tx, ZVOL_ZAP_OBJ, TRUE, NULL);
|
||||
dmu_tx_hold_bonus(tx, ZVOL_OBJ);
|
||||
error = dmu_tx_assign(tx, TXG_WAIT);
|
||||
if (error) {
|
||||
if (error != 0) {
|
||||
dmu_tx_abort(tx);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* If MULTI_VDEV_CRASH_DUMP is active, use the NOPARITY checksum
|
||||
* function. Otherwise, use the old default -- OFF.
|
||||
*/
|
||||
checksum = spa_feature_is_active(spa,
|
||||
SPA_FEATURE_MULTI_VDEV_CRASH_DUMP) ? ZIO_CHECKSUM_NOPARITY :
|
||||
ZIO_CHECKSUM_OFF;
|
||||
|
||||
/*
|
||||
* If we are resizing the dump device then we only need to
|
||||
* update the refreservation to match the newly updated
|
||||
@ -2393,37 +2413,30 @@ zvol_dump_init(zvol_state_t *zv, boolean_t resize)
|
||||
zfs_prop_to_name(ZFS_PROP_REFRESERVATION), 8, 1,
|
||||
&zv->zv_volsize, tx);
|
||||
} else {
|
||||
uint64_t checksum, compress, refresrv, vbs, dedup;
|
||||
|
||||
error = dsl_prop_get_integer(zv->zv_name,
|
||||
zfs_prop_to_name(ZFS_PROP_COMPRESSION), &compress, NULL);
|
||||
error = error ? error : dsl_prop_get_integer(zv->zv_name,
|
||||
zfs_prop_to_name(ZFS_PROP_CHECKSUM), &checksum, NULL);
|
||||
error = error ? error : dsl_prop_get_integer(zv->zv_name,
|
||||
zfs_prop_to_name(ZFS_PROP_REFRESERVATION), &refresrv, NULL);
|
||||
error = error ? error : dsl_prop_get_integer(zv->zv_name,
|
||||
zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), &vbs, NULL);
|
||||
if (version >= SPA_VERSION_DEDUP) {
|
||||
error = error ? error :
|
||||
dsl_prop_get_integer(zv->zv_name,
|
||||
zfs_prop_to_name(ZFS_PROP_DEDUP), &dedup, NULL);
|
||||
}
|
||||
|
||||
error = error ? error : zap_update(os, ZVOL_ZAP_OBJ,
|
||||
error = zap_update(os, ZVOL_ZAP_OBJ,
|
||||
zfs_prop_to_name(ZFS_PROP_COMPRESSION), 8, 1,
|
||||
&compress, tx);
|
||||
error = error ? error : zap_update(os, ZVOL_ZAP_OBJ,
|
||||
zfs_prop_to_name(ZFS_PROP_CHECKSUM), 8, 1, &checksum, tx);
|
||||
error = error ? error : zap_update(os, ZVOL_ZAP_OBJ,
|
||||
zfs_prop_to_name(ZFS_PROP_REFRESERVATION), 8, 1,
|
||||
&refresrv, tx);
|
||||
error = error ? error : zap_update(os, ZVOL_ZAP_OBJ,
|
||||
zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), 8, 1,
|
||||
&vbs, tx);
|
||||
error = error ? error : dmu_object_set_blocksize(
|
||||
os, ZVOL_OBJ, SPA_OLD_MAXBLOCKSIZE, 0, tx);
|
||||
if (version >= SPA_VERSION_DEDUP) {
|
||||
error = error ? error : zap_update(os, ZVOL_ZAP_OBJ,
|
||||
if (error == 0) {
|
||||
error = zap_update(os, ZVOL_ZAP_OBJ,
|
||||
zfs_prop_to_name(ZFS_PROP_CHECKSUM), 8, 1,
|
||||
&checksum, tx);
|
||||
}
|
||||
if (error == 0) {
|
||||
error = zap_update(os, ZVOL_ZAP_OBJ,
|
||||
zfs_prop_to_name(ZFS_PROP_REFRESERVATION), 8, 1,
|
||||
&refresrv, tx);
|
||||
}
|
||||
if (error == 0) {
|
||||
error = zap_update(os, ZVOL_ZAP_OBJ,
|
||||
zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), 8, 1,
|
||||
&vbs, tx);
|
||||
}
|
||||
if (error == 0) {
|
||||
error = dmu_object_set_blocksize(
|
||||
os, ZVOL_OBJ, SPA_OLD_MAXBLOCKSIZE, 0, tx);
|
||||
}
|
||||
if (version >= SPA_VERSION_DEDUP && error == 0) {
|
||||
error = zap_update(os, ZVOL_ZAP_OBJ,
|
||||
zfs_prop_to_name(ZFS_PROP_DEDUP), 8, 1,
|
||||
&dedup, tx);
|
||||
}
|
||||
@ -2436,7 +2449,15 @@ zvol_dump_init(zvol_state_t *zv, boolean_t resize)
|
||||
* We only need update the zvol's property if we are initializing
|
||||
* the dump area for the first time.
|
||||
*/
|
||||
if (!resize) {
|
||||
if (error == 0 && !resize) {
|
||||
/*
|
||||
* If MULTI_VDEV_CRASH_DUMP is active, use the NOPARITY checksum
|
||||
* function. Otherwise, use the old default -- OFF.
|
||||
*/
|
||||
checksum = spa_feature_is_active(spa,
|
||||
SPA_FEATURE_MULTI_VDEV_CRASH_DUMP) ? ZIO_CHECKSUM_NOPARITY :
|
||||
ZIO_CHECKSUM_OFF;
|
||||
|
||||
VERIFY(nvlist_alloc(&nv, NV_UNIQUE_NAME, KM_SLEEP) == 0);
|
||||
VERIFY(nvlist_add_uint64(nv,
|
||||
zfs_prop_to_name(ZFS_PROP_REFRESERVATION), 0) == 0);
|
||||
@ -2455,13 +2476,11 @@ zvol_dump_init(zvol_state_t *zv, boolean_t resize)
|
||||
error = zfs_set_prop_nvlist(zv->zv_name, ZPROP_SRC_LOCAL,
|
||||
nv, NULL);
|
||||
nvlist_free(nv);
|
||||
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* Allocate the space for the dump */
|
||||
error = zvol_prealloc(zv);
|
||||
if (error == 0)
|
||||
error = zvol_prealloc(zv);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user