Bug 2213653

Summary: sys_wwid and sys_serial device ids with spaces
Product: Red Hat Enterprise Linux 9 Reporter: David Teigland <teigland>
Component: lvm2Assignee: David Teigland <teigland>
lvm2 sub component: Devices, Filtering and Stacking QA Contact: cluster-qe <cluster-qe>
Status: POST --- Docs Contact:
Severity: high    
Priority: high CC: agk, heinzm, jbrassow, msnitzer, prajnoha, zkabelac
Version: 9.2Keywords: Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Teigland 2023-06-08 21:15:08 UTC
Description of problem:

lvm should ignore leading and trailing spaces on sys_wwid and sys_serial device ids, and replace spaces in the middle with underscores.  For t10 wwids, multiple sequential spaces in the middle of the value are replaced with a single underscore.

Spaces have been handled inconsistently in past releases.  In some cases, lvm would be able to use a device with the spaces, and in others it wouldn't.

In RHEL 9.0 and 9.1, lvm replaced leading and trailing spaces in sys_wwid and sys_serial with underscores, and was able to use the device.  So, we want to recognize and handle any system.devices entries with leading/trailing underscores.  These versions also replaced every middle space with an underscore, so we also want to recognize those (this bit of handling was already added in 9.2.)

In RHEL 9.2, wwids with leading spaces are not usable, and wwids with trailing spaces are usable only for the t10 type.  wwids with spaces in the middle of the wwid are only usable for the t10 type.  sys_serial is handled like 9.0 and 9.1, by replacing all spaces with underscores.

In practice, only t10 wwids and serial numbers are expected to contain spaces (naa and eui wwid standards do not permit spaces.)


Examples (quotes show spaces, and are not in the values):

reported sysfs wwid:     "  t10.123  456  "
expected system.devices: "t10.123_456"

reported sysfs wwid:      "  naa.123  456  "
expected system.devices:  "naa.123__456"

reported sysfs serial:    "  123  456  "
expected system.devices   "123__456"

Possible system.devices values created by previous lvm versions that we want to handle:

"__t10.123__456__"
"__naa.123__456__"
"__123__456__"


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 David Teigland 2023-06-15 20:27:35 UTC
in main branch:
https://sourceware.org/git/?p=lvm2.git;a=commit;h=228a8e8c1fd8e82a2e31a6060614dc3dd2f8bc51


$ mkdir -p /test/sys/dev/block/8:128/device/
$ lvmconfig | grep device_id_sysfs_dir
        device_id_sysfs_dir="/test/sys/"


$ rm /etc/lvm/devices/system.devices
$ echo "  t10.123  456  " > /test/sys/dev/block/8:128/device/wwid
$ lvmdevices --adddev /dev/sdi
$ grep IDNAME /etc/lvm/devices/system.devices 
IDTYPE=sys_wwid IDNAME=t10.123_456 DEVNAME=/dev/sdi PVID=oBlXttXs30XwwvtWxcfWfh33YD944taH
$ pvs /dev/sdi
  PV         VG Fmt  Attr PSize PFree
  /dev/sdi      lvm2 ---  8.00m 8.00m


$ rm /etc/lvm/devices/system.devices
$ echo "  naa.123  456  " > /test/sys/dev/block/8:128/device/wwid
$ lvmdevices --adddev /dev/sdi
$ grep IDNAME /etc/lvm/devices/system.devices 
IDTYPE=sys_wwid IDNAME=naa.123__456 DEVNAME=/dev/sdi PVID=oBlXttXs30XwwvtWxcfWfh33YD944taH
$ pvs /dev/sdi
  PV         VG Fmt  Attr PSize PFree
  /dev/sdi      lvm2 ---  8.00m 8.00m


$ rm /etc/lvm/devices/system.devices
$ rm /test/sys/dev/block/8:128/device/wwid
$ echo "  123  456  " > /test/sys/dev/block/8:128/device/serial
$ lvmdevices --adddev /dev/sdi
$ grep IDNAME /etc/lvm/devices/system.devices 
IDTYPE=sys_serial IDNAME=123__456 DEVNAME=/dev/sdi PVID=oBlXttXs30XwwvtWxcfWfh33YD944taH
$ pvs /dev/sdi
  PV         VG Fmt  Attr PSize PFree
  /dev/sdi      lvm2 ---  8.00m 8.00m

Comment 2 David Teigland 2023-06-16 14:37:01 UTC
Same device ids tested above, edited system.devices to add underscores that would have been added by previous lvm versions.


$ echo "  t10.123  456  " > /test/sys/dev/block/8:128/device/wwid
$ grep IDNAME /etc/lvm/devices/system.devices 
IDTYPE=sys_wwid IDNAME=__t10.123__456__ DEVNAME=/dev/sdi PVID=oBlXttXs30XwwvtWxcfWfh33YD944taH
$ pvs /dev/sdi
  PV         VG Fmt  Attr PSize PFree
  /dev/sdi      lvm2 ---  8.00m 8.00m


$ echo "  naa.123  456  " > /test/sys/dev/block/8:128/device/wwid
$ grep IDNAME /etc/lvm/devices/system.devices 
IDTYPE=sys_wwid IDNAME=__naa.123__456__ DEVNAME=/dev/sdi PVID=oBlXttXs30XwwvtWxcfWfh33YD944taH
$ pvs /dev/sdi
  PV         VG Fmt  Attr PSize PFree
  /dev/sdi      lvm2 ---  8.00m 8.00m


$ echo "  123  456  " > /test/sys/dev/block/8:128/device/serial
$ grep IDNAME /etc/lvm/devices/system.devices 
IDTYPE=sys_serial IDNAME=__123__456__ DEVNAME=/dev/sdi PVID=oBlXttXs30XwwvtWxcfWfh33YD944taH
$ pvs /dev/sdi
  PV         VG Fmt  Attr PSize PFree
  /dev/sdi      lvm2 ---  8.00m 8.00m