Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp36053imn; Wed, 27 Jul 2022 14:26:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uf3ffvHRtiJsZfTuVOqJrEnjiaxZQyMgYN0rC3lL1LFR3zrreUnuL3RBrHrmtWmLQ37m3h X-Received: by 2002:a63:4558:0:b0:411:442a:b740 with SMTP id u24-20020a634558000000b00411442ab740mr19960957pgk.540.1658957214516; Wed, 27 Jul 2022 14:26:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658957214; cv=none; d=google.com; s=arc-20160816; b=AC1T9BRus2Y//a3bXdZBXpSG9sMFeir1hrT1YROhoP4qNqvyze8Dy2fRb4Ee1G08/b 8ITcREvM+0fzrNTRDoM/CGb5+StqXsP6xipu/iMTHHdrDMstrT7fVDP8boNkPB3M8xaS 7cBzfIyxbSGug7huavM3c+iSDPYHqMO+QIGWv7nW6gvBRIlPca74s94IUGcJZwIyiHyF 9ehbnwGaVk4fp+kUMmaEa/jTyy+5sgeWD3rzjZSRefPr06DMETG30uuDH7TXL9Y6MOJz A7y2UnPdbPxHQ4+RW6r/sncaOSI577s+OZQc2jCGe2TaQSnq1GMowZsLFmi0+4uJEY0p n36A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=grvheGVvup9YTpeIxKlrbH4yr1vdjhEqEftjGji1hi4=; b=sc+e1vM3CEQZyO+9zes8Guh9K0yxiKh9DPPucKtDB3nHjCbJP5iB6qsQrTgdlrTNeQ w8YbqdOfth9fc1S0jpU3uzHfo1kCqgkg0MM46LyNgbSn/KDa9wZkU6IVVyIO1yk2wqAq yfYI6FOwBaIzZ84AGq2lZ6fk5U+CdCuyREuGsl9YPBhIHNdnU1+sa/VBKXhVMsupbSpl ljugwvW8TTnnkHV8XutHDkebLa7nC/UuB0iYHwq79eI5fydX1KfuCPk6UqfRLXziqV45 3OdLb2NmXkgDWR1I83iAUHOmzrtVqS8dTDM+ODsc9i8jzaePK4LIKhjxf8+Y4aIJ2+dX 7G3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b="M5JTO/qX"; 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=deltatee.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 129-20020a630287000000b0041af3628711si10856783pgc.828.2022.07.27.14.26.16; Wed, 27 Jul 2022 14:26:54 -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=@deltatee.com header.s=20200525 header.b="M5JTO/qX"; 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=deltatee.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237700AbiG0VI4 (ORCPT + 99 others); Wed, 27 Jul 2022 17:08:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237594AbiG0VIf (ORCPT ); Wed, 27 Jul 2022 17:08:35 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A518961737; Wed, 27 Jul 2022 14:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:MIME-Version:References:In-Reply-To: Message-Id:Date:Cc:To:From:content-disposition; bh=grvheGVvup9YTpeIxKlrbH4yr1vdjhEqEftjGji1hi4=; b=M5JTO/qX+gDbSsaY1y5DtCne5a kA3+niW7Kc1MrCoYJRdPJMA6n12G1ewKs2uqeB2+rDC8Jkp2j+ZVTIakSm5Q7qG0N0ITGyBroFT// rNQBC4XALKn5qvQbPDhUz8cjjXUxo38wRDaY4Onx9yFW6D+hFBRdeDfoMxDpi7+TO9usq2FcTCDwu SWacAJjo1HAeJi2z2vICZ/c0X5l6e6t+iV8ZC8PEPsWtljQ7jDLTQoZ/TCrQ3kM63dCCXHetctAPT rgarnWEvraQeZnsnfdNvHgImxwhTNksGUnxOMjHGfCzM+iqHZcTvilpZ0B89OlqU3wi4QpcYxM3Ph Gp2MHU6Q==; Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oGoEG-001pyE-GJ; Wed, 27 Jul 2022 15:06:06 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from ) id 1oGoEE-000VI0-Ql; Wed, 27 Jul 2022 15:06:02 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, Song Liu Cc: Christoph Hellwig , Guoqing Jiang , Stephen Bates , Martin Oliveira , David Sloan , Logan Gunthorpe Date: Wed, 27 Jul 2022 15:05:57 -0600 Message-Id: <20220727210600.120221-3-logang@deltatee.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220727210600.120221-1-logang@deltatee.com> References: <20220727210600.120221-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, song@kernel.org, hch@infradead.org, guoqing.jiang@linux.dev, sbates@raithlin.com, Martin.Oliveira@eideticom.com, David.Sloan@eideticom.com, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH 2/5] md/raid5: Make is_inactive_blocked() helper X-SA-Exim-Version: 4.2.1 (built Sat, 13 Feb 2021 17:57:42 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The logic to wait_for_stripe is difficult to parse being on so many lines and with confusing operator precedence. Move it to a helper function to make it easier to read. No functional changes intended. Signed-off-by: Logan Gunthorpe --- drivers/md/raid5.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index b1cb0be8fa67..e7e02a979670 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -755,6 +755,24 @@ static bool has_failed(struct r5conf *conf) return degraded > conf->max_degraded; } +/* + * Block until another thread clears R5_INACTIVE_BLOCKED or + * there are fewer than 3/4 the maximum number of active stripes + * and there is an inactive stripe available. + */ +static bool is_inactive_blocked(struct r5conf *conf, int hash) +{ + int active = atomic_read(&conf->active_stripes); + + if (list_empty(conf->inactive_list + hash)) + return false; + + if (!test_bit(R5_INACTIVE_BLOCKED, &conf->cache_state)) + return true; + + return active < (conf->max_nr_stripes * 3 / 4); +} + struct stripe_head * raid5_get_active_stripe(struct r5conf *conf, sector_t sector, int previous, int noblock, int noquiesce) @@ -796,11 +814,7 @@ raid5_get_active_stripe(struct r5conf *conf, sector_t sector, set_bit(R5_INACTIVE_BLOCKED, &conf->cache_state); r5l_wake_reclaim(conf->log, 0); wait_event_lock_irq(conf->wait_for_stripe, - !list_empty(conf->inactive_list + hash) && - (atomic_read(&conf->active_stripes) - < (conf->max_nr_stripes * 3 / 4) - || !test_bit(R5_INACTIVE_BLOCKED, - &conf->cache_state)), + is_inactive_blocked(conf, hash), *(conf->hash_locks + hash)); clear_bit(R5_INACTIVE_BLOCKED, &conf->cache_state); goto retry; -- 2.30.2