md: small cleanups in MD driver
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
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
@@ -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
PATCH 2/2 md: use mddev_lock_nointr() in mddev_suspend_and_lock_nointr()
In reply to Abd-Alrhman MasalkhiThis 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
@@ -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
Yu Kuai
AppliedQuoted 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()withwait_event()Patch 2: replaces amutex_lock()withmddev_lock_nointr()Thanks,
Abd-Alrhman
Quoted 7 lines
Abd-Alrhman Masalkhi (2):
md: replace wait loop withwait_event()inmd_handle_request()
md: usemddev_lock_nointr()inmddev_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