Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3663380pxf; Mon, 5 Apr 2021 19:08:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhUv5E1eppSYBw2T09b07fp4ZLNmIAM/0RNehhY8RcBptZTNx6E50d7Bdv0b4Q1a/NuH1Z X-Received: by 2002:a05:6402:10c9:: with SMTP id p9mr35226689edu.268.1617674938647; Mon, 05 Apr 2021 19:08:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617674938; cv=none; d=google.com; s=arc-20160816; b=FkV9NWl4vzeBxQGLEpYluhN6Ry5MELNO93+U7HY9feSfhaID0ZFEZdByH6Za4iGuQu bX7y037tzCBqDdREythjPDNvFzx/ZrupxG6EEuawTsAFgraJd+QCZMCCEWDe9kgJL9zo Jn0ECFXx/E043lmdVf9Ek05fzIduu3LSLW7L22brVRy4KKjaOofIg2tDZrd0xfccGfRD d98qAJ0FAHwDGrHb2kUzB7SsYYsfyj2F6j7MbhQ9KASZ9k/OFk0vR/ncJ27cb/47uX91 6Ar1DLie8n9mSlrgp6QyZTJMzvkRDVh3KtIfs26ktYtNqmk/UZaL3uUj4igXRZcn9ozZ hCWA== 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=6mG8k4MwQgphoyhZmUGS36BJlhnNjY0OPogOEii/8Ic=; b=0rg7r05amxZ+A6M/R1xADjsl+8MUozg15AttHX0O0QcGSI+xxDhVdlF3jCPhU+GwA6 PAZbMP+igq8mfpGcrhvYGe6BC2f25ptZB/hAFSuH+wYl83gJddrMKLM/ynEExj7f5wLZ 0Gx7gFlCS9jxqQIvc7yVnUhDYw5ufTcqp2DZ7ae4LHZN/TukKuqrtlcrCKgDS9kuT/lU dy1xA7uW2MMdJCYbZW8AX8nJ/SbLUBbq4/wPsIROOXr7tj4GquNDhGYi1G1XoMjR5cHt efwcDwaySRfqtG0RNXeoJ2xxxrsNpeYcMz4qAa/0TaPj6wyyilqfheXu5460z86i4FQW UZUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FxePwx7I; 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 b6si7006867ejk.0.2021.04.05.19.08.35; Mon, 05 Apr 2021 19:08:58 -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=FxePwx7I; 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 S240112AbhDEQGx (ORCPT + 99 others); Mon, 5 Apr 2021 12:06:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:57682 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241958AbhDEQFb (ORCPT ); Mon, 5 Apr 2021 12:05:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 10924613DA; Mon, 5 Apr 2021 16:05:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617638724; bh=Pnu4XLT048i01pPL7dUpm0pczXeNSgGFed1aJZ2t7Wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FxePwx7IPWUlKbMJXhHYqL1OdpYkYg66aUNzLF4/akhVXRS0zsFypaAbyzJXltCGk Hs2B/omW8SfnfbgrCG+aXgnSR1tt7WqCa0zq7JyDH5c6iGxaoOBAMqmB0vrrbom2Dw FJbggzSt9dM37d6agex3PxIMI2bru5WVoMDOtFs+n2eUTIbe0BvaoiIT2VuaQZySpR cvcfXuEN3os5HIp7vMxZU6inMGpoP1MylT9qVqTmekgvG9BHasH08j+oE4geYhCJRY HMa1Cup3dEEDNKs6lgaP5yf20Df7MyXhKnsmTibDDc7QvGsLJoLCgP0/WO70P03csg wmpp2axtZz6bg== 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.19 7/8] block: only update parent bi_status when bio fail Date: Mon, 5 Apr 2021 12:05:14 -0400 Message-Id: <20210405160515.269020-7-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210405160515.269020-1-sashal@kernel.org> References: <20210405160515.269020-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 3d757055305f..fe749404ef93 100644 --- a/block/bio.c +++ b/block/bio.c @@ -314,7 +314,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