Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2647559lqb; Tue, 28 May 2024 06:34:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVcM/iVo5A9mHPujN+XJpgLdNTd456vFGaQx3UCZN0qyRDtCdCqjmWEEpaSbKMuOlQx1T+KmUPzxfKVuvEc/XBHirWwnzIFEA7bznDb/Q== X-Google-Smtp-Source: AGHT+IG/ywQajZYkWbIDSLlN0Ujyrq/cWkMFtB1wzbJ9NDm3MhYZv+ouiXc254oohFM3ZFgEAUjz X-Received: by 2002:a17:906:5a47:b0:a62:2c5f:5a64 with SMTP id a640c23a62f3a-a626407bfacmr891215366b.15.1716903245415; Tue, 28 May 2024 06:34:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716903245; cv=pass; d=google.com; s=arc-20160816; b=DQV7p8UmmFgrqLxjgOANGwUrs1cEmlMp5zxJZXvZwaQ9vyDCRJDZ3ILY8tBIRqOQDS XlxO/Sej4/B87y83kunvN1h9YTst3xam1HtIbfSEZSX1yKcuVH0Nigl09kIOT9iT1Cf8 O/UvfVUuzq4EyPDekxpul+OicEuy47YJdtMdKahq3GIleID0SDFZKqKtk1JzWi2c2nI5 UVYV6FaVDdmeSSEF7f+ZR8hnaGWRkN+4f17Zjqbi8vw/AN/4qSL6iYDc0X5Cj5Se6ULr Muc0t0WxGD4ujxltjByyV9YVU3ntVaWUVobkc/V4kqNsQfFtDgBBnsFR+hLq1/Po9Hpq G55A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:date:message-id:from :references:cc:to:subject; bh=fbmjBQwP4dtLKPB7uI+LZdT+S++Hc1z2pZvWJwk/qZ8=; fh=bYoUGguF1i4seAd9kfCddUewG9Dj2oBXsbvVjkPuBJk=; b=QKrHMlR7y3Nz+kSUUvMPKNAKU+bDZ3gmD6ml5aLPKuNHwE8QLalBia4K7BdLhZyZPn olLkJq3UHm/e0DMv633PHCFC7DO3y+Jmsxj+IkbSIqUeSZ8lcnnDG0pswE3BBrzMo33U kGR/ukTdgpo93JRYO678TQmP8i+sgcI+1XwHsYUcouip0mY/9K6RMim2USf5cf6TKJnd kc8taaAIWblZn4UkELmidllfwpmxjJLkbumkTjxHF5JXTlfbKnNHuUwwA+GcjK4lzsit wXeHGZjjNsCjQ1l16ZnddkUUj+cko+KJc0+yAtJLTXPxbEUWKsjDhtOu4uhafTtNYhkX Y5og==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-192422-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192422-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cc3755dsi516500666b.456.2024.05.28.06.34.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 06:34:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192422-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-192422-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192422-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9246D1F24658 for ; Tue, 28 May 2024 13:33:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E391416F296; Tue, 28 May 2024 13:32:48 +0000 (UTC) Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6B2017C7F; Tue, 28 May 2024 13:32:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716903168; cv=none; b=GpFpkI0OnT4vz7yk9KpPauB/0BgExGYyKVPOOvPmtnQrrcaLeYGuKZK/3AWhtqP0Qp0SsNjj+FE9g0wiU1QVA0g60fTevhhSkw31qYuwH3/ApceXa+RqFPUBxDpCS4QqKVtUzMKpM6DEpOPE+fViRH0XBD8laSYp1MPWCnVmbmA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716903168; c=relaxed/simple; bh=1PhnMJDZWj2BGHeJ5Cta1tAR85uMdgv9y7/GJ2QDmgI=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=s+ov27bzAcK2MYSM4I60aKIDzDoRsIzs4pD9Wdo3OkfxIckZ3LDCkmcLyKcKa77+584d9broDBxm4yga8qYEn3xhPLm8La3N5KvnhP02tNQv0GZcMKie1uWp6huMstRCTPD4TFDMLIb14Q6cwv/s5vRsMTU4UfQlWVkquU7FCkk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VpYNJ5Rjwz4f3jXt; Tue, 28 May 2024 21:32:32 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 04F071A0568; Tue, 28 May 2024 21:32:42 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP1 (Coremail) with SMTP id cCh0CgAXKwT43FVmvE2rNw--.10284S3; Tue, 28 May 2024 21:32:41 +0800 (CST) Subject: Re: [PATCH v2] md: make md_flush_request() more readable To: linan666@huaweicloud.com, song@kernel.org Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com, "yukuai (C)" References: <20240528203149.2383260-1-linan666@huaweicloud.com> From: Yu Kuai Message-ID: <8dc33d99-4b50-fdb7-e81b-581939dadeaa@huaweicloud.com> Date: Tue, 28 May 2024 21:32:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20240528203149.2383260-1-linan666@huaweicloud.com> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgAXKwT43FVmvE2rNw--.10284S3 X-Coremail-Antispam: 1UD129KBjvJXoW7tF13WF4DuFW7CrW3AFW8JFb_yoW8AF47p3 9akasxAr4rtw4DCw47JF4kJwn8Wa1SyFWUtFWaywn5ZFy3ZF1kGw1ag39YqFykGryfC3y8 JFs8A395Cay0vwUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkK14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j 6r4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcVAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCYjI0SjxkI62AI1cAE67vI Y487MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI 0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y 0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxV WUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Wr1j6rW3Jr1lIxAIcVC2z280aVAFwI0_Jr0_ Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUbXdbU UUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Hi, ?? 2024/05/29 4:31, linan666@huaweicloud.com ะด??: > From: Li Nan > > Setting bio to NULL and checking 'if(!bio)' is redundant and looks strange, > just consolidate them into one condition. There are no functional changes. > > Suggested-by: Christoph Hellwig > Signed-off-by: Li Nan > --- > v2: Rewrite the code according to Christoph's suggestion. > > drivers/md/md.c | 28 +++++++++++++--------------- > 1 file changed, 13 insertions(+), 15 deletions(-) > > diff --git a/drivers/md/md.c b/drivers/md/md.c > index aff9118ff697..9598b4898ea9 100644 > --- a/drivers/md/md.c > +++ b/drivers/md/md.c > @@ -654,24 +654,22 @@ bool md_flush_request(struct mddev *mddev, struct bio *bio) > WARN_ON(percpu_ref_is_zero(&mddev->active_io)); > percpu_ref_get(&mddev->active_io); > mddev->flush_bio = bio; > - bio = NULL; > - } > - spin_unlock_irq(&mddev->lock); > - > - if (!bio) { > + spin_unlock_irq(&mddev->lock); > INIT_WORK(&mddev->flush_work, submit_flushes); > queue_work(md_wq, &mddev->flush_work); > - } else { > - /* flush was performed for some other bio while we waited. */ > - if (bio->bi_iter.bi_size == 0) > - /* an empty barrier - all done */ > - bio_endio(bio); > - else { > - bio->bi_opf &= ~REQ_PREFLUSH; > - return false; > - } > + return true; > } > - return true; > + > + /* flush was performed for some other bio while we waited. */ > + spin_unlock_irq(&mddev->lock); > + if (bio->bi_iter.bi_size == 0) { It's better to use bio_sectors() here. Thanks, Kuai > + /* pure flush without data - all done */ > + bio_endio(bio); > + return true; > + } > + > + bio->bi_opf &= ~REQ_PREFLUSH; > + return false; > } > EXPORT_SYMBOL(md_flush_request); > >