mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvmdevices: add --delnotfound to delete entries for missing devices
Used with update: lvmdevices --update --delnotfound. Removes all devices file entries for which no matching device is found.
This commit is contained in:
parent
e3cc3e55c8
commit
7cc414135a
@ -241,6 +241,16 @@ not grep "$PVID2" $DF
|
||||
setup_loop_devs
|
||||
rm $DF
|
||||
|
||||
# test delnotfound
|
||||
lvmdevices --addpvid "$PVID1"
|
||||
echo "IDTYPE=sys_wwid IDNAME=naa.123 DEVNAME=/dev/sdx1 PVID=aaa PART=1" >> $DF
|
||||
echo "IDTYPE=devname IDNAME=/dev/sdy DEVNAME=/dev/sdy PVID=bbb" >> $DF
|
||||
lvmdevices
|
||||
lvmdevices --update --delnotfound
|
||||
not grep PVID=aaa $DF
|
||||
not grep PVID=bbb $DF
|
||||
|
||||
|
||||
# TODO: add/rem of partitions of same device
|
||||
|
||||
losetup -D
|
||||
|
@ -52,6 +52,9 @@ arg(deldev_ARG, '\0', "deldev", string_VAL, 0, 0,
|
||||
"When used alone, --deldev specifies a device name.\n"
|
||||
"When used with --deviceidtype, --deldev specifies a device id.\n")
|
||||
|
||||
arg(delnotfound_ARG, '\0', "delnotfound", 0, 0, 0,
|
||||
"Remove devices file entries with no matching device.\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,
|
||||
|
@ -1445,6 +1445,7 @@ ID: lvmdevices_check
|
||||
DESC: Check the devices file and report incorrect values.
|
||||
|
||||
lvmdevices --update
|
||||
OO: --delnotfound
|
||||
ID: lvmdevices_update
|
||||
DESC: Update the devices file to fix incorrect values.
|
||||
|
||||
|
@ -293,6 +293,18 @@ int lvmdevices(struct cmd_context *cmd, int argc, char **argv)
|
||||
label_scan_invalidate(du->dev);
|
||||
}
|
||||
|
||||
if (arg_is_set(cmd, delnotfound_ARG)) {
|
||||
dm_list_iterate_items_safe(du, du2, &cmd->use_devices) {
|
||||
if (!du->dev) {
|
||||
log_print("Deleting IDTYPE=%s IDNAME=%s PVID=%s",
|
||||
idtype_to_str(du->idtype), du->idname ?: ".", du->pvid ?: ".");
|
||||
dm_list_del(&du->list);
|
||||
free_du(du);
|
||||
update_needed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (arg_is_set(cmd, update_ARG)) {
|
||||
if (update_needed || serial_update_needed || !dm_list_empty(&found_devs)) {
|
||||
if (!device_ids_write(cmd))
|
||||
|
Loading…
Reference in New Issue
Block a user