- Manage_subdevs(ent->dev, mdfd, &devlist, verbose, 0, NULL, 0);
- devlist.disposition = 'r';
- rv = Manage_subdevs(ent->dev, mdfd, &devlist, verbose, 0, NULL, 0);
+ rv |= Manage_subdevs(ent->devnm, mdfd, &devlist,
+ verbose, 0, NULL, 0);
+ if (rv & 2) {
+ /* Failed due to EBUSY, try to stop the array.
+ * Give udisks a chance to unmount it first.
+ */
+ int devid = devnm2devid(ent->devnm);
+ run_udisks("--unmount", map_dev(major(devid),minor(devid), 0));
+ rv = Manage_stop(ent->devnm, mdfd, verbose, 1);
+ if (rv)
+ /* At least we can try to trigger a 'remove' */
+ sysfs_uevent(&mdi, "remove");
+ if (verbose) {
+ if (rv)
+ pr_err("Fail to stop %s too.\n", ent->devnm);
+ }
+ } else {
+ devlist.disposition = 'r';
+ rv = Manage_subdevs(ent->devnm, mdfd, &devlist,
+ verbose, 0, NULL, 0);
+ }