diff mbox

[5/9] rbd: protect flag bit of RBD_DEV_FLAG_BLACKLISTED with lock_rwsem

Message ID 1525682645-30510-6-git-send-email-dongsheng.yang@easystack.cn (mailing list archive)
State New, archived
Headers show

Commit Message

Dongsheng Yang May 7, 2018, 8:44 a.m. UTC
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
---
 drivers/block/rbd.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox

Patch

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 70ca81d..a13bb06 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3025,7 +3025,9 @@  static void rbd_acquire_lock(struct work_struct *work)
 		 * want to block.
 		 */
 		if (!(rbd_dev->disk->flags & GENHD_FL_UP)) {
+			down_write(&rbd_dev->lock_rwsem);
 			set_bit(RBD_DEV_FLAG_BLACKLISTED, &rbd_dev->flags);
+			up_write(&rbd_dev->lock_rwsem);
 			/* wake "rbd map --exclusive" process */
 			wake_requests(rbd_dev, false);
 		}
@@ -3471,7 +3473,9 @@  static void rbd_reregister_watch(struct work_struct *work)
 	if (ret) {
 		rbd_warn(rbd_dev, "failed to reregister watch: %d", ret);
 		if (ret == -EBLACKLISTED || ret == -ENOENT) {
+			down_write(&rbd_dev->lock_rwsem);
 			set_bit(RBD_DEV_FLAG_BLACKLISTED, &rbd_dev->flags);
+			up_write(&rbd_dev->lock_rwsem);
 			wake_requests(rbd_dev, true);
 		} else {
 			queue_delayed_work(rbd_dev->task_wq,