Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3680584pxf; Mon, 5 Apr 2021 19:49:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2e1exrCEQbg53xv/aOBkoRdQj+eZzk6lDGaEFz1WsJlkodlleedWsz/M+yVtvqeDIzEu2 X-Received: by 2002:a17:906:7806:: with SMTP id u6mr29601227ejm.130.1617677381362; Mon, 05 Apr 2021 19:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617677381; cv=none; d=google.com; s=arc-20160816; b=xA/90scSLWargdH05MoHByqCZBQKsE0U1cMEbolaILrjTHJfPNwyRsPUvBL0wTIElH qRn0o7OSlcyarmVZy4S/WSTKZ46sdDf9Nc+sL8rn19REMmVFRg5TzAGoUTbuNYpfVsJ0 W9dE85w/z9nWeA3rWo/tTCzFGcV1vmJbgDLcj18EKWQ1vMQuWBnGXt9XRIsK3f0MQ+z9 HQLGduYIGWTM3Xel4hn9X3GvdcmyoqbLok/6m7qtHBo92kOYad6ZnOIYWvDYhzo0jw4U /hRwh22zrr3ZBOJ3n3NoRvRq138eRPqqF2YneVtHJd9WUqixV5hIpbi5KLweFoncNn/S zbrA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sXNyw2kjrfTdiJ1kOs/OymGoXuXbe9Mn+ps/lcJzSBs=; b=B5wbbKyGHpqp9VemIGoIKqhrbB8GXXr9pm+nSj3fvnjWA8AvGrkCCzFwmuhPH/Xu/m wTtw66AS20Dig9pyxM6XW/iayjZulmtMjoU9Zhl5p62inkVM6NIViL2lRP3D8Qp1R1er tl/Isewx3CLDAvEHnlsJlU421MTtRBoVMP/QR0Gpw8MyYtF2yM+bJ3s7h2moUiCy51qR W50jr0syfM3N2UwXMibvw1a82SD+QwPa+lY5gKSCEOTDgGTBRCX2ulycTMkVxsSDzie6 E6/+NeNlqedktHL7ZsE12biwLrV1vX9o8EXqjL1oOpOmJVTvhkzLx2pSNYu+gTh+ZK2m AZ2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=h92QLovv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kw15si14698124ejc.217.2021.04.05.19.49.17; Mon, 05 Apr 2021 19:49:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=h92QLovv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239948AbhDEQHa (ORCPT + 99 others); Mon, 5 Apr 2021 12:07:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:58772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239140AbhDEQFk (ORCPT ); Mon, 5 Apr 2021 12:05:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1CC01613E1; Mon, 5 Apr 2021 16:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617638733; bh=KYAN3BxRm/d45qQPO+VJEPD+cFCDPf1hNxi5Ys+0qpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h92QLovv6yxv98kykkoj2uXOxV3D4/DMS5Xblt2+8i94wS+e5AehFAOCNRUF7P/Qq 9KqZaxmO8+og+FbH6lGedQhZDggxIuL0QJr+oqfUdBFt9IwkOIzEOTLqXpYjyRe7oc FLsnx22Y0/oo4GH4VNZuzZN3X4XVsIGlKX0//UOWTvhTwuoEuEePp7i4dHMhIdSZGw 8SwPyQL4Qr+QM5eLPZUyeBN0uju2a6qrObOgYXlFJX44SZN/obdyCofPrXbBopdPj/ OBqvVtIVizbTtUD5DrEdP11JvqzGQDiNSAXLMdtfs0Rl0MASbEG1uEXciJtO8PcbYg JqTCIlnMqc88A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yufen Yu , Keith Busch , Ming Lei , Jens Axboe , Sasha Levin , linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 5/5] block: only update parent bi_status when bio fail Date: Mon, 5 Apr 2021 12:05:26 -0400 Message-Id: <20210405160526.269140-5-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210405160526.269140-1-sashal@kernel.org> References: <20210405160526.269140-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yufen Yu [ Upstream commit 3edf5346e4f2ce2fa0c94651a90a8dda169565ee ] For multiple split bios, if one of the bio is fail, the whole should return error to application. But we found there is a race between bio_integrity_verify_fn and bio complete, which return io success to application after one of the bio fail. The race as following: split bio(READ) kworker nvme_complete_rq blk_update_request //split error=0 bio_endio bio_integrity_endio queue_work(kintegrityd_wq, &bip->bip_work); bio_integrity_verify_fn bio_endio //split bio __bio_chain_endio if (!parent->bi_status) nvme_irq blk_update_request //parent error=7 req_bio_endio bio->bi_status = 7 //parent bio parent->bi_status = 0 parent->bi_end_io() // return bi_status=0 The bio has been split as two: split and parent. When split bio completed, it depends on kworker to do endio, while bio_integrity_verify_fn have been interrupted by parent bio complete irq handler. Then, parent bio->bi_status which have been set in irq handler will overwrite by kworker. In fact, even without the above race, we also need to conside the concurrency beteen mulitple split bio complete and update the same parent bi_status. Normally, multiple split bios will be issued to the same hctx and complete from the same irq vector. But if we have updated queue map between multiple split bios, these bios may complete on different hw queue and different irq vector. Then the concurrency update parent bi_status may cause the final status error. Suggested-by: Keith Busch Signed-off-by: Yufen Yu Reviewed-by: Ming Lei Link: https://lore.kernel.org/r/20210331115359.1125679-1-yuyufen@huawei.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index 1384f9790882..30df1b45dde8 100644 --- a/block/bio.c +++ b/block/bio.c @@ -312,7 +312,7 @@ static struct bio *__bio_chain_endio(struct bio *bio) { struct bio *parent = bio->bi_private; - if (!parent->bi_status) + if (bio->bi_status && !parent->bi_status) parent->bi_status = bio->bi_status; bio_put(bio); return parent; -- 2.30.2