Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2161044rwd; Thu, 15 Jun 2023 23:22:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6RMq9kTzKlEN+8nnWLllMc4EV1YdZ3ArVxU0aNPmSSBrRZxV8ecBJg1gZIww3+Sg1Xp4hl X-Received: by 2002:a05:6a00:181b:b0:654:9d3a:f970 with SMTP id y27-20020a056a00181b00b006549d3af970mr1331534pfa.31.1686896577065; Thu, 15 Jun 2023 23:22:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686896577; cv=none; d=google.com; s=arc-20160816; b=SvaOPJTc+p3hzQVqqH0mAKwWtt72Soj6rbilSX/F2EzkN57woKL5kF1/2yfvYjdKAr T07AIPZDpiBN12nz4SUC9f6Pr+EkO4aLhzApU+mCzeoD8RbauXsNoFf6j3toOAhQEWt9 kkySbj8o2pyL3ZHr3qEbPim6KDhJ3bglg1S+jnhtK0qo2UeLW6tF55McxD9r1qOPBNY8 0XaKxA1hgkutPq0vHqBKx6dfWf7qq1WrexOg5qUA6vJhAx6Srw8WzDJYOKbek2W8mWsx 832iAbjWlGO6jQiPUYnS/rfWjn1kJeBVL4A+QNsZ8a9moXQlnjIThSsDll1CrFmXGQ0i EQtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=fJg23mysYEuiSiObzwzGN/G61eUcyGUPjLingnJVU2w=; b=ZWRc4vKVipKSGuwz8/Xcem+WUMtEq1xD9Gw8TZSNTX2XXwVj+3CrtG95YOQG+h/jpY v2fFwirnwl9ZfHTZDYE3/9ajQ3QUyKNpN07oW/RG+Y41z20ESnHdvn9ScvRptu1WF9lt Jf6wbL65EIbcltHVbb//QDYh8/2XaBTwaUxaiXCHlNdp48iQPk8r4QZSX0B+QU2JWHrd /BmSY9fOA8h18Q2RXpmWVw4e5nxs3jPBffbHuStgZGbXBRRAhwlGNesfNRDfwLVtakL2 aRUzoDA0sZ5hgOZFuHXtsLlUMVtRGRjdCbITQOLmKPLLpDLKj3HeSQd/u9Clk2s3OR2X by0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="pUBf/xg8"; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s10-20020aa78bca000000b00661397beb62si14376976pfd.171.2023.06.15.23.22.43; Thu, 15 Jun 2023 23:22:57 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b="pUBf/xg8"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242697AbjFPGMr (ORCPT + 99 others); Fri, 16 Jun 2023 02:12:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233966AbjFPGMp (ORCPT ); Fri, 16 Jun 2023 02:12:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F5B4269E; Thu, 15 Jun 2023 23:12:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A35F0622C0; Fri, 16 Jun 2023 06:12:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E064BC433C8; Fri, 16 Jun 2023 06:12:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686895962; bh=JiyaFCT5XlQ5cdqxzxNN/QD3/0qLm+DuVjJw4o9ljwQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=pUBf/xg8lWvY3+0lGdY5WnLFtxkq7oE3dmIMKdkCq6tsljGxUjfc2/YZCSCodv9yj 5llG8LKlBHGDIreDK/9G5kKp4q9BMl7he/Mi7P+wOvJrNq2Og4x4eBmTNutf5iPAPa fVPLd/OaotbcSwMu+fJOMGRlCwS7WiwhyEFEycJhmL+f9EAAY2yEbrUlVuvj7eDXDQ TnC2av6PSpuSWlTepzY9fXUpuAS+Of8fWpD92iJhogBFlFWcWlMpq/5+V4X43LG7kI vv/hQT+aB0QoLr6b1HnCymvZO09Q8tB7Z+AjdEnRxuwhXWYyJ12mkY9BY4o/iY14Sr LFdfVAkiPuI+A== Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2b44d77e56bso7128661fa.1; Thu, 15 Jun 2023 23:12:42 -0700 (PDT) X-Gm-Message-State: AC+VfDw/GzR+16Ck9y8EVcSwsmdIdrik82or2PsMniiLQ5iMxWbC8AR1 80OD/t9C6s3j9cIt21k5q7GD8tGI2HIeWEq3PoQ= X-Received: by 2002:a2e:9b01:0:b0:2a2:ac00:4de4 with SMTP id u1-20020a2e9b01000000b002a2ac004de4mr241405lji.22.1686895960931; Thu, 15 Jun 2023 23:12:40 -0700 (PDT) MIME-Version: 1.0 References: <20230609094320.2397604-1-linan666@huaweicloud.com> In-Reply-To: <20230609094320.2397604-1-linan666@huaweicloud.com> From: Song Liu Date: Thu, 15 Jun 2023 23:12:28 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] md/raid10: Only check QUEUE_FLAG_IO_STAT when issuing io To: linan666@huaweicloud.com Cc: jgq516@gmail.com, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, linan122@huawei.com, yukuai3@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 On Fri, Jun 9, 2023 at 2:47=E2=80=AFAM wrote: > > From: Li Nan > > /sys/block/[device]/queue/iostats is used to control whether to count io > stat. Write 0 to it will clear queue_flags QUEUE_FLAG_IO_STAT which means > iostats is disabled. If we disable iostats and later endable it, the io > issued during this period will be counted incorrectly, inflight will be > decreased to -1. > > //T1 set iostats > echo 0 > /sys/block/md0/queue/iostats > clear QUEUE_FLAG_IO_STAT > > //T2 issue io > if (QUEUE_FLAG_IO_STAT) -> false > bio_start_io_acct > inflight++ > > echo 1 > /sys/block/md0/queue/iostats > set QUEUE_FLAG_IO_STAT > > //T3 io end > if (QUEUE_FLAG_IO_STAT) -> true > bio_end_io_acct > inflight-- -> -1 > > Also, if iostats is enabled while issuing io but disabled while io end, > inflight will never be decreased. > > Fix it by checking start_time when io end. Only check QUEUE_FLAG_IO_STAT > while issuing io, just like request based devices. > > Fixes: 528bc2cf2fcc ("md/raid10: enable io accounting") > Signed-off-by: Li Nan The subject and commit log is a little confusing. I updated it a little bit and applied to md-next. Thanks, Song > --- > drivers/md/raid10.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c > index 381c21f7fb06..bf9dca5c25c3 100644 > --- a/drivers/md/raid10.c > +++ b/drivers/md/raid10.c > @@ -325,7 +325,7 @@ static void raid_end_bio_io(struct r10bio *r10_bio) > if (!test_bit(R10BIO_Uptodate, &r10_bio->state)) > bio->bi_status =3D BLK_STS_IOERR; > > - if (blk_queue_io_stat(bio->bi_bdev->bd_disk->queue)) > + if (r10_bio->start_time) > bio_end_io_acct(bio, r10_bio->start_time); > bio_endio(bio); > /* > -- > 2.39.2 >