Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4219968pxf; Tue, 16 Mar 2021 08:18:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+IANEH7ZTikEccY4syG9RwKJRKVN9srVrk2/g0+1BxIFLIZyiR6P8Ooc5Qf5CWO3dSNEW X-Received: by 2002:a17:906:c210:: with SMTP id d16mr29975310ejz.187.1615907922794; Tue, 16 Mar 2021 08:18:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615907922; cv=none; d=google.com; s=arc-20160816; b=rXA9Kar/mkssbhBirAr4KmHpU9zraD5LrabTwsXfg6tYAWSZuayP4ZbrE+5SM/tBo7 gLf4OxVTU6uKQuWt7uiCAtde54iBN0+KaZu+qLaA3ZFeAmsF+NMHr0CyGWhrfgLMW3Jp +NLTDfBZrqRu6IbsumNLkju1Vi4GRcDQ7fhhkjzpVaD5Wx7Jws/WhTcquNAElUp5aE/o aID8HgbaWVAj+IEziN3nJBqyZF4U8uRRrFwUKRTYW7HXCjGs20nhvdXPFydT+HoVCKKs 61JfutE/Quj0BQGJz7aTd3y/iYmw4dMYSyPajfJUNHW2GLP7wHyY+9WjxcBZjFnMBzSc SIfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:date:message-id:from:references:cc:to :dkim-signature:subject; bh=2RV/8N8KzNaNSB0MsMJ/DLGhsQF2TQXW0NED6d3dcjU=; b=KdYPuUiHLlutmuOdH5GTR7YeGafjcalCzUz5BNv16E4+EhQ+SqPbMlg81/yRkJva8I Pgf0izcy854dPdM6KCXuuiMKcE3BQGKMH4lU8S4e91DcPAlrMkFVwuRKXQww3VYl4v24 cXxIv1eN3GLoULlQpllJAVaXEBHq3ZCZ7GF9nXgxpIHw1lJjlZjrYaQZwzkC6Y4Gkfq+ bxqnHBGRA0iZjl76xbwLZoiMansgWdCGWPKCLe3WRfUwMY7bGXX4tqRGNzJeLQD31i51 qsAtodnkIeAOCIT9zI8ya40BIZMv2PubGLvDgiAiAoAxgS/8DnZCp5o2BVqQnUmBhQIk Seug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synology.com header.s=123 header.b=TDFAuZZg; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=synology.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f1si14288081ejh.95.2021.03.16.08.18.19; Tue, 16 Mar 2021 08:18:42 -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=@synology.com header.s=123 header.b=TDFAuZZg; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=synology.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236619AbhCPKa2 (ORCPT + 99 others); Tue, 16 Mar 2021 06:30:28 -0400 Received: from mail.synology.com ([211.23.38.101]:42972 "EHLO synology.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236569AbhCPKaD (ORCPT ); Tue, 16 Mar 2021 06:30:03 -0400 Subject: Re: [PATCH v2] block: fix trace completion for chained bio DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synology.com; s=123; t=1615890602; bh=bytYvWpMK+2SPyQATrsWUcRSbI+iXR9EQhuampwSLxg=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=TDFAuZZgIuiLzfDJ5Ze+NAIN7OP/LFyPxwAenzNa9HeznkyuZXIaatG4yTH5JwWE1 inPFb+5FlSHQE0UEXM60WldeycIKAAjtS2KoxnkrKOFy42X0M7atVjQ5F8Smx8BRRK bhojU3M4XHLtcHZZ+XWAmU/K9HyzrbSIBy3H6rmc= To: axboe@kernel.dk, neilb@suse.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, s3t@synology.com, bingjingc@synology.com, cccheng@synology.com References: <1614741726-28074-1-git-send-email-edwardh@synology.com> From: Edward Hsieh Message-ID: Date: Tue, 16 Mar 2021 18:30:02 +0800 MIME-Version: 1.0 In-Reply-To: <1614741726-28074-1-git-send-email-edwardh@synology.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Synology-MCP-Status: no X-Synology-Spam-Flag: no X-Synology-Spam-Status: score=0, required 6, WHITELIST_FROM_ADDRESS 0 X-Synology-Virus-Status: no Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jens and Neil, Is there any feedback on this patch? Thank you, Edward Hsieh On 3/3/2021 11:22 AM, Edward Hsieh wrote: > From: Edward Hsieh > > 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. > > md/raid5 read with bio cross chunks can reproduce this issue. > > 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 > --- > block/bio.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > > diff --git a/block/bio.c b/block/bio.c > index a1c4d29..2ff72cb 100644 > --- a/block/bio.c > +++ b/block/bio.c > @@ -1397,8 +1397,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) > { > @@ -1411,6 +1410,11 @@ void bio_endio(struct bio *bio) > 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 > @@ -1424,11 +1428,6 @@ void bio_endio(struct bio *bio) > 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); >