diff options
author | NeilBrown <neilb@suse.de> | 2009-05-12 09:49:45 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-05-12 09:49:45 +1000 |
commit | c7b474474c793e9a82bd0d84868fdf7367c89696 (patch) | |
tree | c622523a1beaccd8a5db9c1685ea9874b24b5d99 | |
parent | 6957819fe61c0366565bfb2588982773ed010dfa (diff) | |
download | mdadm-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.c | 8 | ||||
-rw-r--r-- | Monitor.c | 19 | ||||
-rw-r--r-- | super0.c | 2 | ||||
-rw-r--r-- | super1.c | 2 |
4 files changed, 22 insertions, 9 deletions
@@ -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)); @@ -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); @@ -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) { @@ -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; |