Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2834713pxv; Mon, 12 Jul 2021 03:06:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwr7HdiMAKsiF+3PtLIIAN46CuAAvB4MbYxd6rOalGHYLVwJ5r08vIGvGT3oSbRakl3EOWu X-Received: by 2002:a92:190e:: with SMTP id 14mr35002282ilz.70.1626084403786; Mon, 12 Jul 2021 03:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084403; cv=none; d=google.com; s=arc-20160816; b=y9deaYzoM93nQCun7N7SyCmbky3k70FPPTkdxtI+OKVTQP4PmEQyGnkxtIIonzyXNn OvUnd2LUux50UU5rDAe/1Iv8uuv8L+3wJEyEzr4nsM+xvycRusQyMMXnlSGx1xowGIS2 7nby9FUme4Rll2gGxFouixfvzbI5Cu7PLQvaKxoozKRCdyrqbBA96/TEEsSfSGDXZYRX nXaEYG5BWc9kCKFMJRwyBVMYr8FH3RPmYc2u2iYtZ8LomV1MFWdqpGRCsBdfR8YUNuEB KJGtB1EfCGJBewcVRwO9DtUQ4yq3xXQrx/mv3lU3jVu4/j1hAISGBCGVUbV+7Nc/U5BH Xkpw== 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=t/Ok3pTUatmzdIHP51oOVC4eHEcW7ZM2eNTt5TOZvlo=; b=syTezFmRE4dkTe6EPmncgyItZfwQhLu3bu79ZuT3oHTExsL7cVyKUveYdZsN5AlBrP 0xab5ADPuD/Zhjdo2EQPDelFeBw+VbaouDrLlzDPKPW8Ztog80PblLJQDxflYJMYLzID sgr9ypWhMUAsweTfeYh7Pez2Twsf+1RNPxxRU7i3Q9b6mH1XANYSse7YS9PtjjO9ip0D ZhaUZICNV8qvebCg92TKPZfsUoJstG+EUhoY+uvpVz0jccMK2iY1aRBoCn3zbq5+yw0u Qtdx7Np10VrJloB5l5V34cWqqEELZ7W3C2ceBORxamzc2QJ8BQNM+SAzgtyJeVVc9Jhg f/iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bXkZAFIg; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t10si16085172ilp.101.2021.07.12.03.06.32; Mon, 12 Jul 2021 03:06:43 -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=@linuxfoundation.org header.s=korg header.b=bXkZAFIg; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345546AbhGLHnG (ORCPT + 99 others); Mon, 12 Jul 2021 03:43:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:46008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239110AbhGLHLp (ORCPT ); Mon, 12 Jul 2021 03:11:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DA93160FE7; Mon, 12 Jul 2021 07:08:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626073736; bh=+/JFy+slToYPRalqVJJOi9ffJwiRSsiakNYtXkNAREA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bXkZAFIgRCjX7/ChKDECsO4m8t6F8hxabXv0PlKQingxWkukruf72EzZg8drn5odP 8X7+jchA0OFKa1c4KcppTXRaobfBFjswh26mJib9ko1DRIzlIdIKLe5wogY75eiVPp Xy+AloDC2TEDz4cwpmE5rag0rj4f+DZXG6xJRRyA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wade Liang , BingJing Chang , Edward Hsieh , Christoph Hellwig , Jens Axboe , Sasha Levin Subject: [PATCH 5.12 341/700] block: fix trace completion for chained bio Date: Mon, 12 Jul 2021 08:07:04 +0200 Message-Id: <20210712061012.579182430@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Edward Hsieh [ Upstream commit 60b6a7e6a0f4382cd689f9afdac816964fec2921 ] For chained bio, trace_block_bio_complete in bio_endio is currently called only by the parent bio once upon all chained bio completed. However, the sector and size for the parent bio are modified in bio_split. Therefore, the size and sector of the complete events might not match the queue events in blktrace. The original fix of bio completion trace ("block: trace completion of all bios.") wants multiple complete events to correspond to one queue event but missed this. The issue can be reproduced by md/raid5 read with bio cross chunks. To fix, move trace completion into the loop for every chained bio to call. Fixes: fbbaf700e7b1 ("block: trace completion of all bios.") Reviewed-by: Wade Liang Reviewed-by: BingJing Chang Signed-off-by: Edward Hsieh Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/r/20210624123030.27014-1-edwardh@synology.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bio.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/block/bio.c b/block/bio.c index 50e579088aca..b00c5a88a743 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1412,8 +1412,7 @@ static inline bool bio_remaining_done(struct bio *bio) * * bio_endio() can be called several times on a bio that has been chained * using bio_chain(). The ->bi_end_io() function will only be called the - * last time. At this point the BLK_TA_COMPLETE tracing event will be - * generated if BIO_TRACE_COMPLETION is set. + * last time. **/ void bio_endio(struct bio *bio) { @@ -1426,6 +1425,11 @@ again: if (bio->bi_bdev) rq_qos_done_bio(bio->bi_bdev->bd_disk->queue, bio); + if (bio->bi_bdev && bio_flagged(bio, BIO_TRACE_COMPLETION)) { + trace_block_bio_complete(bio->bi_bdev->bd_disk->queue, bio); + bio_clear_flag(bio, BIO_TRACE_COMPLETION); + } + /* * Need to have a real endio function for chained bios, otherwise * various corner cases will break (like stacking block devices that @@ -1439,11 +1443,6 @@ again: goto again; } - if (bio->bi_bdev && bio_flagged(bio, BIO_TRACE_COMPLETION)) { - trace_block_bio_complete(bio->bi_bdev->bd_disk->queue, bio); - bio_clear_flag(bio, BIO_TRACE_COMPLETION); - } - blk_throtl_bio_endio(bio); /* release cgroup info */ bio_uninit(bio); -- 2.30.2