Skip to contentSkip to conversation

main - device id: add new types using values from vpd_pg83

PATCH David Teigland 1 participant 1 message Oct 10, 2022

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=79e67fc5e4f28d19fe4d93e6831a3a60e9760b68
Commit:        79e67fc5e4f28d19fe4d93e6831a3a60e9760b68
Parent:        8de87e0207342b0142778ebe9c51f0d552adfab8
Author:        David Teigland <[email protected]>
AuthorDate:    Wed Aug 31 16:05:07 2022 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Mon Oct 10 11:47:29 2022 -0500

device id: add new types using values from vpd_pg83

The new device_id types are: wwid_naa, wwid_eui, wwid_t10. The new types use the specific wwid type in their name. lvm currently gets the values for these types by reading the device's vpd_pg83 sysfs file (this could change in the future if better methods become available for reading the values.)

If a device is added to the devices file using one of these types, prior versions of lvm will not recognize the types and will be unable to use the devices.

When adding a new device, lvm continues to first use sys_wwid from the sysfs wwid file. If the device has no sysfs wwid file, lvm now attempts to use one of the new types from vpd_pg83.

If a devices file entry with type sys_wwid does not match a given device's sysfs wwid file, the sys_wwid value will also be compared to that device's other wwids from its vpd_pg83 file. If the kernel changes the wwid type reported from the sysfs wwid file, e.g. from a device's t10 id to its naa id, then lvm should still be able to match it correctly using the vpd_pg83 data which will include both ids.

---
 lib/config/config_settings.h |   3 ++
 lib/config/defaults.h        |   2 +
 lib/device/device.h          |   4 ++
 lib/device/device_id.c       | 103 ++++++++++++++++++++++++++++++++++++++++++-
 lib/device/device_id.h       |   2 +
 5 files changed, 112 insertions(+), 2 deletions(-)
lib/config/config_settings.h +3 -0
index b172c7c5f..699b40bd0 100644
@@ -224,6 +224,9 @@ cfg(devices_dir_CFG, "dir", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_ADV
 	"Directory in which to create volume group device nodes.\n"
 	"Commands also accept this as a prefix on volume group names.\n")
 
+cfg(devices_device_id_sysfs_dir_CFG, "device_id_sysfs_dir", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_UNSUPPORTED, CFG_TYPE_STRING, DEFAULT_DEVICE_ID_SYSFS_DIR, vsn(2, 3, 17), NULL, 0, NULL,
+	"Location of sysfs for finding device ids (for testing.)\n")
+
 cfg_array(devices_scan_CFG, "scan", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_ADVANCED, CFG_TYPE_STRING, "#S/dev", vsn(1, 0, 0), NULL, 0, NULL,
 	"Directories containing device nodes to use with LVM.\n")
 
lib/config/defaults.h +2 -0
index 3308b1ea6..571054dc4 100644
@@ -332,4 +332,6 @@
 #define VGS_ONLINE_DIR DEFAULT_RUN_DIR "/vgs_online"
 #define PVS_LOOKUP_DIR DEFAULT_RUN_DIR "/pvs_lookup"
 
+#define DEFAULT_DEVICE_ID_SYSFS_DIR "/sys/"  /* trailing / to match dm_sysfs_dir() */
+
 #endif				/* _LVM_DEFAULTS_H */
lib/device/device.h +4 -0
index 89173a840..ca46490ce 100644
@@ -67,7 +67,11 @@ struct dev_ext {
 #define DEV_ID_TYPE_CRYPT_UUID 6
 #define DEV_ID_TYPE_LVMLV_UUID 7
 #define DEV_ID_TYPE_DEVNAME    8
+#define DEV_ID_TYPE_WWID_NAA   9
+#define DEV_ID_TYPE_WWID_EUI  10
+#define DEV_ID_TYPE_WWID_T10  11
 
+/* Max length of WWID_NAA, WWID_EUI, WWID_T10 */
 #define DEV_WWID_SIZE 128
 
 /*
lib/device/device_id.c +101 -2

163 lines not on this page · raw message

lib/device/device_id.h +2 -0
index 46ab33784..6962925df 100644
@@ -63,6 +63,8 @@ int read_sys_block_binary(struct cmd_context *cmd, struct device *dev,
 
 int dev_has_mpath_uuid(struct cmd_context *cmd, struct device *dev, const char **idname_out);
 
+int wwid_type_to_idtype(int wwid_type);
+int idtype_to_wwid_type(int idtype);
 void free_wwids(struct dm_list *ids);
 struct dev_wwid *dev_add_wwid(char *id, int id_type, struct dm_list *ids);
 int dev_read_vpd_wwids(struct cmd_context *cmd, struct device *dev);