diff options
author | Guoqing Jiang <gqjiang@suse.com> | 2015-10-07 10:06:54 +0800 |
---|---|---|
committer | NeilBrown <neilb@suse.com> | 2015-10-08 11:08:40 +1100 |
commit | 9465f1705853ec47d95f31a332fb2e91f865cdaa (patch) | |
tree | 71ca86aefe0c4653662983c9803b04710dfeaf61 /Manage.c | |
parent | 8266a36ad61579f33b5a2b40e3c5ce35f77a4301 (diff) | |
download | mdadm-9465f1705853ec47d95f31a332fb2e91f865cdaa.tar.gz |
re-add: make re-add try to write sysfs node first
If sysfs node existed, we should try to write "re-add" to it.
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: NeilBrown <neilb@suse.com>
Diffstat (limited to 'Manage.c')
-rw-r--r-- | Manage.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -1309,6 +1309,7 @@ int Manage_subdevs(char *devname, int fd, int sysfd = -1; int count = 0; /* number of actions taken */ struct mdinfo info; + struct mdinfo devinfo; int frozen = 0; int busy = 0; int raid_slot = -1; @@ -1517,6 +1518,18 @@ int Manage_subdevs(char *devname, int fd, pr_err("Cannot add disks to a \'member\' array, perform this operation on the parent container\n"); goto abort; } + + /* Let's first try to write re-add to sysfs */ + if (rdev != 0 && + (dv->disposition == 'A' || dv->disposition == 'F')) { + sysfs_init_dev(&devinfo, rdev); + if (sysfs_set_str(&info, &devinfo, "state", "re-add") == 0) { + pr_err("re-add %s to %s succeed\n", + dv->devname, info.sys_name); + break; + } + } + if (dv->disposition == 'F') /* Need to remove first */ ioctl(fd, HOT_REMOVE_DISK, rdev); |