Skip to content

Commit ae5b2ec

Browse files
committed
block: set REQ_SYNC if we clear REQ_FUA|REQ_PREFLUSH
If we insert a flush request, we clear REQ_PREFLUSH and/or REQ_FUA, depending on flush settings. Since op_is_sync() factors those flags in for deciding whether this request is sync or not, we should set REQ_SYNC to avoid screwing up this accounting. This should be less fragile. Reported-by: Logan Gunthorpe <[email protected]> Fixes: b685d3d ("block: treat REQ_FUA and REQ_PREFLUSH as synchronous") Signed-off-by: Jens Axboe <[email protected]>
1 parent b57d74a commit ae5b2ec

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

block/blk-flush.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,13 @@ void blk_insert_flush(struct request *rq)
395395
if (!(fflags & (1UL << QUEUE_FLAG_FUA)))
396396
rq->cmd_flags &= ~REQ_FUA;
397397

398+
/*
399+
* REQ_PREFLUSH|REQ_FUA implies REQ_SYNC, so if we clear any
400+
* of those flags, we have to set REQ_SYNC to avoid skewing
401+
* the request accounting.
402+
*/
403+
rq->cmd_flags |= REQ_SYNC;
404+
398405
/*
399406
* An empty flush handed down from a stacking driver may
400407
* translate into nothing if the underlying device does not

0 commit comments

Comments
 (0)