Skip to content

Commit acc6680

Browse files
Li Nanliu-song-6
authored andcommitted
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 <[email protected]> Signed-off-by: Li Nan <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Song Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 611d5cb commit acc6680

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

drivers/md/md.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -657,24 +657,22 @@ bool md_flush_request(struct mddev *mddev, struct bio *bio)
657657
WARN_ON(percpu_ref_is_zero(&mddev->active_io));
658658
percpu_ref_get(&mddev->active_io);
659659
mddev->flush_bio = bio;
660-
bio = NULL;
661-
}
662-
spin_unlock_irq(&mddev->lock);
663-
664-
if (!bio) {
660+
spin_unlock_irq(&mddev->lock);
665661
INIT_WORK(&mddev->flush_work, submit_flushes);
666662
queue_work(md_wq, &mddev->flush_work);
667-
} else {
668-
/* flush was performed for some other bio while we waited. */
669-
if (bio->bi_iter.bi_size == 0)
670-
/* an empty barrier - all done */
671-
bio_endio(bio);
672-
else {
673-
bio->bi_opf &= ~REQ_PREFLUSH;
674-
return false;
675-
}
663+
return true;
676664
}
677-
return true;
665+
666+
/* flush was performed for some other bio while we waited. */
667+
spin_unlock_irq(&mddev->lock);
668+
if (bio->bi_iter.bi_size == 0) {
669+
/* pure flush without data - all done */
670+
bio_endio(bio);
671+
return true;
672+
}
673+
674+
bio->bi_opf &= ~REQ_PREFLUSH;
675+
return false;
678676
}
679677
EXPORT_SYMBOL(md_flush_request);
680678

0 commit comments

Comments
 (0)