Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4411797ioa; Wed, 27 Apr 2022 03:20:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzZqUXOD9UyreSt0fTkKlxqejFBpPHnUKCEf7LDIUp9nyIZVeYWnuhG5Z+dOU5xPS/yxZE X-Received: by 2002:a17:902:bc8b:b0:158:ac00:cca0 with SMTP id bb11-20020a170902bc8b00b00158ac00cca0mr28054666plb.102.1651054825448; Wed, 27 Apr 2022 03:20:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651054825; cv=none; d=google.com; s=arc-20160816; b=L54KUSkQZq8mVKjcCZpZ/m5zTWb6/kLfTyI+6X+t/4dY+8hG0WyH3diGRD8o7D6PBk 5TucMyPnEVF/Ed5bbm8ScQygb4EEOycUXKnzrXtRiYehQu9yz4K/4P2cQb1iZ9u0fLqx ErQzRFdFUx/vy6p4WLtLrC+uRRmG0EE4v6+S5/4RkALJ2aY4rERBIkawYQWh/1mJIv/b 0cuQlELMvbwwwxR182WHtjZUkhB3EdvsbuQg4JiQnjKFmK8pl7WhiHN5urf+IIRWqkVp WiAyFUZopZjSQfPnAyx+rwHNuW9se7p/CLaVPOgke+PNh3tbEDcyJrNcs4gYBd2V6tex H9yw== 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=U9OJAJ+VWS+nkDw471oltmZA8ASzZzfxknB1OTs/0Yc=; b=GimQr2E8AQ0TuQCqiH+xNvZ+KcaWZFz4QqnozrlSwf0hKbN31GJu1OF4KRR5vpNF+B HE1/agM7wl43QuI2gwWaZi+8FeGyjAa+bBWwBPq1kCg1e9NAjb4I5czz/rvXKcC9OtGq HylkbN1Umm2l1OGKoUNhyTiEiuJ8by01Qg89udBeZ/ooRPTDYe9u1W9Co0zZ1kPJjBLj ix6O3Ntqv+4LUS7dk0UStvHBn6S5emp1qROxqf6h4QtTBuCU/G//TKmhXks3u2qdIffe d9FvCRu6I3tzJxVuSXqbHDDid9YVsn2y/iA2rCHmN8eh6Q9shdi4x4/uVJM+WQiiYIzV Snyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=MeWuCZM+; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id ng7-20020a17090b1a8700b001d973c6d990si5222522pjb.169.2022.04.27.03.20.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:20:25 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=MeWuCZM+; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 F3F983677E5; Wed, 27 Apr 2022 02:40:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356987AbiD0B4h (ORCPT + 99 others); Tue, 26 Apr 2022 21:56:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356978AbiD0B4d (ORCPT ); Tue, 26 Apr 2022 21:56:33 -0400 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1CC2FE5D2; Tue, 26 Apr 2022 18:53:24 -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=1651024403; 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=U9OJAJ+VWS+nkDw471oltmZA8ASzZzfxknB1OTs/0Yc=; b=MeWuCZM+tNSEl8NWdJ61UgByFG/nGiTRAITfgH6MhxkKsPh+nRYwSRR0rDm20mEsxW8BAj qTAuuUEVAG4gNEWBNzUK7XnOsTsrKZWu7uv7yYHz4lRzhMwXUyBu2GJuH1BqT0H12ScS3J OvQdLZyOgDFd+M1DTzP8hisApnc1Seg= From: Guoqing Jiang Subject: Re: [PATCH v2 11/12] md/raid5: Check all disks in a stripe_head for reshape progress To: Logan Gunthorpe , linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, Song Liu Cc: Christoph Hellwig , Stephen Bates , Martin Oliveira , David Sloan References: <20220420195425.34911-1-logang@deltatee.com> <20220420195425.34911-12-logang@deltatee.com> Message-ID: <7f61aacd-d378-092c-1291-f2aaf42a5537@linux.dev> Date: Wed, 27 Apr 2022 09:53:16 +0800 MIME-Version: 1.0 In-Reply-To: <20220420195425.34911-12-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: > When testing if a previous stripe has had reshape expand past it, use > the earliest or latest logical sector in all the disks for that stripe > head. This will allow adding multiple disks at a time in a subesquent > patch. > > To do this cleaner, refactor the check into a helper function called > stripe_ahead_of_reshape(). > > Signed-off-by: Logan Gunthorpe > --- > drivers/md/raid5.c | 55 ++++++++++++++++++++++++++++++++++------------ > 1 file changed, 41 insertions(+), 14 deletions(-) > > diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c > index 1fa82d8fa89e..40a25c4b80bd 100644 > --- a/drivers/md/raid5.c > +++ b/drivers/md/raid5.c > @@ -5823,6 +5823,42 @@ static bool ahead_of_reshape(struct mddev *mddev, sector_t sector, > return sector >= reshape_sector; > } > > +static bool range_ahead_of_reshape(struct mddev *mddev, sector_t min, > + sector_t max, sector_t reshape_sector) > +{ > + if (mddev->reshape_backwards) > + return max < reshape_sector; > + else > + return min >= reshape_sector; > +} > + > +static bool stripe_ahead_of_reshape(struct mddev *mddev, struct r5conf *conf, > + struct stripe_head *sh) > +{ > + sector_t max_sector = 0, min_sector = MaxSector; > + bool ret = false; > + int dd_idx; > + > + for (dd_idx = 0; dd_idx < sh->disks; dd_idx++) { > + if (dd_idx == sh->pd_idx) > + continue; > + > + min_sector = min(min_sector, sh->dev[dd_idx].sector); > + max_sector = min(max_sector, sh->dev[dd_idx].sector); > + } > + > + spin_lock_irq(&conf->device_lock); > + > + if (!range_ahead_of_reshape(mddev, min_sector, max_sector, > + conf->reshape_progress)) > + /* mismatch, need to try again */ > + ret = true; I think we can just open code range_ahead_of_reshape. And seems the above is not same as below original checking which compare logical_sector with reshape_progress. Is it intentional or am I miss something? ... > - int must_retry = 0; > - spin_lock_irq(&conf->device_lock); > - if (!ahead_of_reshape(mddev, logical_sector, > - conf->reshape_progress)) > - /* mismatch, need to try again */ > - must_retry = 1; > - spin_unlock_irq(&conf->device_lock); > - if (must_retry) { > - raid5_release_stripe(sh); > - return STRIPE_SCHEDULE_AND_RETRY; > - } > + raid5_release_stripe(sh); > + return STRIPE_SCHEDULE_AND_RETRY; > } > > if (read_seqcount_retry(&conf->gen_lock, seq)) { Thanks, Guoqing