diff mbox

[2/2] rbd: don't queue lock delayed work when we are removing device

Message ID 1527564161-17328-2-git-send-email-dongsheng.yang@easystack.cn (mailing list archive)
State New, archived
Headers show

Commit Message

Dongsheng Yang May 29, 2018, 3:22 a.m. UTC
We should not queue a lock delayed work after cancel_delayed_work_sync(&rbd_dev->lock_dwork);

So let's don't queue lock delayed work when we are removing device.

Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
---
 drivers/block/rbd.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index d1d8f46..8d9d0a6 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3032,8 +3032,12 @@  static void rbd_acquire_lock(struct work_struct *work)
 		}
 	} else if (ret < 0) {
 		rbd_warn(rbd_dev, "error requesting lock: %d", ret);
-		mod_delayed_work(rbd_dev->task_wq, &rbd_dev->lock_dwork,
-				 RBD_RETRY_DELAY);
+		spin_lock_irq(&rbd_dev->lock);
+		if (!test_bit(RBD_DEV_FLAG_REMOVING, &rbd_dev->flags)) {
+			mod_delayed_work(rbd_dev->task_wq, &rbd_dev->lock_dwork,
+					 RBD_RETRY_DELAY);
+		}
+		spin_unlock_irq(&rbd_dev->lock);
 	} else {
 		/*
 		 * lock owner acked, but resend if we don't see them
@@ -3041,8 +3045,12 @@  static void rbd_acquire_lock(struct work_struct *work)
 		 */
 		dout("%s rbd_dev %p requeueing lock_dwork\n", __func__,
 		     rbd_dev);
-		mod_delayed_work(rbd_dev->task_wq, &rbd_dev->lock_dwork,
-		    msecs_to_jiffies(2 * RBD_NOTIFY_TIMEOUT * MSEC_PER_SEC));
+		spin_lock_irq(&rbd_dev->lock);
+		if (!test_bit(RBD_DEV_FLAG_REMOVING, &rbd_dev->flags)) {
+			mod_delayed_work(rbd_dev->task_wq, &rbd_dev->lock_dwork,
+			    msecs_to_jiffies(2 * RBD_NOTIFY_TIMEOUT * MSEC_PER_SEC));
+		}
+		spin_unlock_irq(&rbd_dev->lock);
 	}
 }