From: Czarnowska, Anna Sent: Monday, July 05, 2010 11:40 AM To: Neil Brown Cc: linux-raid@xxxxxxxxxxxxxxx; Czarnowska, Anna; Hawrylewicz Czarnowski, Przemyslaw; Labun, Marcin; Neubauer, Wojciech; Williams, Dan J; Ciechanowski, Ed; dledford@xxxxxxxxxx Subject: [PATCH 26/33] added --path <path_id> to give the information on the 'path-id' of removed device From: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@xxxxxxxxx> <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@xxxxxxxxx> --- Incremental.c | 8 +++++++- ReadMe.c | 2 ++ mdadm.c | 15 ++++++++++++--- mdadm.h | 6 +++++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Incremental.c b/Incremental.c index 4f52e3b..20e3445 100644 --- a/Incremental.c +++ b/Incremental.c @@ -941,13 +941,19 @@ int Incremental_container(struct supertype *st, char *devname, int verbose, * 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 *path, int verbose) { int mdfd; int rv; struct mdstat_ent *ent; struct mddev_dev_s devlist; + if (!path) { + fprintf(stderr, Name ": incremental removal without --path <path_id> lacks " + "the possibility to re-add new device in this port\n"); + return 1; + } + if (strchr(devname, '/')) { fprintf(stderr, Name ": incremental removal requires a " "kernel device name, not a file: %s\n", devname); diff --git a/ReadMe.c b/ReadMe.c index 5b59369..f1b11fb 100644 --- a/ReadMe.c +++ b/ReadMe.c @@ -191,6 +191,8 @@ struct option long_options[] = { /* For Incremental */ {"rebuild-map", 0, 0, 'r'}, {"grab", 0, 0, 'g'}, /* grab devices for hot spare use */ + {"path", 1, 0, IncrementalPath}, + {0, 0, 0, 0} }; diff --git a/mdadm.c b/mdadm.c index a111b47..60b4e3b 100644 --- a/mdadm.c +++ b/mdadm.c @@ -104,6 +104,7 @@ int main(int argc, char *argv[]) int dosyslog = 0; int rebuild_map = 0; int auto_update_home = 0; + char *remove_path = NULL; int print_help = 0; FILE *outf; @@ -913,6 +914,13 @@ int main(int argc, char *argv[]) case O(INCREMENTAL, 'g'): new_disk = 1; continue; + case O(INCREMENTAL, IncrementalPath): + if (!optarg) { + fprintf(stderr, Name ":option --path needs obligatory argument\n"); + exit(2); + } + remove_path = strdup(optarg); + continue; } /* We have now processed all the valid options. Anything else is * an error @@ -1559,9 +1567,10 @@ int main(int argc, char *argv[]) rv = 1; break; } - if (devmode == 'f') - rv = IncrementalRemove(devlist->devname, verbose-quiet); - else if (new_disk > 0) + if (devmode == 'f') { + rv = IncrementalRemove(devlist->devname, remove_path, verbose-quiet); + free(remove_path); + } else if (new_disk > 0) rv = IncrementalNew(devlist->devname, verbose-quiet, export); else diff --git a/mdadm.h b/mdadm.h index 86f5370..79eed16 100644 --- a/mdadm.h +++ b/mdadm.h @@ -275,6 +275,9 @@ enum special_options { AutoDetect, Waitclean, DetailPlatform, + HotPlug, + HotUnplug, + IncrementalPath }; enum disk_status { @@ -907,7 +910,7 @@ extern int Incremental_container(struct supertype *st, char *devname, int trustworthy); 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 IncrementalNew(char *devname, int verbose, int export); extern int CreateBitmap(char *filename, int force, char uuid[16], unsigned long chunksize, unsigned long daemon_sleep, @@ -1024,6 +1027,7 @@ extern char *devnum2devname(int num); extern int devname2devnum(char *name); extern int stat2devnum(struct stat *st); extern int fd2devnum(int fd); +extern void free_mddev_dev(mddev_dev_t devlist); extern char *get_devpath_from_devname(char *devname); extern char *get_array_devname(char *array); extern char *get_array_devname_by_uuid(int (*uuid)[4]); -- 1.6.4.2 -- To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html