Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4418610ioa; Wed, 27 Apr 2022 03:31:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/mCzQcWJOZagtAmP1RqiUmnKGtHp9GY7Yoe4fV2hAK7Ar8vNgZecHI0VgEi6O+mpIbtRb X-Received: by 2002:a62:e518:0:b0:4fa:9333:ddbd with SMTP id n24-20020a62e518000000b004fa9333ddbdmr29447513pff.11.1651055491177; Wed, 27 Apr 2022 03:31:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651055491; cv=none; d=google.com; s=arc-20160816; b=WQiagYgDt1VFAtKP9P5EfG5PQ6lt0lheikeDeCsLawg9CfSFiMY+w/yFqwwKFvCf82 5s9zUhas/8bGmDI/Uuf7GjLXWn+gjztlZwDqwMagLmLZbpEtS8KqIOt0XdjRqCUK7cc5 q6AYMujdv8qaPAwYrSi/wpwblJd0/SuFM90FEtmKM6rObrOB7FxdZfIrQSC61EdVpWdV 1WfWzcYGAafiDL6oZMKuxRCmQDUHxu/GN8MeXjkj2QvvTnG9U6iQuZN6Smt+z5Zqm1QJ 1sbtNBKSU0epRg9qdixU6shavEGHRf21pE6kDI9NdpMdwAGItYcuXABpWLn3tFi8knnb wIUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:date:message-id:references:cc:to:subject :from:dkim-signature; bh=SIHaNF4527y5Q6cHf2f9Nqj4nsyw93HOagsxqabub9Y=; b=qNBz7dmEx6SayrSYjmIohEgBSljp23p4jA6mnieJnOlJ8ueIoqbVMwLRk00DefHAhn BNxGpZlazByBl7y/a2dYhRXDjH4f6t8zq+829vfJwJelYIPw+pUSyaIvKsI6+CxdG1W5 3R8zeyOfCYB6+i0CYa3Dk/87K5PxnDqgvwnDiarAP8Zi2K3grY31sJaXf1gBvEQoBD/J DKCAvrat5UnmPq1S+2tYleb94mBLyaqlqBYuzrgHHBkLm2L1aJGpaa1/OdRDcL8ykC8h fh9XCA5yDz0Y9kmfz17dgxpMMEeyOwcXVDoTQ1L8typpMRkhEdZ2p7e/PtyrRf5H1KUo VnwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ICUhEc2e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l17-20020a170902f69100b0015cdd65c1easi1304598plg.565.2022.04.27.03.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:31:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ICUhEc2e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5DCB5289FC7; Wed, 27 Apr 2022 02:45:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356691AbiD0BcN (ORCPT + 99 others); Tue, 26 Apr 2022 21:32:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240661AbiD0BcM (ORCPT ); Tue, 26 Apr 2022 21:32:12 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CC3785669; Tue, 26 Apr 2022 18:29:01 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1651022939; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SIHaNF4527y5Q6cHf2f9Nqj4nsyw93HOagsxqabub9Y=; b=ICUhEc2eK9UWupUv/x/Cuz1UaSthfDD5cy9YHCcnZk9Em8EEUaJ95qRC6ys6vlJDZTHhpi pTh2qCCuYGjf1omC10b+Cm8VkStGFbFblZ2b4erj/VQLDnXVIyozPCd+qWwFfueqOEzpCr Koc1uqN09+z2OQ8leadVYXzKLavPw/Q= From: Guoqing Jiang Subject: Re: [PATCH v2 01/12] md/raid5: Factor out ahead_of_reshape() function To: Logan Gunthorpe , linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, Song Liu Cc: Christoph Hellwig , Stephen Bates , Martin Oliveira , David Sloan , Christoph Hellwig References: <20220420195425.34911-1-logang@deltatee.com> <20220420195425.34911-2-logang@deltatee.com> Message-ID: <2a6d5554-4f71-6476-6d14-031da52005f5@linux.dev> Date: Wed, 27 Apr 2022 09:28:33 +0800 MIME-Version: 1.0 In-Reply-To: <20220420195425.34911-2-logang@deltatee.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=no 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 4/21/22 3:54 AM, Logan Gunthorpe wrote: > There are a few uses of an ugly ternary operator in raid5_make_request() > to check if a sector is a head of a reshape sector. > > Factor this out into a simple helper called ahead_of_reshape(). > > This appears to fix the first bio_wouldblock_error() check which appears > to have comparison operators that didn't match the check below which > causes a schedule. Besides this, no functional changes intended. > > Suggested-by: Christoph Hellwig > Signed-off-by: Logan Gunthorpe > --- > drivers/md/raid5.c | 29 +++++++++++++++++------------ > 1 file changed, 17 insertions(+), 12 deletions(-) > > diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c > index 7f7d1546b9ba..97b23c18402b 100644 > --- a/drivers/md/raid5.c > +++ b/drivers/md/raid5.c > @@ -5787,6 +5787,15 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi) > bio_endio(bi); > } > > +static bool ahead_of_reshape(struct mddev *mddev, sector_t sector, > + sector_t reshape_sector) > +{ > + if (mddev->reshape_backwards) > + return sector < reshape_sector; > + else > + return sector >= reshape_sector; > +} I think it can be an inline function. > + > static bool raid5_make_request(struct mddev *mddev, struct bio * bi) > { > struct r5conf *conf = mddev->private; > @@ -5843,9 +5852,8 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi) > /* Bail out if conflicts with reshape and REQ_NOWAIT is set */ > if ((bi->bi_opf & REQ_NOWAIT) && > (conf->reshape_progress != MaxSector) && > - (mddev->reshape_backwards > - ? (logical_sector > conf->reshape_progress && logical_sector <= conf->reshape_safe) > - : (logical_sector >= conf->reshape_safe && logical_sector < conf->reshape_progress))) { > + !ahead_of_reshape(mddev, logical_sector, conf->reshape_progress) && > + ahead_of_reshape(mddev, logical_sector, conf->reshape_safe)) { TBH, the previous code is more readable to me though I can live with the change. Thanks, Guoqing