diff mbox series

block: eliminate unnecessary flush requests for bio with flush&fua

Message ID 20240830081854.487023-1-yangyongpeng1@oppo.com (mailing list archive)
State New
Headers show
Series block: eliminate unnecessary flush requests for bio with flush&fua | expand

Commit Message

Yongpeng Yang Aug. 30, 2024, 8:18 a.m. UTC
The write bio is configured as follows:
	bio->bi_iter.bi_size = 4096,
	bio->bi_opf |= (REQ_SYNC | REQ_PREFLUSH | REQ_FUA),
	bio->bi_bdev: dm-0(dm-linear) with 1 slave device /dev/sda.
submit_bio(bio), device-mapper will:
	Step 1. submit empty bio with (REQ_SYNC | REQ_PREFLUSH
		| REQ_FUA) flag to /dev/sda.
	Step 2. submit bio with (REQ_SYNC | REQ_FUA) flag to
		/dev/sda.
The blk_insert_flush function will trigger sending a flush request
to /dev/sda twice if the request queue does not support FUA. The
second flush request is unnecessary.

Signed-off-by: Yongpeng Yang <yangyongpeng1@oppo.com>
---
 block/blk-flush.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/block/blk-flush.c b/block/blk-flush.c
index a72e2a83d075..606a6a5ae089 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -445,6 +445,9 @@  bool blk_insert_flush(struct request *rq)
 		fq->flush_data_in_flight++;
 		spin_unlock_irq(&fq->mq_flush_lock);
 		return false;
+	case REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH:
+		policy &= ~REQ_FSEQ_POSTFLUSH;
+		fallthrough;
 	default:
 		/*
 		 * Mark the request as part of a flush sequence and submit it