Skip to content

Commit 855678e

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md: Fix missing release of 'active_io' for flush
submit_flushes atomic_set(&mddev->flush_pending, 1); rdev_for_each_rcu(rdev, mddev) atomic_inc(&mddev->flush_pending); bi->bi_end_io = md_end_flush submit_bio(bi); /* flush io is done first */ md_end_flush if (atomic_dec_and_test(&mddev->flush_pending)) percpu_ref_put(&mddev->active_io) -> active_io is not released if (atomic_dec_and_test(&mddev->flush_pending)) -> missing release of active_io For consequence, mddev_suspend() will wait for 'active_io' to be zero forever. Fix this problem by releasing 'active_io' in submit_flushes() if 'flush_pending' is decreased to zero. Fixes: fa2bbff ("md: synchronize flush io with array reconfiguration") Cc: [email protected] # v6.1+ Reported-by: Blazej Kucman <[email protected]> Closes: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Yu Kuai <[email protected]> Signed-off-by: Song Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9f3fe29 commit 855678e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/md/md.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,12 @@ static void submit_flushes(struct work_struct *ws)
579579
rcu_read_lock();
580580
}
581581
rcu_read_unlock();
582-
if (atomic_dec_and_test(&mddev->flush_pending))
582+
if (atomic_dec_and_test(&mddev->flush_pending)) {
583+
/* The pair is percpu_ref_get() from md_flush_request() */
584+
percpu_ref_put(&mddev->active_io);
585+
583586
queue_work(md_wq, &mddev->flush_work);
587+
}
584588
}
585589

586590
static void md_submit_flush_data(struct work_struct *ws)

0 commit comments

Comments
 (0)