"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Manage.c" between
mdadm-4.1.tar.gz and mdadm-4.2.tar.gz

About: mdadm is a tool for creating, managing and monitoring device arrays using the "md" driver in Linux, also known as Software RAID arrays.

Manage.c  (mdadm-4.1):Manage.c  (mdadm-4.2)
skipping to change at line 744 skipping to change at line 744
if (!force) { if (!force) {
pr_err("%s is larger than %s can effectively use.\n" pr_err("%s is larger than %s can effectively use.\n"
" Add --force is you really want to add this device.\n", " Add --force is you really want to add this device.\n",
dv->devname, devname); dv->devname, devname);
return -1; return -1;
} }
pr_err("%s is larger than %s can effectively use.\n" pr_err("%s is larger than %s can effectively use.\n"
" Adding anyway as --force was given.\n", " Adding anyway as --force was given.\n",
dv->devname, devname); dv->devname, devname);
} }
if (!tst->ss->external && array->major_version == 0) {
if (ioctl(fd, HOT_ADD_DISK, rdev)==0) {
if (verbose >= 0)
pr_err("hot added %s\n",
dv->devname);
return 1;
}
pr_err("hot add failed for %s: %s\n",
dv->devname, strerror(errno));
return -1;
}
if (array->not_persistent == 0 || tst->ss->external) { if (array->not_persistent == 0 || tst->ss->external) {
/* need to find a sample superblock to copy, and /* need to find a sample superblock to copy, and
* a spare slot to use. * a spare slot to use.
* For 'external' array (well, container based), * For 'external' array (well, container based),
* We can just load the metadata for the array-> * We can just load the metadata for the array->
*/ */
int array_failed; int array_failed;
if (tst->sb) if (tst->sb)
skipping to change at line 1007 skipping to change at line 995
strcpy(devnm, fd2devnm(fd)); strcpy(devnm, fd2devnm(fd));
container_fd = open_dev_excl(devnm); container_fd = open_dev_excl(devnm);
if (container_fd < 0) { if (container_fd < 0) {
pr_err("add failed for %s: could not get exclusive access to container\n", pr_err("add failed for %s: could not get exclusive access to container\n",
dv->devname); dv->devname);
tst->ss->free_super(tst); tst->ss->free_super(tst);
return -1; return -1;
} }
/* Check if metadata handler is able to accept the drive */
if (!tst->ss->validate_geometry(tst, LEVEL_CONTAINER, 0, 1, NULL,
0, 0, dv->devname, NULL, 0, 1)) {
close(container_fd);
return -1;
}
Kill(dv->devname, NULL, 0, -1, 0); Kill(dv->devname, NULL, 0, -1, 0);
dfd = dev_open(dv->devname, O_RDWR | O_EXCL|O_DIRECT); dfd = dev_open(dv->devname, O_RDWR | O_EXCL|O_DIRECT);
if (mdmon_running(tst->container_devnm))
tst->update_tail = &tst->updates;
if (tst->ss->add_to_super(tst, &disc, dfd, if (tst->ss->add_to_super(tst, &disc, dfd,
dv->devname, INVALID_SECTORS)) { dv->devname, INVALID_SECTORS)) {
close(dfd); close(dfd);
close(container_fd); close(container_fd);
return -1; return -1;
} }
if (tst->update_tail) if (!mdmon_running(tst->container_devnm))
flush_metadata_updates(tst);
else
tst->ss->sync_metadata(tst); tst->ss->sync_metadata(tst);
sra = sysfs_read(container_fd, NULL, 0); sra = sysfs_read(container_fd, NULL, 0);
if (!sra) { if (!sra) {
pr_err("add failed for %s: sysfs_read failed\n", pr_err("add failed for %s: sysfs_read failed\n",
dv->devname); dv->devname);
close(container_fd); close(container_fd);
tst->ss->free_super(tst); tst->ss->free_super(tst);
return -1; return -1;
} }
skipping to change at line 1304 skipping to change at line 1295
return -1; return -1;
} }
int Manage_subdevs(char *devname, int fd, int Manage_subdevs(char *devname, int fd,
struct mddev_dev *devlist, int verbose, int test, struct mddev_dev *devlist, int verbose, int test,
char *update, int force) char *update, int force)
{ {
/* Do something to each dev. /* Do something to each dev.
* devmode can be * devmode can be
* 'a' - add the device * 'a' - add the device
* try HOT_ADD_DISK
* If that fails EINVAL, try ADD_NEW_DISK
* 'S' - add the device as a spare - don't try re-add * 'S' - add the device as a spare - don't try re-add
* 'j' - add the device as a journal device * 'j' - add the device as a journal device
* 'A' - re-add the device * 'A' - re-add the device
* 'r' - remove the device: HOT_REMOVE_DISK * 'r' - remove the device: HOT_REMOVE_DISK
* device can be 'faulty' or 'detached' in which case all * device can be 'faulty' or 'detached' in which case all
* matching devices are removed. * matching devices are removed.
* 'f' - set the device faulty SET_DISK_FAULTY * 'f' - set the device faulty SET_DISK_FAULTY
* device can be 'detached' in which case any device that * device can be 'detached' in which case any device that
* is inaccessible will be marked faulty. * is inaccessible will be marked faulty.
* 'R' - mark this device as wanting replacement. * 'R' - mark this device as wanting replacement.
skipping to change at line 1745 skipping to change at line 1734
int move_spare(char *from_devname, char *to_devname, dev_t devid) int move_spare(char *from_devname, char *to_devname, dev_t devid)
{ {
struct mddev_dev devlist; struct mddev_dev devlist;
char devname[20]; char devname[20];
/* try to remove and add */ /* try to remove and add */
int fd1 = open(to_devname, O_RDONLY); int fd1 = open(to_devname, O_RDONLY);
int fd2 = open(from_devname, O_RDONLY); int fd2 = open(from_devname, O_RDONLY);
if (fd1 < 0 || fd2 < 0) { if (fd1 < 0 || fd2 < 0) {
if (fd1>=0) close(fd1); if (fd1 >= 0)
if (fd2>=0) close(fd2); close(fd1);
if (fd2 >= 0)
close(fd2);
return 0; return 0;
} }
devlist.next = NULL; devlist.next = NULL;
devlist.used = 0; devlist.used = 0;
devlist.writemostly = FlagDefault; devlist.writemostly = FlagDefault;
devlist.failfast = FlagDefault; devlist.failfast = FlagDefault;
devlist.devname = devname; devlist.devname = devname;
sprintf(devname, "%d:%d", major(devid), minor(devid)); sprintf(devname, "%d:%d", major(devid), minor(devid));
devlist.disposition = 'r'; devlist.disposition = 'r';
if (Manage_subdevs(from_devname, fd2, &devlist, -1, 0, NULL, 0) == 0) { if (Manage_subdevs(from_devname, fd2, &devlist, -1, 0, NULL, 0) == 0) {
devlist.disposition = 'a'; devlist.disposition = 'a';
if (Manage_subdevs(to_devname, fd1, &devlist, -1, 0, NULL, 0) == if (Manage_subdevs(to_devname, fd1, &devlist, -1, 0,
0) { NULL, 0) == 0) {
/* make sure manager is aware of changes */ /* make sure manager is aware of changes */
ping_manager(to_devname); ping_manager(to_devname);
ping_manager(from_devname); ping_manager(from_devname);
close(fd1); close(fd1);
close(fd2); close(fd2);
return 1; return 1;
} }
else Manage_subdevs(from_devname, fd2, &devlist, -1, 0, NULL, 0); else
Manage_subdevs(from_devname, fd2, &devlist,
-1, 0, NULL, 0);
} }
close(fd1); close(fd1);
close(fd2); close(fd2);
return 0; return 0;
} }
 End of changes. 8 change blocks. 
24 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)