Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1782505pxp; Mon, 7 Mar 2022 02:11:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwokjxHEOJwlMLBwevRwMePs3sNmk8kFle/VIUP31fKVIStmpuFg5LfLAp6QLZLlxYDqH+B X-Received: by 2002:a05:6402:358c:b0:412:e44e:f62c with SMTP id y12-20020a056402358c00b00412e44ef62cmr10300922edc.206.1646647896864; Mon, 07 Mar 2022 02:11:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646647896; cv=none; d=google.com; s=arc-20160816; b=WvGDwRrZpUWNpZ9e4prCUZOK7aPOecOgMeIMnCzM9zNIzS/7jtUgj4fGoKaGKAbfI8 IpC1p1wJrgXHJal9EwP8ERcCouUw5BwvPfQZVzYPY/+rO+eap10oK5YZ9EcUXS69Xt3A oLkOeEw7D/hTKgR/eW+T7jykjaGvwF/5NwyqOeL1qfrmxyPSUPWT+JOWRT/W5142/OtD YFTGW1sKTy/lSk9u4ecK7t1RWh1OrrgvzzBj5+CK3n/abItiB+ezbdD2ZE25xZ4VKy8R r+mfx0f2P4sLyo52ac3+O/nJ2ObiUhOSeSQMeeTgl/VgH5B3Ngv2RSOYVxuu3wDP0nMP nE5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ofX5/zMk3J7JfukCUH5JAD/2FrhIpK5Olf+lxOAs0e4=; b=z4COjLN5pp353ZZQvWqWycSTp9E2cS0VJ96cgcw68SqcZRrhZTrPcd8umEOs8GL87b KW+jiC8mjqZU1QQB/laDDzfS+ky65SGrLZTXdK9/9RsyNdh3ANrXpL7dzSYpJIfxjqfp N9zhmbYTiwMtXp/pIjQjw4ZMl7eyTx0kUpZBcU3cGA2u/7U1JJOY3bJO81tPoxWxCd60 FludJHA15z2qIr5k/qN8l/wZPRopj3qrdHtqn8LjuJoWMCSGPhAodoG3t65uCyMryspl zXRgIX4DrTfamoGzfoOEaGkKCb5Qf4A9MawxoMDqqnDcQ6mX8L+SdSkYfLDWzCiaYfN/ gbkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uEmlSwFo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ec43-20020a0564020d6b00b0041630f3cc59si2904975edb.93.2022.03.07.02.11.14; Mon, 07 Mar 2022 02:11:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uEmlSwFo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237506AbiCGJgh (ORCPT + 99 others); Mon, 7 Mar 2022 04:36:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237647AbiCGJ2R (ORCPT ); Mon, 7 Mar 2022 04:28:17 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CEA26AA63; Mon, 7 Mar 2022 01:25:48 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B65E2B810B9; Mon, 7 Mar 2022 09:25:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AF12C340F3; Mon, 7 Mar 2022 09:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645145; bh=l/hF19ts1pVffdE2/W6xqEpFVxjmTbWSdZr2grIVloI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uEmlSwFoQ7CtG7dSTmRXKxYuR6sn5h+vmspFCJZ1eEs118uUW8DdCkyfBH2KkmuvB QOn0XsvQ4UCFa5zvP4s1mv8mlgEOo8SHAD35D42WzIbtgQDLss2qtxnXyB3NDAp1mp jW36X1CPxi+a9KP4COXhhwqmX9U6yptQ3finjUSE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ye Bin , Ming Lei , Jens Axboe , Sudip Mukherjee Subject: [PATCH 4.19 29/51] block: Fix fsync always failed if once failed Date: Mon, 7 Mar 2022 10:19:04 +0100 Message-Id: <20220307091637.820937128@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091636.988950823@linuxfoundation.org> References: <20220307091636.988950823@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 @@ -239,8 +239,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 = blk_mq_map_queue(q, flush_rq->mq_ctx->cpu); if (!q->elevator) {