Message ID | 20230506012315.3370489-4-linan666@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp799080vqo; Fri, 5 May 2023 18:42:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ523Hu34knaaLizJW6L9Kvu2ld2a//x0jIm2pp+WD2K9Lnw1TRecgyvXxx5lxqq5SHX0Rt4 X-Received: by 2002:a05:6a20:442a:b0:ff:68f1:679 with SMTP id ce42-20020a056a20442a00b000ff68f10679mr1241838pzb.52.1683337355621; Fri, 05 May 2023 18:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683337355; cv=none; d=google.com; s=arc-20160816; b=osJfsbRZCxuRBG8S1RrIG1POkB6i9zM1Tl6rOpUfINKzrNzqZZFEanJE/HKqjMwTZe nbWzipgreqpJna8vvXnOh36x1si3K6jeAkz/JtYsv0XSH8o7QVAv4Mv7ag9sI38X9SSv +qaBpE6C0VLfdBHlq/0w7Z/ewdql8ZMaLC5Ac4lKxj84PJiE1vxmY90UHqM0JQHIfwpa VWhd7f81E4CqrZafOG6Sez5HjxVrjr3j5+Ezd2K4mE5MoTnX7kHWmw+HRPX62Nf7y0qi 13bpVM6d/qipCqh+qZU5b7LGenbdFm3Z2QBy/5NqUyRKaLqE+7yoviw1XBJKlb1fx4Ec uaPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1YLXeR/5kHPFzxuXJNIveNrhmma9wPB0fMjvVklTLUE=; b=bP0qgwDBCUAjshswRmxV6Zrv3dj7MR3VDFm2aA0x39DrFSTt1u6JeI5U13h0VjMmhk QTgvBKLY29Rqn0mHYcYf3SvuQfHR3JVp+sBFAIguiJ/vYi0BYupZQNJJTed2EYRcNevm XCzBxjnw7rNFT/UXKYQO94QfURrdcP9k1pmsM2e0Vnuroo24uMPrB74hkPTZcrj/rREo LaCJ6KGBLhgMCjvG0tVM+mCHyeZXrnS42fbgF2GABJgdwRcTCiX1eXX9fmmUFRbVSil9 FrQiODjdeom79XKzZDarPdo2kNWGHT2hEMplkp7yUKdSXj5/tgL1L7CdMsF5CJMyQ37N Mkig== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c19-20020a637253000000b0050f77f03312si3036138pgn.853.2023.05.05.18.42.22; Fri, 05 May 2023 18:42:35 -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 S231854AbjEFBYi (ORCPT <rfc822;baris.duru.linux@gmail.com> + 99 others); Fri, 5 May 2023 21:24:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231437AbjEFBY3 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 5 May 2023 21:24:29 -0400 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D1F07297; Fri, 5 May 2023 18:24:28 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4QCqbC714mz4f3mLL; Sat, 6 May 2023 09:24:23 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgD3X7NHrFVkfh1lIw--.56086S7; Sat, 06 May 2023 09:24:25 +0800 (CST) From: linan666@huaweicloud.com To: song@kernel.org, neilb@suse.de, Rob.Becker@riverbed.com Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, linan122@huawei.com, yukuai3@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com Subject: [PATCH v2 3/4] md/raid10: fix wrong setting of max_corr_read_errors Date: Sat, 6 May 2023 09:23:14 +0800 Message-Id: <20230506012315.3370489-4-linan666@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230506012315.3370489-1-linan666@huaweicloud.com> References: <20230506012315.3370489-1-linan666@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgD3X7NHrFVkfh1lIw--.56086S7 X-Coremail-Antispam: 1UD129KBjvJXoW7CrWDCFWruF13uF43uF4kJFb_yoW8urW3pw 4DAasxZr15J34UAr1DJFykua4Fyw1FkayjyryrAw4fWa43Jr98ta4UGayjgr1DWF1ft3W3 XFZ8KrWDCa18tFUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmjb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUWw A2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2vYz4IE04k24VAvwVAKI4IrM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrV ACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWU JVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2 ka0xkIwI1lw4CEc2x0rVAKj4xxMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j 6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7 AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE 2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcV C2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2Kfnx nUUI43ZEXa7IU1U73PUUUUU== X-CM-SenderInfo: polqt0awwwqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765107150772881675?= X-GMAIL-MSGID: =?utf-8?q?1765107150772881675?= |
Series |
md: bugfix of writing raid sysfs
|
|
Commit Message
Li Nan
May 6, 2023, 1:23 a.m. UTC
From: Li Nan <linan122@huawei.com> max_corr_read_errors should not be negative number. Change it to unsigned int where use it. Fixes: 1e50915fe0bb ("raid: improve MD/raid10 handling of correctable read errors.") Signed-off-by: Li Nan <linan122@huawei.com> --- drivers/md/md.c | 2 +- drivers/md/raid10.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)
Comments
Hi, 在 2023/05/06 9:23, linan666@huaweicloud.com 写道: > From: Li Nan <linan122@huawei.com> > > max_corr_read_errors should not be negative number. Change it to > unsigned int where use it. > Looks good, feel free to add: Reviewed-by: Yu Kuai <yukuai3@huawei.com> > Fixes: 1e50915fe0bb ("raid: improve MD/raid10 handling of correctable read errors.") > Signed-off-by: Li Nan <linan122@huawei.com> > --- > drivers/md/md.c | 2 +- > drivers/md/raid10.c | 5 +++-- > 2 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/md/md.c b/drivers/md/md.c > index fd5c3babcd6d..4a1e566d6bdc 100644 > --- a/drivers/md/md.c > +++ b/drivers/md/md.c > @@ -4486,7 +4486,7 @@ __ATTR_PREALLOC(array_state, S_IRUGO|S_IWUSR, array_state_show, array_state_stor > > static ssize_t > max_corrected_read_errors_show(struct mddev *mddev, char *page) { > - return sprintf(page, "%d\n", > + return sprintf(page, "%u\n", > atomic_read(&mddev->max_corr_read_errors)); > } > > diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c > index 4fcfcb350d2b..4d615fcc6a50 100644 > --- a/drivers/md/raid10.c > +++ b/drivers/md/raid10.c > @@ -2727,7 +2727,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10 > int sect = 0; /* Offset from r10_bio->sector */ > int sectors = r10_bio->sectors; > struct md_rdev *rdev; > - int max_read_errors = atomic_read(&mddev->max_corr_read_errors); > + unsigned int max_read_errors = > + atomic_read(&mddev->max_corr_read_errors); > int d = r10_bio->devs[r10_bio->read_slot].devnum; > > /* still own a reference to this rdev, so it cannot > @@ -2743,7 +2744,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10 > check_decay_read_errors(mddev, rdev); > atomic_inc(&rdev->read_errors); > if (atomic_read(&rdev->read_errors) > max_read_errors) { > - pr_notice("md/raid10:%s: %pg: Raid device exceeded read_error threshold [cur %d:max %d]\n", > + pr_notice("md/raid10:%s: %pg: Raid device exceeded read_error threshold [cur %u:max %u]\n", > mdname(mddev), rdev->bdev, > atomic_read(&rdev->read_errors), max_read_errors); > pr_notice("md/raid10:%s: %pg: Failing raid device\n", >
On Fri, May 5, 2023 at 7:02 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: > > Hi, > > 在 2023/05/06 9:23, linan666@huaweicloud.com 写道: > > From: Li Nan <linan122@huawei.com> > > > > max_corr_read_errors should not be negative number. Change it to > > unsigned int where use it. > > > > Looks good, feel free to add: > > Reviewed-by: Yu Kuai <yukuai3@huawei.com> > > > Fixes: 1e50915fe0bb ("raid: improve MD/raid10 handling of correctable read errors.") > > Signed-off-by: Li Nan <linan122@huawei.com> Hmm.. Does the current code break in any cases? Thanks, Song > > --- > > drivers/md/md.c | 2 +- > > drivers/md/raid10.c | 5 +++-- > > 2 files changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/md/md.c b/drivers/md/md.c > > index fd5c3babcd6d..4a1e566d6bdc 100644 > > --- a/drivers/md/md.c > > +++ b/drivers/md/md.c > > @@ -4486,7 +4486,7 @@ __ATTR_PREALLOC(array_state, S_IRUGO|S_IWUSR, array_state_show, array_state_stor > > > > static ssize_t > > max_corrected_read_errors_show(struct mddev *mddev, char *page) { > > - return sprintf(page, "%d\n", > > + return sprintf(page, "%u\n", > > atomic_read(&mddev->max_corr_read_errors)); > > } > > > > diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c > > index 4fcfcb350d2b..4d615fcc6a50 100644 > > --- a/drivers/md/raid10.c > > +++ b/drivers/md/raid10.c > > @@ -2727,7 +2727,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10 > > int sect = 0; /* Offset from r10_bio->sector */ > > int sectors = r10_bio->sectors; > > struct md_rdev *rdev; > > - int max_read_errors = atomic_read(&mddev->max_corr_read_errors); > > + unsigned int max_read_errors = > > + atomic_read(&mddev->max_corr_read_errors); > > int d = r10_bio->devs[r10_bio->read_slot].devnum; > > > > /* still own a reference to this rdev, so it cannot > > @@ -2743,7 +2744,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10 > > check_decay_read_errors(mddev, rdev); > > atomic_inc(&rdev->read_errors); > > if (atomic_read(&rdev->read_errors) > max_read_errors) { > > - pr_notice("md/raid10:%s: %pg: Raid device exceeded read_error threshold [cur %d:max %d]\n", > > + pr_notice("md/raid10:%s: %pg: Raid device exceeded read_error threshold [cur %u:max %u]\n", > > mdname(mddev), rdev->bdev, > > atomic_read(&rdev->read_errors), max_read_errors); > > pr_notice("md/raid10:%s: %pg: Failing raid device\n", > > >
Hi, 在 2023/05/13 9:08, Song Liu 写道: > On Fri, May 5, 2023 at 7:02 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: >> >> Hi, >> >> 在 2023/05/06 9:23, linan666@huaweicloud.com 写道: >>> From: Li Nan <linan122@huawei.com> >>> >>> max_corr_read_errors should not be negative number. Change it to >>> unsigned int where use it. >>> >> >> Looks good, feel free to add: >> >> Reviewed-by: Yu Kuai <yukuai3@huawei.com> >> >>> Fixes: 1e50915fe0bb ("raid: improve MD/raid10 handling of correctable read errors.") >>> Signed-off-by: Li Nan <linan122@huawei.com> > > Hmm.. Does the current code break in any cases? The problem is that somewhere use unsigned value, and somewhere use signed value, and I thinsk the only functional change is in fix_read_error(), if max_read_errors is negative, the judgement will always pass before this patch: if (atomic_read(&rdev->read_errors) > max_read_errors) Thanks, Kuai > > Thanks, > Song > >>> --- >>> drivers/md/md.c | 2 +- >>> drivers/md/raid10.c | 5 +++-- >>> 2 files changed, 4 insertions(+), 3 deletions(-) >>> >>> diff --git a/drivers/md/md.c b/drivers/md/md.c >>> index fd5c3babcd6d..4a1e566d6bdc 100644 >>> --- a/drivers/md/md.c >>> +++ b/drivers/md/md.c >>> @@ -4486,7 +4486,7 @@ __ATTR_PREALLOC(array_state, S_IRUGO|S_IWUSR, array_state_show, array_state_stor >>> >>> static ssize_t >>> max_corrected_read_errors_show(struct mddev *mddev, char *page) { >>> - return sprintf(page, "%d\n", >>> + return sprintf(page, "%u\n", >>> atomic_read(&mddev->max_corr_read_errors)); >>> } >>> >>> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c >>> index 4fcfcb350d2b..4d615fcc6a50 100644 >>> --- a/drivers/md/raid10.c >>> +++ b/drivers/md/raid10.c >>> @@ -2727,7 +2727,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10 >>> int sect = 0; /* Offset from r10_bio->sector */ >>> int sectors = r10_bio->sectors; >>> struct md_rdev *rdev; >>> - int max_read_errors = atomic_read(&mddev->max_corr_read_errors); >>> + unsigned int max_read_errors = >>> + atomic_read(&mddev->max_corr_read_errors); >>> int d = r10_bio->devs[r10_bio->read_slot].devnum; >>> >>> /* still own a reference to this rdev, so it cannot >>> @@ -2743,7 +2744,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10 >>> check_decay_read_errors(mddev, rdev); >>> atomic_inc(&rdev->read_errors); >>> if (atomic_read(&rdev->read_errors) > max_read_errors) { >>> - pr_notice("md/raid10:%s: %pg: Raid device exceeded read_error threshold [cur %d:max %d]\n", >>> + pr_notice("md/raid10:%s: %pg: Raid device exceeded read_error threshold [cur %u:max %u]\n", >>> mdname(mddev), rdev->bdev, >>> atomic_read(&rdev->read_errors), max_read_errors); >>> pr_notice("md/raid10:%s: %pg: Failing raid device\n", >>> >> > . >
在 2023/5/13 10:21, Yu Kuai 写道: > Hi, > > 在 2023/05/13 9:08, Song Liu 写道: >> On Fri, May 5, 2023 at 7:02 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: >>> >>> Hi, >>> >>> 在 2023/05/06 9:23, linan666@huaweicloud.com 写道: >>>> From: Li Nan <linan122@huawei.com> >>>> >>>> max_corr_read_errors should not be negative number. Change it to >>>> unsigned int where use it. >>>> >>> >>> Looks good, feel free to add: >>> >>> Reviewed-by: Yu Kuai <yukuai3@huawei.com> >>> >>>> Fixes: 1e50915fe0bb ("raid: improve MD/raid10 handling of >>>> correctable read errors.") >>>> Signed-off-by: Li Nan <linan122@huawei.com> >> >> Hmm.. Does the current code break in any cases? > > The problem is that somewhere use unsigned value, and somewhere use > signed value, and I thinsk the only functional change is in > fix_read_error(), if max_read_errors is negative, the judgement will > always pass before this patch: > > if (atomic_read(&rdev->read_errors) > max_read_errors) > In addition, it is confusing for users after setting a huge number to it. # echo 4294967295 > /sys/block/$disk/md/max_read_errors # cat /sys/block/$disk/md/max_read_errors -1
diff --git a/drivers/md/md.c b/drivers/md/md.c index fd5c3babcd6d..4a1e566d6bdc 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -4486,7 +4486,7 @@ __ATTR_PREALLOC(array_state, S_IRUGO|S_IWUSR, array_state_show, array_state_stor static ssize_t max_corrected_read_errors_show(struct mddev *mddev, char *page) { - return sprintf(page, "%d\n", + return sprintf(page, "%u\n", atomic_read(&mddev->max_corr_read_errors)); } diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 4fcfcb350d2b..4d615fcc6a50 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -2727,7 +2727,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10 int sect = 0; /* Offset from r10_bio->sector */ int sectors = r10_bio->sectors; struct md_rdev *rdev; - int max_read_errors = atomic_read(&mddev->max_corr_read_errors); + unsigned int max_read_errors = + atomic_read(&mddev->max_corr_read_errors); int d = r10_bio->devs[r10_bio->read_slot].devnum; /* still own a reference to this rdev, so it cannot @@ -2743,7 +2744,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10 check_decay_read_errors(mddev, rdev); atomic_inc(&rdev->read_errors); if (atomic_read(&rdev->read_errors) > max_read_errors) { - pr_notice("md/raid10:%s: %pg: Raid device exceeded read_error threshold [cur %d:max %d]\n", + pr_notice("md/raid10:%s: %pg: Raid device exceeded read_error threshold [cur %u:max %u]\n", mdname(mddev), rdev->bdev, atomic_read(&rdev->read_errors), max_read_errors); pr_notice("md/raid10:%s: %pg: Failing raid device\n",