added --path <path_id> to give the information on the 'path-id' of removed device

<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>
This commit is contained in:
Przemyslaw Czarnowski 2010-11-22 20:58:06 +11:00 committed by NeilBrown
parent 157e6e24b9
commit 950bc34477
5 changed files with 23 additions and 9 deletions

View 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);

View File

@ -191,6 +191,8 @@ struct option long_options[] = {
/* For Incremental */
{"rebuild-map", 0, 0, 'r'},
{"path", 1, 0, IncrementalPath},
{0, 0, 0, 0}
};

17
mdadm.c
View File

@ -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();

View File

@ -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,

View 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