Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp547680rdb; Tue, 15 Aug 2023 05:11:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IET6X/nVgp7gks2HMU0tUTcZ+cgmTZ42wEEu1hQTNKFgivfwW0dQS4ngdDAGwxsb3BaXFIY X-Received: by 2002:a05:6a00:2295:b0:686:bbfa:68e3 with SMTP id f21-20020a056a00229500b00686bbfa68e3mr20487416pfe.15.1692101509082; Tue, 15 Aug 2023 05:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692101509; cv=none; d=google.com; s=arc-20160816; b=woWT18yT0Iu+DwpvW7Pzm48S/XlsI5VWECRtS1y+G/vbKk+x9iqC7z//Hhh8lYItw/ E3R7J/7aRFGtmFZMsl+kE1htsVd8rEpZTGX2xwXpRGb2bXqMPROSgNH8/+bj5KmsyLPq kYnNUPsQaI7D475X/YK7DjOQNjOtV3MfaIRT4So0h2pi6+nGmBDFPGpS2deg/KhTJe/j 8M32H3IqwCWqAXCMpHUfpUrFphtG77oGha3RMfe7NKv8cOc7gy+KRE8WNoPWa1B6UubL m02fWoMH2mL8dWPLBymZ+zPNA7j5tTQa5fzEgIvSIfhXrncNp0CIbbuIUS262pjD4neZ IlcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding; bh=D4D9VvBdCD7t7pvtGRkosaNo+llnPK2wyXgPC8A+9yk=; fh=8+t8/lOgGX1YGfrs3OHm4lNupoLWzbIv3GRokerx/fU=; b=eb9COiuOWK7DSQH2osuCHWSx8Eg8X6sQhr4a8wWWeOBzQS8BfkcdCiAYU+yXUiIs5c cLN+eoD+gx+bfachdcAW7qoBKRB1abyQgMYMvPf1onxy3KBhRm2wagPaSH30X7g7V7g8 VY4RkujZlB3nPlvN6AGNr+cSeQr8/3iO21rJCd9sdkh357ifyrRrAgTdRFDeL4jkoY7r 2APlMYkE7kGtrE+16ta9icV/qBDBb99vu+D6AXmllpp2e9SDB62Inot5EPtDU+GKCJ8X 1YxXXu45/lnpZmp33LMlJnCwvln2o+88kqojAtWkNaSjw3hzKGgE5youc1A6+/YZueHu 2gEA== 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 w184-20020a6382c1000000b00563de9f0f02si9678927pgd.365.2023.08.15.05.11.28; Tue, 15 Aug 2023 05:11:49 -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 S233363AbjHNWhF convert rfc822-to-8bit (ORCPT + 99 others); Mon, 14 Aug 2023 18:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233366AbjHNWg4 (ORCPT ); Mon, 14 Aug 2023 18:36:56 -0400 X-Greylist: delayed 1800 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 14 Aug 2023 15:36:55 PDT Received: from neil.brown.name (neil.brown.name [103.29.64.221]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53B1FAB; Mon, 14 Aug 2023 15:36:55 -0700 (PDT) Received: from 196.186.233.220.static.exetel.com.au ([220.233.186.196] helo=home.neil.brown.name) by neil.brown.name with esmtp (Exim 4.95) (envelope-from ) id 1qVfF1-00Grlp-43; Mon, 14 Aug 2023 21:36:47 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 From: "NeilBrown" To: "Song Liu" Cc: "Yu Kuai" , xni@redhat.com, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: Re: [PATCH -next 01/13] md: remove rdev flag 'RemoveSynchronized' In-reply-to: References: <20230803132426.2688608-1-yukuai1@huaweicloud.com>, <20230803132426.2688608-2-yukuai1@huaweicloud.com>, Date: Tue, 15 Aug 2023 07:36:46 +1000 Message-id: <169204900650.11073.14374074900186832485@noble.neil.brown.name> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_NONE 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 On Mon, 14 Aug 2023, Song Liu wrote: > + Neil > > RemoveSynchronized was added by Neil not too long ago. I wonder whether > we still need it in some cases (large raid10 losing a large set of disks). We have customers with thousands of members in a raid10. They do sometimes need to remove half of them. Dropping RemoveSynchronized would significantly increase the time it takes to do that. Removing an rdev is not often a hot path. But sometimes it can be. NeilBrown > > Thanks, > Song > > > On Thu, Aug 3, 2023 at 9:27 PM Yu Kuai wrote: > > > > From: Yu Kuai > > > > When multiple rdevs are removed from array in remove_and_add_spares(), > > which is only possible from daemon thread(user can only remove one rdev > > through ioctl/sysfs at one time), the flag is used to avoid calling > > synchronize_rcu() multiple times for each rdev. > > > > However, remove rdev from daemon thread really is super cold path, while > > removing n rdevs, it doesn't matter sync rcu n times or just one time. > > Hence remove this flag and make code simpler. > > > > Signed-off-by: Yu Kuai > > --- > > drivers/md/md-multipath.c | 15 +++++++-------- > > drivers/md/md.c | 26 ++------------------------ > > drivers/md/md.h | 5 ----- > > drivers/md/raid1.c | 15 +++++++-------- > > drivers/md/raid10.c | 15 +++++++-------- > > drivers/md/raid5.c | 15 +++++++-------- > > 6 files changed, 30 insertions(+), 61 deletions(-) > > > > diff --git a/drivers/md/md-multipath.c b/drivers/md/md-multipath.c > > index d22276870283..9e4ddd5240cd 100644 > > --- a/drivers/md/md-multipath.c > > +++ b/drivers/md/md-multipath.c > > @@ -258,14 +258,13 @@ static int multipath_remove_disk(struct mddev *mddev, struct md_rdev *rdev) > > goto abort; > > } > > p->rdev = NULL; > > - if (!test_bit(RemoveSynchronized, &rdev->flags)) { > > - synchronize_rcu(); > > - if (atomic_read(&rdev->nr_pending)) { > > - /* lost the race, try later */ > > - err = -EBUSY; > > - p->rdev = rdev; > > - goto abort; > > - } > > + > > + synchronize_rcu(); > > + if (atomic_read(&rdev->nr_pending)) { > > + /* lost the race, try later */ > > + err = -EBUSY; > > + p->rdev = rdev; > > + goto abort; > > } > > err = md_integrity_register(mddev); > > } > > diff --git a/drivers/md/md.c b/drivers/md/md.c > > index a3d98273b295..cd7ac1dee3b8 100644 > > --- a/drivers/md/md.c > > +++ b/drivers/md/md.c > > @@ -9155,7 +9155,6 @@ static int remove_and_add_spares(struct mddev *mddev, > > struct md_rdev *rdev; > > int spares = 0; > > int removed = 0; > > - bool remove_some = false; > > > > if (this && test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) > > /* Mustn't remove devices when resync thread is running */ > > @@ -9165,28 +9164,9 @@ static int remove_and_add_spares(struct mddev *mddev, > > if ((this == NULL || rdev == this) && > > rdev->raid_disk >= 0 && > > !test_bit(Blocked, &rdev->flags) && > > - test_bit(Faulty, &rdev->flags) && > > + !test_bit(In_sync, &rdev->flags) && > > + !test_bit(Journal, &rdev->flags) && > > atomic_read(&rdev->nr_pending)==0) { > > - /* Faulty non-Blocked devices with nr_pending == 0 > > - * never get nr_pending incremented, > > - * never get Faulty cleared, and never get Blocked set. > > - * So we can synchronize_rcu now rather than once per device > > - */ > > - remove_some = true; > > - set_bit(RemoveSynchronized, &rdev->flags); > > - } > > - } > > - > > - if (remove_some) > > - synchronize_rcu(); > > - rdev_for_each(rdev, mddev) { > > - if ((this == NULL || rdev == this) && > > - rdev->raid_disk >= 0 && > > - !test_bit(Blocked, &rdev->flags) && > > - ((test_bit(RemoveSynchronized, &rdev->flags) || > > - (!test_bit(In_sync, &rdev->flags) && > > - !test_bit(Journal, &rdev->flags))) && > > - atomic_read(&rdev->nr_pending)==0)) { > > if (mddev->pers->hot_remove_disk( > > mddev, rdev) == 0) { > > sysfs_unlink_rdev(mddev, rdev); > > @@ -9195,8 +9175,6 @@ static int remove_and_add_spares(struct mddev *mddev, > > removed++; > > } > > } > > - if (remove_some && test_bit(RemoveSynchronized, &rdev->flags)) > > - clear_bit(RemoveSynchronized, &rdev->flags); > > } > > > > if (removed && mddev->kobj.sd) > > diff --git a/drivers/md/md.h b/drivers/md/md.h > > index 8ae957480976..b25b6d061372 100644 > > --- a/drivers/md/md.h > > +++ b/drivers/md/md.h > > @@ -189,11 +189,6 @@ enum flag_bits { > > * than other devices in the array > > */ > > ClusterRemove, > > - RemoveSynchronized, /* synchronize_rcu() was called after > > - * this device was known to be faulty, > > - * so it is safe to remove without > > - * another synchronize_rcu() call. > > - */ > > ExternalBbl, /* External metadata provides bad > > * block management for a disk > > */ > > diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c > > index 23d211969565..acb6d6542619 100644 > > --- a/drivers/md/raid1.c > > +++ b/drivers/md/raid1.c > > @@ -1859,15 +1859,14 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev) > > goto abort; > > } > > p->rdev = NULL; > > - if (!test_bit(RemoveSynchronized, &rdev->flags)) { > > - synchronize_rcu(); > > - if (atomic_read(&rdev->nr_pending)) { > > - /* lost the race, try later */ > > - err = -EBUSY; > > - p->rdev = rdev; > > - goto abort; > > - } > > + synchronize_rcu(); > > + if (atomic_read(&rdev->nr_pending)) { > > + /* lost the race, try later */ > > + err = -EBUSY; > > + p->rdev = rdev; > > + goto abort; > > } > > + > > if (conf->mirrors[conf->raid_disks + number].rdev) { > > /* We just removed a device that is being replaced. > > * Move down the replacement. We drain all IO before > > diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c > > index 7704a4c7f469..64dd5cb6133e 100644 > > --- a/drivers/md/raid10.c > > +++ b/drivers/md/raid10.c > > @@ -2247,15 +2247,14 @@ static int raid10_remove_disk(struct mddev *mddev, struct md_rdev *rdev) > > goto abort; > > } > > *rdevp = NULL; > > - if (!test_bit(RemoveSynchronized, &rdev->flags)) { > > - synchronize_rcu(); > > - if (atomic_read(&rdev->nr_pending)) { > > - /* lost the race, try later */ > > - err = -EBUSY; > > - *rdevp = rdev; > > - goto abort; > > - } > > + synchronize_rcu(); > > + if (atomic_read(&rdev->nr_pending)) { > > + /* lost the race, try later */ > > + err = -EBUSY; > > + *rdevp = rdev; > > + goto abort; > > } > > + > > if (p->replacement) { > > /* We must have just cleared 'rdev' */ > > p->rdev = p->replacement; > > diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c > > index 4cdb35e54251..37d9865b180a 100644 > > --- a/drivers/md/raid5.c > > +++ b/drivers/md/raid5.c > > @@ -8267,15 +8267,14 @@ static int raid5_remove_disk(struct mddev *mddev, struct md_rdev *rdev) > > goto abort; > > } > > *rdevp = NULL; > > - if (!test_bit(RemoveSynchronized, &rdev->flags)) { > > - lockdep_assert_held(&mddev->reconfig_mutex); > > - synchronize_rcu(); > > - if (atomic_read(&rdev->nr_pending)) { > > - /* lost the race, try later */ > > - err = -EBUSY; > > - rcu_assign_pointer(*rdevp, rdev); > > - } > > + lockdep_assert_held(&mddev->reconfig_mutex); > > + synchronize_rcu(); > > + if (atomic_read(&rdev->nr_pending)) { > > + /* lost the race, try later */ > > + err = -EBUSY; > > + rcu_assign_pointer(*rdevp, rdev); > > } > > + > > if (!err) { > > err = log_modify(conf, rdev, false); > > if (err) > > -- > > 2.39.2 > > >