]> git.proxmox.com Git - mirror_zfs.git/commit - module/zfs/spa_misc.c
Prevent race in blkptr_verify against device removal
authorPaul Dagnelie <pcd@delphix.com>
Wed, 14 Aug 2019 03:24:43 +0000 (20:24 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 14 Aug 2019 03:24:43 +0000 (21:24 -0600)
commitdc04a8c757d7df91efbca05491174112540f6e7a
treea7f13ef90ddddd8c64e5af6f0ac9a4470ec4c27e
parent8e556c5ebc7b66caf2cdcc561b6644f9f8437a6d
Prevent race in blkptr_verify against device removal

When we check the vdev of the blkptr in zfs_blkptr_verify, we can run
into a race condition where that vdev is temporarily unavailable. This
happens when a device removal operation and the old vdev_t has been
removed from the array, but the new indirect vdev has not yet been
inserted.

We hold the spa_config_lock while doing our sensitive verification.
To ensure that we don't deadlock, we only grab the lock if we don't
have config_writer held. In addition, I had to const the tags of the
refcounts and the spa_config_lock arguments.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Closes #9112
include/sys/refcount.h
include/sys/spa.h
module/zfs/refcount.c
module/zfs/spa_misc.c
module/zfs/zio.c