Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7555209rwn; Wed, 14 Sep 2022 00:02:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR57DLh16bqWuzjRi2oh1hsbeUcYFYV03m6qjpSUxcHHs9t47uslWENxDz5e2qon/A3aE8ro X-Received: by 2002:a17:907:72d6:b0:742:133b:42be with SMTP id du22-20020a17090772d600b00742133b42bemr23338894ejc.581.1663138959285; Wed, 14 Sep 2022 00:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663138959; cv=none; d=google.com; s=arc-20160816; b=sOjuNYAtuMkJDdI6wXOlsV1MJpbf3069l4/EM3H3ik6d2C1OMRCUWZ4AxBLaFTSW5N k9jp8Nv2vr0EjstLosvBus4NgmjhkD/sukX+0eRfsRucB6rKOEQ0/jHRXv6FadGmnnO0 MyTedvy9Ak1dC6I5Q5D0HdvK9+QRCSuPuEBr0ZgUfTx0iQ8gdWyv9mLgwAapDUycBP2L WXF1BkIieSyrGnffwNmqVGE40+jW+4ah7G87HgLLn48DrCs5ZHRo+uDWj4Tm3a+ILyeD +mxaheUVDc8sP+mp/BirkswfstKMx61xZk10UEa0DbByXgoH5XMcZ7gbr2Bt3YxvVmbf k0EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=vbU9A9U5lH2dBPxkAk+I4NuIjzHXxLRbpATNuCPkjIM=; b=d0tPsW4DRDpjvnaOqXLQJQzdD0MkrTibudleGDGYjnXqal0QZHVFMkSTdE9m+BIlNY d9EoL9eNabFrmeE6rQC2wbQrNt/8dBLR/ChHYCSR4kzLXqLF2DNEQVW1lLNSAB2k2TuU imdI1cauvatKNX8TFUMNMy9ALaf2L/955zFepqsMBo711zeKr3Z9WmIZWZW8Xli1A3ML alOOcSvJpm3f9FOcHH7qtAyMyJ8kBI5gMlUCu3k+7g9tHAe1lP08T0ePqzXYbdbyGJU+ 0Ma1HBN6nm1SsneQ18wBBPgiEhKSJUrTAtS+8cH/qN68hEwkIAoF9IntIgfk/ZwtCyXH x6eg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lf4-20020a170907174400b0072ab5d0fc33si9504999ejc.863.2022.09.14.00.02.13; Wed, 14 Sep 2022 00:02:39 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbiINGgu (ORCPT + 99 others); Wed, 14 Sep 2022 02:36:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229928AbiINGgs (ORCPT ); Wed, 14 Sep 2022 02:36:48 -0400 Received: from mx1.molgen.mpg.de (mx3.molgen.mpg.de [141.14.17.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F22C38444; Tue, 13 Sep 2022 23:36:46 -0700 (PDT) Received: from [192.168.0.2] (ip5f5aef39.dynamic.kabel-deutschland.de [95.90.239.57]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) (Authenticated sender: pmenzel) by mx.molgen.mpg.de (Postfix) with ESMTPSA id B8A2561EA192A; Wed, 14 Sep 2022 08:36:43 +0200 (CEST) Message-ID: <0b67df9e-7f64-e710-5928-2098ed8d0f2d@molgen.mpg.de> Date: Wed, 14 Sep 2022 08:36:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v2 1/4] md/raid10: cleanup wait_barrier() To: Yu Kuai Cc: song@kernel.org, logang@deltatee.com, guoqing.jiang@linux.dev, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yi.zhang@huawei.com References: <20220914014914.398712-1-yukuai1@huaweicloud.com> <20220914014914.398712-2-yukuai1@huaweicloud.com> Content-Language: en-US From: Paul Menzel In-Reply-To: <20220914014914.398712-2-yukuai1@huaweicloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 Dear Yu, Thank you for the improved patch. Three minor nits. Am 14.09.22 um 03:49 schrieb Yu Kuai: > From: Yu Kuai In the summary/title, I’d spell *Clean up* with a space. Maybe even use: md/raid10: Factor out code from wait_barrier() to stop_waiting_barrier() > Currently the nasty condition is wait_barrier() is hard to read. This > patch factor out the condition into a function. The first *is* above can be removed, and factor*s* needs an s. > There are no functional changes. > > Signed-off-by: Yu Kuai > --- > drivers/md/raid10.c | 56 ++++++++++++++++++++++++++------------------- > 1 file changed, 32 insertions(+), 24 deletions(-) > > diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c > index 64d6e4cd8a3a..56458a53043d 100644 > --- a/drivers/md/raid10.c > +++ b/drivers/md/raid10.c > @@ -957,44 +957,52 @@ static void lower_barrier(struct r10conf *conf) > wake_up(&conf->wait_barrier); > } > > +static bool stop_waiting_barrier(struct r10conf *conf) > +{ > + /* barrier is dropped */ > + if (!conf->barrier) > + return true; > + > + /* > + * If there are already pending requests (preventing the barrier from > + * rising completely), and the pre-process bio queue isn't empty, then > + * don't wait, as we need to empty that queue to get the nr_pending > + * count down. > + */ > + if (atomic_read(&conf->nr_pending)) { > + struct bio_list *bio_list = current->bio_list; > + > + if (bio_list && (!bio_list_empty(&bio_list[0]) || > + !bio_list_empty(&bio_list[1]))) > + return true; > + } > + > + /* move on if recovery thread is blocked by us */ > + if (conf->mddev->thread->tsk == current && > + test_bit(MD_RECOVERY_RUNNING, &conf->mddev->recovery) && > + conf->nr_queued > 0) > + return true; > + > + return false; > +} > + > static bool wait_barrier(struct r10conf *conf, bool nowait) > { > bool ret = true; > > spin_lock_irq(&conf->resync_lock); > if (conf->barrier) { > - struct bio_list *bio_list = current->bio_list; > - conf->nr_waiting++; > - /* Wait for the barrier to drop. > - * However if there are already pending > - * requests (preventing the barrier from > - * rising completely), and the > - * pre-process bio queue isn't empty, > - * then don't wait, as we need to empty > - * that queue to get the nr_pending > - * count down. > - */ > /* Return false when nowait flag is set */ > if (nowait) { > ret = false; > } else { > + conf->nr_waiting++; > raid10_log(conf->mddev, "wait barrier"); > wait_event_lock_irq(conf->wait_barrier, > - !conf->barrier || > - (atomic_read(&conf->nr_pending) && > - bio_list && > - (!bio_list_empty(&bio_list[0]) || > - !bio_list_empty(&bio_list[1]))) || > - /* move on if recovery thread is > - * blocked by us > - */ > - (conf->mddev->thread->tsk == current && > - test_bit(MD_RECOVERY_RUNNING, > - &conf->mddev->recovery) && > - conf->nr_queued > 0), > + stop_waiting_barrier(conf), > conf->resync_lock); > + conf->nr_waiting--; > } > - conf->nr_waiting--; > if (!conf->nr_waiting) > wake_up(&conf->wait_barrier); > } Acked-by: Paul Menzel Kind regards, Paul