From: Sebastian Riemer <sebastian.riemer@profitbricks.com>
To: linux-raid <linux-raid@vger.kernel.org>
Cc: Sebastian Riemer <sebastian.riemer@profitbricks.com>
Subject: [PATCH] md: also hot remove disk from pers when hot removing
Date: Fri, 16 Nov 2012 16:17:42 +0100 [thread overview]
Message-ID: <1353079062-6711-1-git-send-email-sebastian.riemer@profitbricks.com> (raw)
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);
+ rdev->raid_disk = -1;
+ }
kick_rdev_from_array(rdev);
md_update_sb(mddev, 1);
md_new_event(mddev);
--
1.7.1
next reply other threads:[~2012-11-16 15:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-16 15:17 Sebastian Riemer [this message]
2012-11-16 15:59 ` [PATCH] md: also hot remove disk from pers when hot removing Sebastian Riemer
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=1353079062-6711-1-git-send-email-sebastian.riemer@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox