diff options
author | Dan Williams <dan.j.williams@intel.com> | 2008-09-16 05:58:43 +0200 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2008-09-16 05:58:43 +0200 |
commit | 313a4a82f130e6668ba0f4550200662e168aa945 (patch) | |
tree | 56f6b17ba26b00684153bbbc976dd1c1f825b122 /Manage.c | |
parent | sysfs: detect disks that are in the process of being removed (diff) | |
download | mdadm-313a4a82f130e6668ba0f4550200662e168aa945.tar.xz mdadm-313a4a82f130e6668ba0f4550200662e168aa945.zip |
ping_manager() to prevent 'add' before 'remove' completes
It is currently possible to remove a device and re-add it without the
manager noticing, i.e. without detecting a mdstat->devcnt
container->devcnt mismatch. Introduce ping_manager() to arrange for
mdmon to run manage_container() prior to mdadm dropping the exclusive
open() on the container. Despite these precautions sysfs_read() may
still fail. If this happens invalidate container->devcnt to ensure
manage_container() runs at the next event.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'Manage.c')
-rw-r--r-- | Manage.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -712,6 +712,23 @@ int Manage_subdevs(char *devname, int fd, close(lfd); return 1; } + if (tst->ss->external) { + /* + * Before dropping our exclusive open we make an + * attempt at preventing mdmon from seeing an + * 'add' event before reconciling this 'remove' + * event. + */ + char *name = devnum2devname(fd2devnum(fd)); + + if (!name) { + fprintf(stderr, Name ": unable to get container name\n"); + return 1; + } + + ping_manager(name); + free(name); + } close(lfd); if (verbose >= 0) fprintf(stderr, Name ": hot removed %s\n", |