mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
device_id: refresh devname idnames if any are not found
Search for a PV on other devices if it's a devname entry
and the name doesn't exist on the system. This restores
code that should not have been removed in commit 1901a47df
"device_id: fix conditions for device_ids_refresh"
This commit is contained in:
parent
25a87ea16a
commit
f20be398a1
@ -2721,6 +2721,31 @@ void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set invalid if an entry using IDNAME=devname has not
|
||||||
|
* been matched to a device. It's possible that the device
|
||||||
|
* with the PVID has a new name, different from the IDNAME
|
||||||
|
* value. device_ids_refresh needs to search system devs
|
||||||
|
* for the PVID. The same applies when the IDNAME field
|
||||||
|
* has no value.
|
||||||
|
*/
|
||||||
|
dm_list_iterate_items(du, &cmd->use_devices) {
|
||||||
|
if (cmd->device_ids_invalid)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!du->idname || (du->idname[0] == '.')) {
|
||||||
|
log_debug("Validate %s %s PVID %s: no idname is invalid.",
|
||||||
|
idtype_to_str(du->idtype), du->idname ?: ".", du->pvid ?: ".");
|
||||||
|
cmd->device_ids_invalid = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((du->idtype == DEV_ID_TYPE_DEVNAME) && !du->dev && du->pvid) {
|
||||||
|
log_debug("Validate %s %s PVID %s: no device for idtype devname is invalid.",
|
||||||
|
idtype_to_str(du->idtype), du->idname ?: ".", du->pvid ?: ".");
|
||||||
|
cmd->device_ids_invalid = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When a new devname/pvid mismatch is discovered, a new search for the
|
* When a new devname/pvid mismatch is discovered, a new search for the
|
||||||
* pvid should be permitted (searched_devnames may exist to suppress
|
* pvid should be permitted (searched_devnames may exist to suppress
|
||||||
|
@ -435,7 +435,69 @@ vgremove $vg
|
|||||||
rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
|
rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
|
||||||
cleanup_sysfs
|
cleanup_sysfs
|
||||||
|
|
||||||
|
#
|
||||||
|
# Simply rename a device using IDNAME=devname
|
||||||
|
# use a new device name where a device exists
|
||||||
|
# on the system with that name so that there
|
||||||
|
# will be an initial, incorrect match of the
|
||||||
|
# devices file entry with IDNAME=/dev/sdb to
|
||||||
|
# the /dev/sdb that exists on the system.
|
||||||
|
#
|
||||||
|
# FIXME: this assumes that /dev/sdb exists on the system
|
||||||
|
# and is not the same as DEV1. To do this correctly
|
||||||
|
# we need to find the name of some device on the
|
||||||
|
# system other than DEV1.
|
||||||
|
#
|
||||||
|
|
||||||
|
rm "$DF"
|
||||||
|
aux wipefs_a "$DEV1"
|
||||||
|
touch "$DF"
|
||||||
|
pvcreate "$DEV1"
|
||||||
|
vgcreate $vg1 "$DEV1"
|
||||||
|
cat "$DF"
|
||||||
|
grep "IDTYPE=devname" "$DF" | tee out
|
||||||
|
grep "IDNAME=$DEV1" out
|
||||||
|
mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
|
||||||
|
pvs -o+uuid,deviceidtype,deviceid "$DEV1"
|
||||||
|
# Rename device, simulating reboot
|
||||||
|
sed -e "s|IDNAME=$DEV1|IDNAME=/dev/sdb|" "$DF" > tmpdf
|
||||||
|
sed -e "s|DEVNAME=$DEV1|DEVNAME=/dev/sdb|" tmpdf > "$DF"
|
||||||
|
cat "$DF"
|
||||||
|
# pvs will find PV on DEV1 and fix IDNAME
|
||||||
|
pvs -o+uuid,deviceidtype,deviceid | tee out
|
||||||
|
grep "$DEV1" out
|
||||||
|
grep "IDTYPE=devname" "$DF" | tee out
|
||||||
|
grep "IDNAME=$DEV1" out
|
||||||
|
cleanup_sysfs
|
||||||
|
|
||||||
|
#
|
||||||
|
# Simply rename a device using IDNAME=devname
|
||||||
|
# use a new device name where a device does not
|
||||||
|
# exist on the system with that name
|
||||||
|
#
|
||||||
|
# This assumes that /dev/sdxx does not exist on the system.
|
||||||
|
#
|
||||||
|
|
||||||
|
rm "$DF"
|
||||||
|
aux wipefs_a "$DEV1"
|
||||||
|
touch "$DF"
|
||||||
|
pvcreate "$DEV1"
|
||||||
|
vgcreate $vg1 "$DEV1"
|
||||||
|
cat "$DF"
|
||||||
|
grep "IDTYPE=devname" "$DF" | tee out
|
||||||
|
grep "IDNAME=$DEV1" out
|
||||||
|
mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
|
||||||
|
pvs -o+uuid,deviceidtype,deviceid "$DEV1"
|
||||||
|
# Rename device, simulating reboot
|
||||||
|
sed -e "s|IDNAME=$DEV1|IDNAME=/dev/sdxx|" "$DF" > tmpdf
|
||||||
|
sed -e "s|DEVNAME=$DEV1|DEVNAME=/dev/sdxx|" tmpdf > "$DF"
|
||||||
|
cat "$DF"
|
||||||
|
# pvs will find PV on DEV1 and fix IDNAME
|
||||||
|
pvs -o+uuid,deviceidtype,deviceid | tee out
|
||||||
|
grep "$DEV1" out
|
||||||
|
grep "IDTYPE=devname" "$DF" | tee out
|
||||||
|
grep "IDNAME=$DEV1" out
|
||||||
|
cleanup_sysfs
|
||||||
|
|
||||||
|
|
||||||
# TODO: lvmdevices --adddev <dev> --deviceidtype <type> --deviceid <val>
|
# TODO: lvmdevices --adddev <dev> --deviceidtype <type> --deviceid <val>
|
||||||
|
Loading…
Reference in New Issue
Block a user