* [PATCH] md: make md_flush_request() more readable
@ 2024-05-25 18:56 linan666
2024-05-26 8:54 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: linan666 @ 2024-05-25 18:56 UTC (permalink / raw)
To: song
Cc: linux-raid, linux-kernel, linan666, yukuai3, yi.zhang, houtao1,
yangerkun
From: Li Nan <linan122@huawei.com>
Setting bio to NULL and checking 'if(!bio)' is redundant and looks strange,
just consolidate them into one condition. There are no functional changes.
Signed-off-by: Li Nan <linan122@huawei.com>
---
drivers/md/md.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index aff9118ff697..509e5638cea1 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -654,15 +654,12 @@ 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. */
+ spin_unlock_irq(&mddev->lock);
if (bio->bi_iter.bi_size == 0)
/* an empty barrier - all done */
bio_endio(bio);
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] md: make md_flush_request() more readable
2024-05-25 18:56 [PATCH] md: make md_flush_request() more readable linan666
@ 2024-05-26 8:54 ` Christoph Hellwig
2024-05-28 2:06 ` Li Nan
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2024-05-26 8:54 UTC (permalink / raw)
To: linan666
Cc: song, linux-raid, linux-kernel, yukuai3, yi.zhang, houtao1,
yangerkun
On Sun, May 26, 2024 at 02:56:22AM +0800, linan666@huaweicloud.com wrote:
> - 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. */
> + spin_unlock_irq(&mddev->lock);
> if (bio->bi_iter.bi_size == 0)
> /* an empty barrier - all done */
This stil looks like a somwwhat odd flow Why not go all the way
and turn it into:
...
queue_work(md_wq, &mddev->flush_work);
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;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] md: make md_flush_request() more readable
2024-05-26 8:54 ` Christoph Hellwig
@ 2024-05-28 2:06 ` Li Nan
0 siblings, 0 replies; 3+ messages in thread
From: Li Nan @ 2024-05-28 2:06 UTC (permalink / raw)
To: Christoph Hellwig
Cc: song, linux-raid, linux-kernel, yukuai3, yi.zhang, houtao1,
yangerkun
在 2024/5/26 16:54, Christoph Hellwig 写道:
> On Sun, May 26, 2024 at 02:56:22AM +0800, linan666@huaweicloud.com wrote:
>> - 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. */
>> + spin_unlock_irq(&mddev->lock);
>> if (bio->bi_iter.bi_size == 0)
>> /* an empty barrier - all done */
>
> This stil looks like a somwwhat odd flow Why not go all the way
> and turn it into:
>
>
> ...
> queue_work(md_wq, &mddev->flush_work);
> 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;
> }
Yeah, it looks better. I will changed it in v2.
Thansk for your suggestion.
--
Thanks,
Nan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-28 2:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-25 18:56 [PATCH] md: make md_flush_request() more readable linan666
2024-05-26 8:54 ` Christoph Hellwig
2024-05-28 2:06 ` Li Nan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).