From nobody Thu Dec 18 01:02:11 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A02FC00A8F for ; Sat, 21 Oct 2023 02:25:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231391AbjJUCZZ (ORCPT ); Fri, 20 Oct 2023 22:25:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231184AbjJUCZV (ORCPT ); Fri, 20 Oct 2023 22:25:21 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5609D7A; Fri, 20 Oct 2023 19:25:17 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SC4zp2W17z4f3lfp; Sat, 21 Oct 2023 10:25:10 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAnt9aHNjNlZ+cUDg--.5642S5; Sat, 21 Oct 2023 10:25:13 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH -next v2 1/6] md: remove useless debug code to print configuration Date: Sat, 21 Oct 2023 18:20:54 +0800 Message-Id: <20231021102059.3198284-2-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231021102059.3198284-1-yukuai1@huaweicloud.com> References: <20231021102059.3198284-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: gC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vEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0pRxhLUUUUUU = X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Yu Kuai One the one hand, print_conf() can be called without grabbing 'reconfig_mtuex' and current rcu protection to access rdev through 'conf' is not safe. Fortunately, there is a separate rcu protection to access rdev from 'mddev->disks', and rdev is always removed from 'conf' before 'mddev->disks'. On the other hand, print_conf() is just used for debug, and user can always grab such information(/proc/mdstat and mdadm). There is no need to always enable this debug and try to fix misuse rcu protection for accessing rdev from 'conf', hence remove print_conf(). Signed-off-by: Yu Kuai --- drivers/md/raid1.c | 28 ---------------------------- drivers/md/raid10.c | 29 ----------------------------- drivers/md/raid5.c | 34 ---------------------------------- 3 files changed, 91 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 35d12948e0a9..c13088eae401 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1679,30 +1679,6 @@ static void raid1_error(struct mddev *mddev, struct = md_rdev *rdev) mdname(mddev), conf->raid_disks - mddev->degraded); } =20 -static void print_conf(struct r1conf *conf) -{ - int i; - - pr_debug("RAID1 conf printout:\n"); - if (!conf) { - pr_debug("(!conf)\n"); - return; - } - pr_debug(" --- wd:%d rd:%d\n", conf->raid_disks - conf->mddev->degraded, - conf->raid_disks); - - rcu_read_lock(); - for (i =3D 0; i < conf->raid_disks; i++) { - struct md_rdev *rdev =3D rcu_dereference(conf->mirrors[i].rdev); - if (rdev) - pr_debug(" disk %d, wo:%d, o:%d, dev:%pg\n", - i, !test_bit(In_sync, &rdev->flags), - !test_bit(Faulty, &rdev->flags), - rdev->bdev); - } - rcu_read_unlock(); -} - static void close_sync(struct r1conf *conf) { int idx; @@ -1763,7 +1739,6 @@ static int raid1_spare_active(struct mddev *mddev) mddev->degraded -=3D count; spin_unlock_irqrestore(&conf->device_lock, flags); =20 - print_conf(conf); return count; } =20 @@ -1829,7 +1804,6 @@ static int raid1_add_disk(struct mddev *mddev, struct= md_rdev *rdev) rcu_assign_pointer(p[conf->raid_disks].rdev, rdev); } =20 - print_conf(conf); return err; } =20 @@ -1846,7 +1820,6 @@ static int raid1_remove_disk(struct mddev *mddev, str= uct md_rdev *rdev) if (rdev !=3D p->rdev) p =3D conf->mirrors + conf->raid_disks + number; =20 - print_conf(conf); if (rdev =3D=3D p->rdev) { if (test_bit(In_sync, &rdev->flags) || atomic_read(&rdev->nr_pending)) { @@ -1902,7 +1875,6 @@ static int raid1_remove_disk(struct mddev *mddev, str= uct md_rdev *rdev) } abort: =20 - print_conf(conf); return err; } =20 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index a5927e98dc67..4b5f34f320c8 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -2059,31 +2059,6 @@ static void raid10_error(struct mddev *mddev, struct= md_rdev *rdev) mdname(mddev), conf->geo.raid_disks - mddev->degraded); } =20 -static void print_conf(struct r10conf *conf) -{ - int i; - struct md_rdev *rdev; - - pr_debug("RAID10 conf printout:\n"); - if (!conf) { - pr_debug("(!conf)\n"); - return; - } - pr_debug(" --- wd:%d rd:%d\n", conf->geo.raid_disks - conf->mddev->degrad= ed, - conf->geo.raid_disks); - - /* This is only called with ->reconfix_mutex held, so - * rcu protection of rdev is not needed */ - for (i =3D 0; i < conf->geo.raid_disks; i++) { - rdev =3D conf->mirrors[i].rdev; - if (rdev) - pr_debug(" disk %d, wo:%d, o:%d, dev:%pg\n", - i, !test_bit(In_sync, &rdev->flags), - !test_bit(Faulty, &rdev->flags), - rdev->bdev); - } -} - static void close_sync(struct r10conf *conf) { wait_barrier(conf, false); @@ -2136,7 +2111,6 @@ static int raid10_spare_active(struct mddev *mddev) mddev->degraded -=3D count; spin_unlock_irqrestore(&conf->device_lock, flags); =20 - print_conf(conf); return count; } =20 @@ -2207,7 +2181,6 @@ static int raid10_add_disk(struct mddev *mddev, struc= t md_rdev *rdev) rcu_assign_pointer(p->replacement, rdev); } =20 - print_conf(conf); return err; } =20 @@ -2219,7 +2192,6 @@ static int raid10_remove_disk(struct mddev *mddev, st= ruct md_rdev *rdev) struct md_rdev **rdevp; struct raid10_info *p; =20 - print_conf(conf); if (unlikely(number >=3D mddev->raid_disks)) return 0; p =3D conf->mirrors + number; @@ -2271,7 +2243,6 @@ static int raid10_remove_disk(struct mddev *mddev, st= ruct md_rdev *rdev) =20 abort: =20 - print_conf(conf); return err; } =20 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 4207e945e8c8..27a4dce51c92 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -156,8 +156,6 @@ static int raid6_idx_to_slot(int idx, struct stripe_hea= d *sh, return slot; } =20 -static void print_raid5_conf (struct r5conf *conf); - static int stripe_operations_active(struct stripe_head *sh) { return sh->check_state || sh->reconstruct_state || @@ -7983,8 +7981,6 @@ static int raid5_run(struct mddev *mddev) mddev->raid_disks-mddev->degraded, mddev->raid_disks, mddev->new_layout); =20 - print_raid5_conf(conf); - if (conf->reshape_progress !=3D MaxSector) { conf->reshape_safe =3D conf->reshape_progress; atomic_set(&conf->reshape_stripes, 0); @@ -8075,7 +8071,6 @@ static int raid5_run(struct mddev *mddev) return 0; abort: md_unregister_thread(mddev, &mddev->thread); - print_raid5_conf(conf); free_conf(conf); mddev->private =3D NULL; pr_warn("md/raid:%s: failed to run raid set.\n", mdname(mddev)); @@ -8107,31 +8102,6 @@ static void raid5_status(struct seq_file *seq, struc= t mddev *mddev) seq_printf (seq, "]"); } =20 -static void print_raid5_conf (struct r5conf *conf) -{ - struct md_rdev *rdev; - int i; - - pr_debug("RAID conf printout:\n"); - if (!conf) { - pr_debug("(conf=3D=3DNULL)\n"); - return; - } - pr_debug(" --- level:%d rd:%d wd:%d\n", conf->level, - conf->raid_disks, - conf->raid_disks - conf->mddev->degraded); - - rcu_read_lock(); - for (i =3D 0; i < conf->raid_disks; i++) { - rdev =3D rcu_dereference(conf->disks[i].rdev); - if (rdev) - pr_debug(" disk %d, o:%d, dev:%pg\n", - i, !test_bit(Faulty, &rdev->flags), - rdev->bdev); - } - rcu_read_unlock(); -} - static int raid5_spare_active(struct mddev *mddev) { int i; @@ -8173,7 +8143,6 @@ static int raid5_spare_active(struct mddev *mddev) spin_lock_irqsave(&conf->device_lock, flags); mddev->degraded =3D raid5_calc_degraded(conf); spin_unlock_irqrestore(&conf->device_lock, flags); - print_raid5_conf(conf); return count; } =20 @@ -8186,7 +8155,6 @@ static int raid5_remove_disk(struct mddev *mddev, str= uct md_rdev *rdev) struct disk_info *p; struct md_rdev *tmp; =20 - print_raid5_conf(conf); if (test_bit(Journal, &rdev->flags) && conf->log) { /* * we can't wait pending write here, as this is called in @@ -8266,7 +8234,6 @@ static int raid5_remove_disk(struct mddev *mddev, str= uct md_rdev *rdev) clear_bit(WantReplacement, &rdev->flags); abort: =20 - print_raid5_conf(conf); return err; } =20 @@ -8348,7 +8315,6 @@ static int raid5_add_disk(struct mddev *mddev, struct= md_rdev *rdev) } } out: - print_raid5_conf(conf); return err; } =20 --=20 2.39.2