[PATCH] block: eliminate unnecessary flush requests for bio with flush&fua

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---
 block/blk-flush.c | 3 +++
 1 file changed, 3 insertions(+)

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
-- 
2.40.1





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux