main - lvmdevices: --deldev using device id
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=fb7698b0ce47b965db056022cad712a965554f3a Commit: fb7698b0ce47b965db056022cad712a965554f3a Parent: 151ce8b27672134438d0bc457f49123db96a176c Author: David Teigland <[email protected]> AuthorDate: Wed Apr 6 12:29:26 2022 -0500 Committer: David Teigland <[email protected]> CommitterDate: Wed Apr 6 12:51:34 2022 -0500
lvmdevices: --deldev using device id
When used with --deviceidtype, --deldev can specify a device id to remove.
--- lib/device/device_id.c | 6 +++--- lib/device/device_id.h | 1 + man/lvmdevices.8_des | 1 + test/shell/devicesfile-edit.sh | 21 +++++++++++++++++++ tools/args.h | 8 +++++-- tools/command-lines.in | 3 ++- tools/lvmdevices.c | 47 +++++++++++++++++++++++++++++++++++++++++- 7 files changed, 80 insertions(+), 7 deletions(-)
lib/device/device_id.c +3 -3
@@ -935,7 +935,7 @@ struct dev_use *get_du_for_devname(struct cmd_context *cmd, const char *devname)return NULL ; } -static struct dev_use *_get_du_for_device_id (struct cmd_context *cmd,uint16_t idtype,const char *idname) +struct dev_use *get_du_for_device_id (struct cmd_context *cmd,uint16_t idtype,const char *idname) {struct dev_use *du;
@@ -1128,7 +1128,7 @@ id_done: du_devname =get_du_for_devname (cmd,dev_name (dev));/* Is there already an entry using the device_id for this device? */ - du_devid =_get_du_for_device_id (cmd, id->idtype, id->idname); + du_devid =get_du_for_device_id (cmd, id->idtype, id->idname);if (du_dev) log_debug("device_id_add %s pvid %s matches entry %p dev %s",
@@ -1322,7 +1322,7 @@ void device_id_update_vg_uuid(struct cmd_context *cmd, struct volume_group *vg,memcpy (old_idname+4 , old_vgid,ID_LEN );memcpy (old_idname+4 +ID_LEN , &lvl->lv->lvid.id[1 ],ID_LEN ); -if ((du =_get_du_for_device_id (cmd,DEV_ID_TYPE_LVMLV_UUID , old_idname))) { +if ((du =get_du_for_device_id (cmd,DEV_ID_TYPE_LVMLV_UUID , old_idname))) {log_debug ("device_id update %s pvid %s vgid %s to %s" , du->devname ?:"." , du->pvid ?:"." , old_vgid, new_vgid);memcpy (du->idname+4 , new_vgid,ID_LEN );
lib/device/device_id.h +1 -0
@@ -43,6 +43,7 @@ struct dev_use *get_du_for_devno(struct cmd_context *cmd, dev_t devno);struct dev_use *get_du_for_dev (struct cmd_context *cmd,struct device *dev);struct dev_use *get_du_for_pvid (struct cmd_context *cmd,const char *pvid);struct dev_use *get_du_for_devname (struct cmd_context *cmd,const char *devname); +struct dev_use *get_du_for_device_id (struct cmd_context *cmd,uint16_t idtype,const char *idname);char *devices_file_version (void );int devices_file_exists (struct cmd_context *cmd);
man/lvmdevices.8_des +1 -0
@@ -85,6 +85,7 @@ is used for dm crypt devices, reported by sysfs. .IP \[bu] 2 .B md_uuid is used for md devices, reported by sysfs. +.IP \[bu] 2 .B lvmlv_uuid is used if a PV is placed on top of an lvm LV, reported by sysfs. .IP \[bu] 2
test/shell/devicesfile-edit.sh +21 -0
@@ -135,6 +135,24 @@ lvmdevices --deldev "$LOOP1" not grep "$LOOP1" $DF lvmdevices --deldev "$LOOP2" not grep "$LOOP2" $DF +rm $DF + +# deldev using idname +lvmdevices --adddev "$LOOP1" +lvmdevices --adddev "$LOOP2" +vgcreate $vg "$LOOP1" "$LOOP2" +IDNAME1=`pvs "$LOOP1" --noheading -o deviceid | tr -d - | awk '{print $1}'` +IDNAME2=`pvs "$LOOP2" --noheading -o deviceid | tr -d - | awk '{print $1}'` +lvmdevices --deldev "$IDNAME2" --deviceidtype loop_file +not grep "$IDNAME2" $DF +not grep "$LOOP2" $DF +lvmdevices --deldev "$IDNAME1" --deviceidtype loop_file +not grep "$IDNAME1" $DF +not grep "$LOOP1" $DF +lvmdevices --adddev "$LOOP1" +lvmdevices --adddev "$LOOP2" +vgremove $vg +rm $DF # add/delpvid with default idtype loop_file lvmdevices --addpvid "$PVID1"
@@ -151,6 +169,7 @@ not grep "$PVID1" $DF lvmdevices --delpvid "$PVID2" not grep "$LOOP2" $DF not grep "$PVID2" $DF +rm $DF # add/deldev with non-default idtype devname lvmdevices --adddev "$LOOP1" --deviceidtype devname
@@ -165,6 +184,7 @@ lvmdevices --deldev "$LOOP1" not grep "$LOOP1" $DF lvmdevices --deldev "$LOOP2" not grep "$LOOP2" $DF +rm $DF # add/delpvid with non-default idtype devname lvmdevices --addpvid "$PVID1" --deviceidtype devname
@@ -179,6 +199,7 @@ lvmdevices --deldev "$LOOP1" not grep "$LOOP1" $DF lvmdevices --deldev "$LOOP2" not grep "$LOOP2" $DF +rm $DF # add/deldev when dev is missing, using default idtype lvmdevices --adddev "$LOOP1"
tools/args.h +6 -2
@@ -46,8 +46,12 @@ arg(addtag_ARG, '\0', "addtag", tag_VAL, ARG_GROUPABLE, 0,arg (adddev_ARG,'\0' ,"adddev" , pv_VAL,0 ,0 , "Add a device to the devices file.\n") -arg (deldev_ARG,'\0' ,"deldev" , pv_VAL,0 ,0 , - "Remove a device from the devices file.\n") + +arg (deldev_ARG,'\0' ,"deldev" , string_VAL,0 ,0 , +"Remove a device from the devices file.\n" +"When used alone, --deldev specifies a device name.\n" + "When used with --deviceidtype, --deldev specifies a device id.\n") +arg (addpvid_ARG,'\0' ,"addpvid" , string_VAL,0 ,0 , "Find a device with the PVID and add the device to the devices file.\n") arg(delpvid_ARG, '\0', "delpvid", string_VAL, 0, 0,
tools/command-lines.in +2 -1
@@ -1434,7 +1434,8 @@ OO: --deviceidtype String ID: lvmdevices_edit DESC: Add a device to the devices file. -lvmdevices --deldev PV +lvmdevices --deldev PV|String +OO: --deviceidtype String ID: lvmdevices_edit DESC: Remove a device from the devices file.
tools/lvmdevices.c +46 -1
64 lines not on this page · raw message