diff options
author | Li Nan <linan122@huawei.com> | 2024-05-28 22:31:49 +0200 |
---|---|---|
committer | Song Liu <song@kernel.org> | 2024-06-10 21:15:44 +0200 |
commit | acc6680af28696a037ede62867e731841d4454c2 (patch) | |
tree | 4cb3d81a75109db385b3b4c4124f7f45dceab03d /drivers/md/md.c | |
parent | md: fix deadlock between mddev_suspend and flush bio (diff) | |
download | linux-acc6680af28696a037ede62867e731841d4454c2.tar.xz linux-acc6680af28696a037ede62867e731841d4454c2.zip |
md: make md_flush_request() more readable
Setting bio to NULL and checking 'if(!bio)' is redundant and looks strange,
just consolidate them into one condition. There are no functional changes.
Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Li Nan <linan122@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240528203149.2383260-1-linan666@huaweicloud.com
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index e204e36e3170..b9b15aa79496 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -657,24 +657,22 @@ bool md_flush_request(struct mddev *mddev, struct bio *bio) WARN_ON(percpu_ref_is_zero(&mddev->active_io)); percpu_ref_get(&mddev->active_io); mddev->flush_bio = bio; - bio = NULL; - } - spin_unlock_irq(&mddev->lock); - - if (!bio) { + spin_unlock_irq(&mddev->lock); INIT_WORK(&mddev->flush_work, submit_flushes); queue_work(md_wq, &mddev->flush_work); - } else { - /* flush was performed for some other bio while we waited. */ - if (bio->bi_iter.bi_size == 0) - /* an empty barrier - all done */ - bio_endio(bio); - else { - bio->bi_opf &= ~REQ_PREFLUSH; - return false; - } + return true; } - return true; + + /* flush was performed for some other bio while we waited. */ + spin_unlock_irq(&mddev->lock); + if (bio->bi_iter.bi_size == 0) { + /* pure flush without data - all done */ + bio_endio(bio); + return true; + } + + bio->bi_opf &= ~REQ_PREFLUSH; + return false; } EXPORT_SYMBOL(md_flush_request); |