From f0b5347363e7d28acb56bfcf632bc0880d29c81f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 5 Mar 2022 14:51:47 +0100 Subject: [PATCH] 5.4-stable patches added patches: block-fix-fsync-always-failed-if-once-failed.patch --- ...x-fsync-always-failed-if-once-failed.patch | 64 +++++++++++++++++++ queue-5.4/series | 1 + 2 files changed, 65 insertions(+) create mode 100644 queue-5.4/block-fix-fsync-always-failed-if-once-failed.patch diff --git a/queue-5.4/block-fix-fsync-always-failed-if-once-failed.patch b/queue-5.4/block-fix-fsync-always-failed-if-once-failed.patch new file mode 100644 index 00000000000..b83e7715cad --- /dev/null +++ b/queue-5.4/block-fix-fsync-always-failed-if-once-failed.patch @@ -0,0 +1,64 @@ +From foo@baz Sat Mar 5 02:46:44 PM CET 2022 +From: Ye Bin +Date: Mon, 29 Nov 2021 09:26:59 +0800 +Subject: block: Fix fsync always failed if once failed + +From: Ye Bin + +commit 8a7518931baa8ea023700987f3db31cb0a80610b upstream. + +We do test with inject error fault base on v4.19, after test some time we found +sync /dev/sda always failed. +[root@localhost] sync /dev/sda +sync: error syncing '/dev/sda': Input/output error + +scsi log as follows: +[19069.812296] sd 0:0:0:0: [sda] tag#64 Send: scmd 0x00000000d03a0b6b +[19069.812302] sd 0:0:0:0: [sda] tag#64 CDB: Synchronize Cache(10) 35 00 00 00 00 00 00 00 00 00 +[19069.812533] sd 0:0:0:0: [sda] tag#64 Done: SUCCESS Result: hostbyte=DID_OK driverbyte=DRIVER_OK +[19069.812536] sd 0:0:0:0: [sda] tag#64 CDB: Synchronize Cache(10) 35 00 00 00 00 00 00 00 00 00 +[19069.812539] sd 0:0:0:0: [sda] tag#64 scsi host busy 1 failed 0 +[19069.812542] sd 0:0:0:0: Notifying upper driver of completion (result 0) +[19069.812546] sd 0:0:0:0: [sda] tag#64 sd_done: completed 0 of 0 bytes +[19069.812549] sd 0:0:0:0: [sda] tag#64 0 sectors total, 0 bytes done. +[19069.812564] print_req_error: I/O error, dev sda, sector 0 + +ftrace log as follows: + rep-306069 [007] .... 19654.923315: block_bio_queue: 8,0 FWS 0 + 0 [rep] + rep-306069 [007] .... 19654.923333: block_getrq: 8,0 FWS 0 + 0 [rep] + kworker/7:1H-250 [007] .... 19654.923352: block_rq_issue: 8,0 FF 0 () 0 + 0 [kworker/7:1H] + -0 [007] ..s. 19654.923562: block_rq_complete: 8,0 FF () 18446744073709551615 + 0 [0] + -0 [007] d.s. 19654.923576: block_rq_complete: 8,0 WS () 0 + 0 [-5] + +As 8d6996630c03 introduce 'fq->rq_status', this data only update when 'flush_rq' +reference count isn't zero. If flush request once failed and record error code +in 'fq->rq_status'. If there is no chance to update 'fq->rq_status',then do fsync +will always failed. +To address this issue reset 'fq->rq_status' after return error code to upper layer. + +Fixes: 8d6996630c03("block: fix null pointer dereference in blk_mq_rq_timed_out()") +Signed-off-by: Ye Bin +Reviewed-by: Ming Lei +Link: https://lore.kernel.org/r/20211129012659.1553733-1-yebin10@huawei.com +Signed-off-by: Jens Axboe +[sudip: adjust context] +Signed-off-by: Sudip Mukherjee +Signed-off-by: Greg Kroah-Hartman +--- + block/blk-flush.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/block/blk-flush.c ++++ b/block/blk-flush.c +@@ -222,8 +222,10 @@ static void flush_end_io(struct request + return; + } + +- if (fq->rq_status != BLK_STS_OK) ++ if (fq->rq_status != BLK_STS_OK) { + error = fq->rq_status; ++ fq->rq_status = BLK_STS_OK; ++ } + + hctx = flush_rq->mq_hctx; + if (!q->elevator) { diff --git a/queue-5.4/series b/queue-5.4/series index 5f0b6cfc3f8..0ad887ee025 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -26,3 +26,4 @@ batman-adv-don-t-expect-inter-netns-unique-iflink-indices.patch net-dcb-flush-lingering-app-table-entries-for-unregistered-devices.patch net-smc-fix-unexpected-smc_clc_decl_err_regrmb-error-generated-by-client.patch net-smc-fix-unexpected-smc_clc_decl_err_regrmb-error-cause-by-server.patch +block-fix-fsync-always-failed-if-once-failed.patch -- 2.47.2