]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Correct lock ASSERTs in vdev_label_read/write
authorOlaf Faaland <faaland1@llnl.gov>
Fri, 21 Apr 2017 21:26:43 +0000 (14:26 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 21 Apr 2017 21:26:43 +0000 (14:26 -0700)
commit0091d66f4ebfeb83f70212ab92a4d5a8e4a9c4dc
tree84e004a1c25257059e274057fd470c56dd304e6a
parentd6418de057ecb71fb4cdc1b0a89d5265d13d121a
Correct lock ASSERTs in vdev_label_read/write

The existing assertions in vdev_label_read() and vdev_label_write(),
testing which config locks are held, are incorrect. The assertions
test for locks which exceed what is required for safety.

Both vdev_label_{read,write}() are changed to assert SCL_STATE is held
as RW_READER or RW_WRITER. This is safe because:

Changes to the vdev tree occur under SCL_ALL as RW_WRITER, via
spa_vdev_enter() and spa_vdev_exit().

Changes to vdev state occur under SCL_STATE_ALL as RW_WRITER, via
spa_vdev_state_enter() and spa_vdev_state_exit().

Therefore, the new assertions guarantee that the vdev cannot change
out from under a zio, and I/O to a specified leaf vdev's label is
safe.

Furthermore, this is consistent with the SPA locking discussion in
spa_misc.c, "For any zio operation that takes an explicit vdev_t
argument ... zio_read_phys(), or zio_write_phys() ... SCL_STATE as
reader suffices."

Reviewed-by: Chunwei Chen <david.chen@osnexus.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #5983
module/zfs/vdev_label.c