Commit acc6680a authored by Li Nan's avatar Li Nan Committed by Song Liu
Browse files

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: default avatarChristoph Hellwig <hch@infradead.org>
Signed-off-by: default avatarLi Nan <linan122@huawei.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarSong Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240528203149.2383260-1-linan666@huaweicloud.com
parent 611d5cbc
Loading
Loading
Loading
Loading
+13 −15
Original line number Diff line number Diff line
@@ -657,25 +657,23 @@ 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) {
		INIT_WORK(&mddev->flush_work, submit_flushes);
		queue_work(md_wq, &mddev->flush_work);
	} else {
		return true;
	}

	/* flush was performed for some other bio while we waited. */
		if (bio->bi_iter.bi_size == 0)
			/* an empty barrier - all done */
	spin_unlock_irq(&mddev->lock);
	if (bio->bi_iter.bi_size == 0) {
		/* pure flush without data - all done */
		bio_endio(bio);
		else {
		return true;
	}

	bio->bi_opf &= ~REQ_PREFLUSH;
	return false;
}
	}
	return true;
}
EXPORT_SYMBOL(md_flush_request);

static inline struct mddev *mddev_get(struct mddev *mddev)