From: Sebastian Riemer <sebastian.riemer@profitbricks.com>
To: linux-raid <linux-raid@vger.kernel.org>
Subject: Re: [PATCH] md: also hot remove disk from pers when hot removing
Date: Fri, 16 Nov 2012 16:59:55 +0100 [thread overview]
Message-ID: <50A662FB.1040801@profitbricks.com> (raw)
In-Reply-To: <1353079062-6711-1-git-send-email-sebastian.riemer@profitbricks.com>
On 16.11.2012 16:17, Sebastian Riemer wrote:
> If hot adding a disk not as spare but at the same slot, the disk isn't added
> correctly in the pers and it is possible to cause a kernel panic/oops due to
> the invalid pointer to the old rdev in the pers. So hot remove the disk from
> the personality before removing it from the array.
>
> Tested with raid1.
>
> Signed-off-by: Sebastian Riemer <sebastian.riemer@profitbricks.com>
> ---
> drivers/md/md.c | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 9ab768a..1fc545b 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -5852,6 +5852,7 @@ static int hot_remove_disk(struct mddev * mddev, dev_t dev)
> {
> char b[BDEVNAME_SIZE];
> struct md_rdev *rdev;
> + int err;
>
> rdev = find_rdev(mddev, dev);
> if (!rdev)
> @@ -5860,6 +5861,13 @@ static int hot_remove_disk(struct mddev * mddev, dev_t dev)
> if (rdev->raid_disk >= 0)
> goto busy;
>
> + if (mddev->pers && mddev->pers->hot_remove_disk) {
> + err = mddev->pers->hot_remove_disk(mddev, rdev);
> + if (err)
> + return err;
> + sysfs_unlink_rdev(rdev->mddev, rdev);
In this line for parameter 1 just "mddev" is better.
> + rdev->raid_disk = -1;
Oops, this line is wrong and has to be removed. The slot number counts
up when re-adding. Because it is written to the superblock that this is
a spare.
> + }
> kick_rdev_from_array(rdev);
> md_update_sb(mddev, 1);
> md_new_event(mddev);
I'll resend the patch.
Btw.: How I noticed the issue: I've developed MD RAID-1 replication for
read-only CD-ROM images. Nothing may write to read-only exports.
Therefore, I don't need any spares and can add the devices directly
again to the same slots of the MD array.
Cheers,
Sebastian
prev parent reply other threads:[~2012-11-16 15:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-16 15:17 [PATCH] md: also hot remove disk from pers when hot removing Sebastian Riemer
2012-11-16 15:59 ` Sebastian Riemer [this message]
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=50A662FB.1040801@profitbricks.com \
--to=sebastian.riemer@profitbricks.com \
--cc=linux-raid@vger.kernel.org \
/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.