diff --git a/block/blk-flush.c b/block/blk-flush.c index 403a46c86411..38bd4ae5d9e7 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c @@ -212,7 +212,13 @@ static enum rq_end_io_ret flush_end_io(struct request *flush_rq, spin_lock_irqsave(&fq->mq_flush_lock, flags); if (!req_ref_put_and_test(flush_rq)) { - fq->rq_status = error; + /* + * Remember the status of the flush for whoever drops the last + * reference. blk_mq_put_rq_ref() gets here with BLK_STS_OK and + * must not wipe it out. + */ + if (error != BLK_STS_OK) + fq->rq_status = error; spin_unlock_irqrestore(&fq->mq_flush_lock, flags); return RQ_END_IO_NONE; }