block: keep flush error across tag iterator reference drops
Subsystems (2)
PATCH 1/1 block: keep flush error across tag iterator reference drops
Tag iterators such as blk_mq_queue_tag_busy_iter() take a reference on each busy request, the flush request included, and drop it with blk_mq_put_rq_ref(). For the flush request that calls flush_end_io() with a zero status. When that put is not the last one, flush_end_io() stores the status in fq->rq_status for the last put to report, so the iterator's zero overwrites an error the device completion stored there.
With two iterators holding references, the device completes the flush with an error and flush_end_io() stores it, the first iterator drops its reference and stores 0, and the second drop reports success. The requests waiting on the flush complete without the error and fsync() returns 0.
Only store a nonzero status in fq->rq_status, so dropping an iterator reference can't clear an error.
Reproduced on v7.3 in an x86 QEMU guest with scsi_debug, failing every SYNCHRONIZE CACHE through its debugfs error injection while 16 processes read /sys/block/sda/inflight:
modprobe scsi_debug dev_size_mb=64 ndelay=100000
echo "2 1 0x35 0x00 0x00 0x02 0x04 0x44 0x00" > \
/sys/kernel/debug/scsi_debug/<h:c:t:l>/errorfsync() returned 0 for 35 of 18000 calls on /dev/sda and for 46 of 18000 calls on a file on ext4 without a journal, over six runs. With this change every call failed.
---
Ye Bin's "blk-flush: fix possibe deadlock when process nvme_timeout()" (not merged yet) adds lines right after the same assignment, so the second of the two to be applied needs a trivial rebase.
block/blk-flush.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-flush.c +2 -1
@@ -212,7 +212,8 @@ 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; +if (error) + fq->rq_status = error;spin_unlock_irqrestore (&fq->mq_flush_lock, flags);return RQ_END_IO_NONE ; }
Signature · 1 line
2.43.0
Looks good. Bu I guess Jens already picked up the AI-Version of this:
Sorry for not catchign yours earlier.
Quoted 11 lines · Nirmoy Das
Reproduced on v7.3 in an x86 QEMU guest with
scsi_debug, failing every SYNCHRONIZE CACHE through its debugfs error injection while 16 processes read/sys/block/sda/inflight:modprobe scsi_debug dev_size_mb=64 ndelay=100000 echo "2 1 0x35 0x00 0x00 0x02 0x04 0x44 0x00" > \ /sys/kernel/debug/scsi_debug/<h:c:t:l>/error
fsync()returned 0 for 35 of 18000 calls on/dev/sdaand for 46 of 18000 calls on a file on ext4 without a journal, over six runs. With this change every call failed.
Can you add this to blktests?
Quoted 6 lines · Christoph Hellwig
Looks good. Bu I guess Jens already picked up the AI-Version of this:
Sorry for not catchign yours earlier.
No worries.
Quoted 6 lines · Nirmoy Das
Quoted 4 lines
Reproduced on v7.3 in an x86 QEMU guest with
scsi_debug, failing every SYNCHRONIZE CACHE through its debugfs error injection while 16 processes read/sys/block/sda/inflight:
Quoted 8 lines
Quoted 7 lines
modprobe scsi_debug dev_size_mb=64 ndelay=100000 echo "2 1 0x35 0x00 0x00 0x02 0x04 0x44 0x00" > \ /sys/kernel/debug/scsi_debug/<h:c:t:l>/error
fsync()returned 0 for 35 of 18000 calls on/dev/sdaand for 46 of 18000 calls on a file on ext4 without a journal, over six runs. With this change every call failed.Can you add this to blktests?
I will send a PR https://github.com/linux-blktests/blktests
Regards,
Nirmoy