]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
added --path <path_id> to give the information on the 'path-id' of removed device
authorPrzemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)
<path-id> allows to identify the port to which given device is plugged
in.  In case of hot-removal, udev can pass this information for future
use (eg. write this name as 'cookie' allowing to detect the fact of
reinserting device to the same port).

--path <path-id> parameter has been added to device removal handle
(and char *path has been added to IncrementalRemove() to pass this
value) in order to pass path-id to this handler.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Incremental.c
ReadMe.c
mdadm.c
mdadm.h
udev-md-raid.rules

index b7bf0b4f417d60c8736ab6a0ed10e2e7fb2a3309..a2235530fa6682449a8a742afb1f3280fe1c5138 100644 (file)
@@ -1351,17 +1351,23 @@ static int Incremental_container(struct supertype *st, char *devname,
  * raid arrays, and if so first fail (if needed) and then remove the device.
  *
  * @devname - The device we want to remove
+ * @id_path - name as found in /dev/disk/by-path for this device
  *
  * Note: the device name must be a kernel name like "sda", so
  * that we can find it in /proc/mdstat
  */
-int IncrementalRemove(char *devname, int verbose)
+int IncrementalRemove(char *devname, char *id_path, int verbose)
 {
        int mdfd;
        int rv;
        struct mdstat_ent *ent;
        struct mddev_dev devlist;
 
+       if (!id_path)
+               dprintf(Name ": incremental removal without --path <id_path> "
+                       "lacks the possibility to re-add new device in this "
+                       "port\n");
+
        if (strchr(devname, '/')) {
                fprintf(stderr, Name ": incremental removal requires a "
                        "kernel device name, not a file: %s\n", devname);
index b97c55e76c62ea9be2ac852033dc1ed1cf5f3cc9..07abdb7d11ecd2693165116456c8b4c423a9e5db 100644 (file)
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -191,6 +191,8 @@ struct option long_options[] = {
 
     /* For Incremental */
     {"rebuild-map", 0, 0, 'r'},
+    {"path", 1, 0, IncrementalPath},
+
     {0, 0, 0, 0}
 };
 
diff --git a/mdadm.c b/mdadm.c
index 4a8547486c36fa35108ec5d2ae004683eb4f3c25..0eef6bc80738a6d0e3cd7447cf41b9de00171c2c 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -104,6 +104,7 @@ int main(int argc, char *argv[])
        int rebuild_map = 0;
        int auto_update_home = 0;
        char *subarray = NULL;
+       char *remove_path = NULL;
 
        int print_help = 0;
        FILE *outf;
@@ -943,6 +944,9 @@ int main(int argc, char *argv[])
                case O(INCREMENTAL, 'r'):
                        rebuild_map = 1;
                        continue;
+               case O(INCREMENTAL, IncrementalPath):
+                       remove_path = optarg;
+                       continue;
                }
                /* We have now processed all the valid options. Anything else is
                 * an error
@@ -1586,12 +1590,13 @@ int main(int argc, char *argv[])
                        rv = 1;
                        break;
                }
-               if (devmode == 'f') {
-                       rv = IncrementalRemove(devlist->devname, verbose-quiet);
-                       break;
-               }
-               rv = Incremental(devlist->devname, verbose-quiet, runstop,
-                                ss, homehost, require_homehost, autof);
+               if (devmode == 'f')
+                       rv = IncrementalRemove(devlist->devname, remove_path,
+                                              verbose-quiet);
+               else
+                       rv = Incremental(devlist->devname, verbose-quiet,
+                                        runstop, ss, homehost,
+                                        require_homehost, autof);
                break;
        case AUTODETECT:
                autodetect();
diff --git a/mdadm.h b/mdadm.h
index 9d5e1c0c28ff611bf647d43a36b2aebd9145ac05..c6fdebedf4d7dc512328db4625faae95064fbe98 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -280,6 +280,7 @@ enum special_options {
        DetailPlatform,
        KillSubarray,
        UpdateSubarray, /* 16 */
+       IncrementalPath
 };
 
 /* structures read from config file */
@@ -928,7 +929,7 @@ extern int Incremental(char *devname, int verbose, int runstop,
                       int autof);
 extern void RebuildMap(void);
 extern int IncrementalScan(int verbose);
-extern int IncrementalRemove(char *devname, int verbose);
+extern int IncrementalRemove(char *devname, char *path, int verbose);
 extern int CreateBitmap(char *filename, int force, char uuid[16],
                        unsigned long chunksize, unsigned long daemon_sleep,
                        unsigned long write_behind,
index f9607f37cd68e370fcd17702993dca8428f348cd..a4a57ac8353283b7d1311258eda1c1726984e87b 100644 (file)
@@ -3,7 +3,7 @@
 SUBSYSTEM!="block", GOTO="md_end"
 
 # handle potential components of arrays
-ENV{ID_FS_TYPE}=="linux_raid_member", ACTION=="remove", RUN+="/sbin/mdadm -If $name"
+ENV{ID_FS_TYPE}=="linux_raid_member", ACTION=="remove", RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}"
 ENV{ID_FS_TYPE}=="linux_raid_member", ACTION=="add", RUN+="/sbin/mdadm --incremental $env{DEVNAME}"
 
 # handle md arrays