summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2009-05-12 09:49:45 +1000
committerNeilBrown <neilb@suse.de>2009-05-12 09:49:45 +1000
commitc7b474474c793e9a82bd0d84868fdf7367c89696 (patch)
treec622523a1beaccd8a5db9c1685ea9874b24b5d99
parent6957819fe61c0366565bfb2588982773ed010dfa (diff)
downloadmdadm-c7b474474c793e9a82bd0d84868fdf7367c89696.tar.gz
Monitor: support spare-group manipulation for 1.x metadata.
The code for moving spares around a spare-group currently only works for 0.90 metadata. Generalise it for 1.x metadata as well. Reported-by: "Garth Snyder" <garth@grsweb.us> Signed-off-by NeilBrown <neilb@suse.de>
-rw-r--r--Manage.c8
-rw-r--r--Monitor.c19
-rw-r--r--super0.c2
-rw-r--r--super1.c2
4 files changed, 22 insertions, 9 deletions
diff --git a/Manage.c b/Manage.c
index 33a0bc7..fa4bb60 100644
--- a/Manage.c
+++ b/Manage.c
@@ -292,11 +292,15 @@ int Manage_subdevs(char *devname, int fd,
} else {
j = 0;
- if (stat(dv->devname, &stb)) {
+ tfd = dev_open(dv->devname, O_RDONLY);
+ if (tfd < 0 || fstat(tfd, &stb) != 0) {
fprintf(stderr, Name ": cannot find %s: %s\n",
dv->devname, strerror(errno));
+ if (tfd >= 0)
+ close(tfd);
return 1;
}
+ close(tfd);
if ((stb.st_mode & S_IFMT) != S_IFBLK) {
fprintf(stderr, Name ": %s is not a "
"block device.\n",
@@ -313,7 +317,7 @@ int Manage_subdevs(char *devname, int fd,
/* add the device */
/* Make sure it isn't in use (in 2.6 or later) */
- tfd = open(dv->devname, O_RDONLY|O_EXCL);
+ tfd = dev_open(dv->devname, O_RDONLY|O_EXCL);
if (tfd < 0) {
fprintf(stderr, Name ": Cannot open %s: %s\n",
dv->devname, strerror(errno));
diff --git a/Monitor.c b/Monitor.c
index 3825600..e0a9d2a 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -470,16 +470,25 @@ int Monitor(mddev_dev_t devlist,
}
}
if (dev > 0) {
- if (ioctl(fd2, HOT_REMOVE_DISK,
- (unsigned long)dev) == 0) {
- if (ioctl(fd1, HOT_ADD_DISK,
- (unsigned long)dev) == 0) {
+ struct mddev_dev_s devlist;
+ char devname[20];
+ devlist.next = NULL;
+ devlist.used = 0;
+ devlist.re_add = 0;
+ devlist.writemostly = 0;
+ devlist.devname = devname;
+ sprintf(devname, "%d:%d", major(dev), minor(dev));
+
+ devlist.disposition = 'r';
+ if (Manage_subdevs(st2->devname, fd2, &devlist, -1) == 0) {
+ devlist.disposition = 'a';
+ if (Manage_subdevs(st->devname, fd1, &devlist, -1) == 0) {
alert("MoveSpare", st->devname, st2->devname, mailaddr, mailfrom, alert_cmd, dosyslog);
close(fd1);
close(fd2);
break;
}
- else ioctl(fd2, HOT_ADD_DISK, (unsigned long) dev);
+ else Manage_subdevs(st2->devname, fd2, &devlist, -1);
}
}
close(fd1);
diff --git a/super0.c b/super0.c
index 90fdf23..ebba534 100644
--- a/super0.c
+++ b/super0.c
@@ -672,7 +672,7 @@ static int write_init_super0(struct supertype *st,
mdu_disk_info_t *dinfo, char *devname)
{
mdp_super_t *sb = st->sb;
- int fd = open(devname, O_RDWR|O_EXCL);
+ int fd = dev_open(devname, O_RDWR|O_EXCL);
int rv;
if (fd < 0) {
diff --git a/super1.c b/super1.c
index e545bf5..376b97d 100644
--- a/super1.c
+++ b/super1.c
@@ -887,7 +887,7 @@ static int write_init_super1(struct supertype *st,
{
struct mdp_superblock_1 *sb = st->sb;
struct supertype refst;
- int fd = open(devname, O_RDWR | O_EXCL);
+ int fd = dev_open(devname, O_RDWR | O_EXCL);
int rfd;
int rv;
int bm_space;