summaryrefslogtreecommitdiff
path: root/Manage.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-01-25 07:56:53 +1100
committerNeilBrown <neilb@suse.de>2011-01-25 07:56:53 +1100
commit1cc7f4feb9a979fdf7ac4bb06e5632b065d4f4d9 (patch)
treeab73ac81e3c55388d07589401bdb6c3e6e2b33e7 /Manage.c
parent446d2a5ad48671be2e23676d9ea93af1b8dddf0b (diff)
Don't close fds in write_init_super
We previously closed all 'fds' associated with an array in write_init_super .. sometimes, and sometimes at bad times. This isn't neat and free_super is a better place to close them. So make sure free_super always closes the fds that the metadata manager kept hold of, and stop closing them in write_init_super. Also add a few more calls to free_super to make sure they really do get closed. Reported-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Manage.c')
-rw-r--r--Manage.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Manage.c b/Manage.c
index 4e6afb50..824caa98 100644
--- a/Manage.c
+++ b/Manage.c
@@ -728,6 +728,7 @@ int Manage_subdevs(char *devname, int fd,
skip_re_add:
re_add_failed = 1;
}
+ st->ss->free_super(st);
}
if (add_dev != dv->devname) {
if (verbose > 0)
@@ -808,9 +809,10 @@ int Manage_subdevs(char *devname, int fd,
close(dfd);
return 1;
}
- /* write_init_super will close 'dfd' */
- if (tst->ss->write_init_super(tst))
+ if (tst->ss->write_init_super(tst)) {
+ close(dfd);
return 1;
+ }
} else if (dv->re_add) {
/* this had better be raid1.
* As we are "--re-add"ing we must find a spare slot
@@ -872,6 +874,9 @@ int Manage_subdevs(char *devname, int fd,
new_mdi.disk.major = disc.major;
new_mdi.disk.minor = disc.minor;
new_mdi.recovery_start = 0;
+ /* Make sure fds are closed as they are O_EXCL which
+ * would block add_disk */
+ tst->ss->free_super(tst);
if (sysfs_add_disk(sra, &new_mdi, 0) != 0) {
fprintf(stderr, Name ": add new device to external metadata"
" failed for %s\n", dv->devname);
@@ -889,6 +894,7 @@ int Manage_subdevs(char *devname, int fd,
}
if (verbose >= 0)
fprintf(stderr, Name ": added %s\n", dv->devname);
+ tst->ss->free_super(tst);
break;
case 'r':