All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
To: Wu Guanghao <wuguanghao3@huawei.com>
Cc: <song@kernel.org>, <linux-raid@vger.kernel.org>,
	"liuzhiqiang (I)" <liuzhiqiang26@huawei.com>,
	<louhongxiang@huawei.com>
Subject: Re: [PATCH] raid0: fix set_disk_faulty doesn't return -EBUSY
Date: Tue, 21 Mar 2023 11:18:28 +0100	[thread overview]
Message-ID: <20230321111828.0000172d@linux.intel.com> (raw)
In-Reply-To: <df1fc8d7-0a34-aef7-aeeb-db4f59755f78@huawei.com>

On Tue, 21 Mar 2023 16:56:37 +0800
Wu Guanghao <wuguanghao3@huawei.com> wrote:

> The latest kernel version will not report an error through mdadm
> set_disk_faulty.
> 
> $ lsblk
> sdb                                           8:16   0   10G  0 disk
> └─md0                                         9:0    0 19.9G  0 raid0
> sdc                                           8:32   0   10G  0 disk
> └─md0                                         9:0    0 19.9G  0 raid0
> 
> old kernel:
> ...
> $ mdadm /dev/md0 -f /dev/sdb
> mdadm: set device faulty failed for /dev/sdb:  Device or resource busy
> ...
> 
> latest kernel:
> ...
> $ mdadm /dev/md0 -f /dev/sdb
> mdadm: set /dev/sdb faulty in /dev/md0
> ...
> 
> The old kernel judges whether the Faulty flag is set in rdev->flags,
> and returns -EBUSY if not. And The latest kernel only return -EBUSY
> if the MD_BROKEN flag is set in mddev->flags. raid0 doesn't set error_handler,
> so MD_BROKEN will not be set, it will return 0.
> 
> So if error_handler isn't set for a raid type, also return -EBUSY.
Hi,
Please test with:
https://lore.kernel.org/linux-raid/20230306130317.3418-1-mariusz.tkaczyk@linux.intel.com/

Thanks,
Mariusz

> 
> Fixes: 9631abdbf406 ("md: Set MD_BROKEN for RAID1 and RAID10")
> Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
> ---
>  drivers/md/md.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 927a43db5dfb..b1786ff60d97 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -2928,10 +2928,10 @@ state_store(struct md_rdev *rdev, const char *buf,
> size_t len) int err = -EINVAL;
>         bool need_update_sb = false;
> 
> -       if (cmd_match(buf, "faulty") && rdev->mddev->pers) {
> -               md_error(rdev->mddev, rdev);
> +       if (cmd_match(buf, "faulty") && mddev->pers) {
> +               md_error(mddev, rdev);
> 
> -               if (test_bit(MD_BROKEN, &rdev->mddev->flags))
> +               if (!mddev->pers->error_handler || test_bit(MD_BROKEN,
> &mddev->flags)) err = -EBUSY;
>                 else
>                         err = 0;
> @@ -7421,7 +7421,7 @@ static int set_disk_faulty(struct mddev *mddev, dev_t
> dev) err =  -ENODEV;
>         else {
>                 md_error(mddev, rdev);
> -               if (test_bit(MD_BROKEN, &mddev->flags))
> +               if (!mddev->pers->error_handler || test_bit(MD_BROKEN,
> &mddev->flags)) err = -EBUSY;
>         }
>         rcu_read_unlock();
> --
> 2.27.0
> .


  reply	other threads:[~2023-03-21 10:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21  8:56 [PATCH] raid0: fix set_disk_faulty doesn't return -EBUSY Wu Guanghao
2023-03-21 10:18 ` Mariusz Tkaczyk [this message]
2023-03-22  2:24   ` Wu Guanghao
2023-03-22  7:05     ` Mariusz Tkaczyk
2023-03-22  8:38       ` Wu Guanghao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230321111828.0000172d@linux.intel.com \
    --to=mariusz.tkaczyk@linux.intel.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=liuzhiqiang26@huawei.com \
    --cc=louhongxiang@huawei.com \
    --cc=song@kernel.org \
    --cc=wuguanghao3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.