diff options
author | Olaf Faaland <[email protected]> | 2018-03-08 15:39:07 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-03-09 15:42:54 -0800 |
commit | 743253df70e9d9772cf98fcdd0fb7f42398d4ff8 (patch) | |
tree | 814d3312cd3f7a6862c45b498acf52b07a360b88 /module | |
parent | ebed90a598677dfba76c95cf184549dbc1cb6be5 (diff) |
Hold SCL_VDEV when counting leaves
A config lock should be held while vdev_count_leaves() walks the tree,
otherwise the pointers reference may become invalid during the walk.
SCL_VDEV is a minimal lock provided for such uses cases.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Tony Hutter <[email protected]>
Signed-off-by: Olaf Faaland <[email protected]>
Closes #7286
Diffstat (limited to 'module')
-rw-r--r-- | module/zfs/vdev.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index c73b2e7f2..172485f6e 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -209,7 +209,13 @@ vdev_count_leaves_impl(vdev_t *vd) int vdev_count_leaves(spa_t *spa) { - return (vdev_count_leaves_impl(spa->spa_root_vdev)); + int rc; + + spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER); + rc = vdev_count_leaves_impl(spa->spa_root_vdev); + spa_config_exit(spa, SCL_VDEV, FTAG); + + return (rc); } void |