[PATCH -next 2/2] md: fix potential hang for mddev_suspend()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Yu Kuai <yukuai3@xxxxxxxxxx>

Commit 72adae23a72c ("md: Change active_io to percpu") drop that if
'active_io' is decreased to 0 and array is suspended, 'sb_wait' will be
woke up. This is wrong, however, there is no regression reported and I
think this is probably because 'sb_wait' is used in many scenarios and
it's woke up from other context.

Anyway, fix this potential problem by waking up 'sb_wait' in this case.

Fixes: 72adae23a72c ("md: Change active_io to percpu")
Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx>
---
 drivers/md/md.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 0d69b1a2e2d5..1c7eb3cfadb4 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -399,6 +399,9 @@ static bool md_array_enter(struct mddev *mddev, struct bio *bio)
 static void md_array_exit(struct mddev *mddev)
 {
 	percpu_ref_put(&mddev->active_io);
+	if (percpu_ref_is_zero(&mddev->active_io) &&
+	    wq_has_sleeper(&mddev->sb_wait))
+		wake_up(&mddev->sb_wait);
 }
 
 void md_handle_request(struct mddev *mddev, struct bio *bio)
-- 
2.39.2




[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux