mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
vdev_disk_close: take disk write lock before destroying it
Many IO operations are submitted to the kernel async, and so the zio can complete and followup actions before the submission call returns. If one of the followup actions closes the disk (eg during pool create/import), the initiator may be left holding a lock on the disk at destruction. Instead, take the write lock before finishing up and decoupling the disk state from the vdev proper. The caller will hold until all IO is submitted and locks released. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes #17719
This commit is contained in:
1 parent
3f4312a0a4
commit
f319ff3570
1 file changed
+5
-1
@@ -471,13 +471,17 @@ vdev_disk_close(vdev_t *v)
|
||||
if (v->vdev_reopening || vd == NULL)
|
||||
return;
|
||||
|
||||
rw_enter(&vd->vd_lock, RW_WRITER);
|
||||
|
||||
if (vd->vd_bdh != NULL)
|
||||
vdev_blkdev_put(vd->vd_bdh, spa_mode(v->vdev_spa),
|
||||
zfs_vdev_holder);
|
||||
|
||||
v->vdev_tsd = NULL;
|
||||
|
||||
rw_exit(&vd->vd_lock);
|
||||
rw_destroy(&vd->vd_lock);
|
||||
kmem_free(vd, sizeof (vdev_disk_t));
|
||||
v->vdev_tsd = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in new issue
Block a user