Skip to contentSkip to conversation

md: small cleanups in MD driver

PATCH Applied Abd-Alrhman Masalkhi 2 participants 4 messages Apr 15 – Apr 19 MD RAID

lore
Share & tools
lore
#0 lore raw

cover md: small cleanups in MD driver

Hi,

This small series contains two cleanups in the MD driver.

Patch 1: replaces a wait loop in md_handle_request() with wait_event() Patch 2: replaces a mutex_lock() with mddev_lock_nointr()

Thanks,
Abd-Alrhman

Abd-Alrhman Masalkhi (2):
md: replace wait loop with wait_event() in md_handle_request()
md: use mddev_lock_nointr() in mddev_suspend_and_lock_nointr()

 drivers/md/md.c | 10 +---------
 drivers/md/md.h |  2 +-
 2 files changed, 2 insertions(+), 10 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 md: replace wait loop with wait_event() in md_handle_request()

The wait loop is equivalent to wait_event() and can be simplified by usaing it for improving readability.

---
 drivers/md/md.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/md/md.c +1 -9
index ac71640ff3a8..ba2b5fb2740e 100644
@@ -397,20 +397,12 @@ bool md_handle_request(struct mddev *mddev, struct bio *bio)
 {
 check_suspended:
 	if (is_suspended(mddev, bio)) {
-		DEFINE_WAIT(__wait);
 		/* Bail out if REQ_NOWAIT is set for the bio */
 		if (bio->bi_opf & REQ_NOWAIT) {
 			bio_wouldblock_error(bio);
 			return true;
 		}
-		for (;;) {
-			prepare_to_wait(&mddev->sb_wait, &__wait,
-					TASK_UNINTERRUPTIBLE);
-			if (!is_suspended(mddev, bio))
-				break;
-			schedule();
-		}
-		finish_wait(&mddev->sb_wait, &__wait);
+		wait_event(mddev->sb_wait, !is_suspended(mddev, bio));
 	}
 	if (!percpu_ref_tryget_live(&mddev->active_io))
 		goto check_suspended;
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/2 md: use mddev_lock_nointr() in mddev_suspend_and_lock_nointr()

In reply to Abd-Alrhman Masalkhi

This keeps mddev locking consistent and ensures that any future changes to locking behavior are done through the wrapper.

---
 drivers/md/md.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/md.h +1 -1
index 3bfbee595156..09ced132a917 100644
@@ -1013,7 +1013,7 @@ static inline int mddev_suspend_and_lock(struct mddev *mddev)
 static inline void mddev_suspend_and_lock_nointr(struct mddev *mddev)
 {
 	mddev_suspend(mddev, false);
-	mutex_lock(&mddev->reconfig_mutex);
+	mddev_lock_nointr(mddev);
 }
 
 static inline void mddev_unlock_and_resume(struct mddev *mddev)
Signature · 1 line
2.43.0
Applied
#3 lore raw
In reply to Abd-Alrhman Masalkhi
Quoted 10 lines · Abd-Alrhman Masalkhi

Hi,

This small series contains two cleanups in the MD driver.

Patch 1: replaces a wait loop in md_handle_request() with wait_event() Patch 2: replaces a mutex_lock() with mddev_lock_nointr()

Thanks,
Abd-Alrhman

Quoted 7 lines

Abd-Alrhman Masalkhi (2):
md: replace wait loop with wait_event() in md_handle_request()
md: use mddev_lock_nointr() in mddev_suspend_and_lock_nointr()

  drivers/md/md.c | 10 +---------
  drivers/md/md.h |  2 +-
  2 files changed, 2 insertions(+), 10 deletions(-)

Applied

Signature · 2 lines
Thansk,
Kuai