--- Incremental.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- mdadm-3.2.6.orig/Incremental.c +++ mdadm-3.2.6/Incremental.c @@ -279,6 +279,21 @@ int Incremental(char *devname, int verbo if (map_lock(&map)) fprintf(stderr, Name ": failed to get exclusive lock on " "mapfile\n"); + + /* Now that we have the lock, we should recheck exclusive access, + * and remove partitions. + */ + dfd = dev_open(devname, O_RDONLY|O_EXCL); + if (dfd < 0) { + if (verbose >= 0) + fprintf(stderr, Name ": cannot reopen %s: %s.\n", + devname, strerror(errno)); + goto out_unlock; + } + remove_partitions(dfd); + close(dfd); + dfd = -1; + mp = map_by_uuid(&map, info.uuid); if (mp) mdfd = open_dev(mp->devnum);