diff options
author | Brian Behlendorf <[email protected]> | 2022-04-28 16:47:12 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2022-04-28 16:47:12 -0700 |
commit | ce8d41ef75e1667710a5aeb393877c7ed4b34576 (patch) | |
tree | fd603d81c5b117f01d57619f77220ae598861712 /module/zfs | |
parent | c0ff5f156070bd815bea811b8fd97ad1a78edd6d (diff) |
Skip spacemaps reading in case of pool readonly import
The only zdb utility require to read metaslab-related data during
read-only pool import because of spacemaps validation. Add global
variable which will allow zdb read spacemaps in case of readonly
import mode.
Reviewed-by: Serapheim Dimitropoulos <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Fedor Uporov <[email protected]>
Closes #9095
Closes #12687
Diffstat (limited to 'module/zfs')
-rw-r--r-- | module/zfs/metaslab.c | 6 | ||||
-rw-r--r-- | module/zfs/spa.c | 7 | ||||
-rw-r--r-- | module/zfs/vdev.c | 6 |
3 files changed, 17 insertions, 2 deletions
diff --git a/module/zfs/metaslab.c b/module/zfs/metaslab.c index f367bea98..9e216c38d 100644 --- a/module/zfs/metaslab.c +++ b/module/zfs/metaslab.c @@ -2659,7 +2659,8 @@ metaslab_init(metaslab_group_t *mg, uint64_t id, uint64_t object, /* * We only open space map objects that already exist. All others - * will be opened when we finally allocate an object for it. + * will be opened when we finally allocate an object for it. For + * readonly pools there is no need to open the space map object. * * Note: * When called from vdev_expand(), we can't call into the DMU as @@ -2668,7 +2669,8 @@ metaslab_init(metaslab_group_t *mg, uint64_t id, uint64_t object, * that case, the object parameter is zero though, so we won't * call into the DMU. */ - if (object != 0) { + if (object != 0 && !(spa->spa_mode == SPA_MODE_READ && + !spa->spa_read_spacemaps)) { error = space_map_open(&ms->ms_sm, mos, object, ms->ms_start, ms->ms_size, vd->vdev_ashift); diff --git a/module/zfs/spa.c b/module/zfs/spa.c index 7c49ced99..dfa73483a 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -181,6 +181,12 @@ boolean_t spa_create_process = B_TRUE; /* no process ==> no sysdc */ boolean_t spa_load_verify_dryrun = B_FALSE; /* + * Allow read spacemaps in case of readonly import (spa_mode == SPA_MODE_READ). + * This is used by zdb for spacemaps verification. + */ +boolean_t spa_mode_readable_spacemaps = B_FALSE; + +/* * This (illegal) pool name is used when temporarily importing a spa_t in order * to get the vdev stats associated with the imported devices. */ @@ -1241,6 +1247,7 @@ spa_activate(spa_t *spa, spa_mode_t mode) spa->spa_state = POOL_STATE_ACTIVE; spa->spa_mode = mode; + spa->spa_read_spacemaps = spa_mode_readable_spacemaps; spa->spa_normal_class = metaslab_class_create(spa, zfs_metaslab_ops); spa->spa_log_class = metaslab_class_create(spa, zfs_metaslab_ops); diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index 57dcfe723..a323b90a2 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -3147,6 +3147,12 @@ vdev_dtl_load(vdev_t *vd) if (vd->vdev_ops->vdev_op_leaf && vd->vdev_dtl_object != 0) { ASSERT(vdev_is_concrete(vd)); + /* + * If the dtl cannot be sync'd there is no need to open it. + */ + if (spa->spa_mode == SPA_MODE_READ && !spa->spa_read_spacemaps) + return (0); + error = space_map_open(&vd->vdev_dtl_sm, mos, vd->vdev_dtl_object, 0, -1ULL, 0); if (error) |