Bug 1685787

Summary: PV misalignment on UAS due to optimal_io_size not a multiple of physical_sector_size
Product: [Community] LVM and device-mapper Reporter: Kevin Locke <kevin>
Component: lvm2Assignee: LVM Team <lvm-team>
lvm2 sub component: Changing Logical Volumes QA Contact: cluster-qe <cluster-qe>
Status: NEW --- Docs Contact:
Severity: unspecified    
Priority: unspecified CC: agk, devurandom, heinzm, jbrassow, msnitzer, prajnoha, zkabelac
Version: unspecifiedFlags: pm-rhel: lvm-technical-solution?
pm-rhel: lvm-test-coverage?
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
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:
Attachments:
Description Flags
Patch to only use optimal_io_size matching physical_sector_size none

Description Kevin Locke 2019-03-06 04:26:44 UTC
Created attachment 1541220 [details]
Patch to only use optimal_io_size matching physical_sector_size

Description of problem:

Some devices (USB Attached SCSI in particular) report an optimal_io_size which is not a multiple of physical_sector_size.[^1][^2][^3][^4]  This causes pvcreate to create physical volumes which are mis-aligned to physical sectors, degrading performance.[^5][^6]

Version-Release number of selected component (if applicable): 2.03.02 and current git master (a0c848d4e)

How reproducible:  Always

Steps to Reproduce:
1. pvcreate -v /dev/sdb
2. pvs -o pe_start --units b /dev/sdb

Actual results:

  1st PE   
  33553920B

Expected results:

  1st PE   
  1048576B

Additional info:

The kernel maintainers have stated that sanity checking this value is the responsibility of user-space.[^7]  util-linux only uses the value if it is a multiple of physical_sector_size.[^8]  cryptsetup only uses the value if it is a multiple of minimum_io_size.[^9]  parted is currently discussing the issue.[^10]

I have attached a patch which adopts the util-linux strategy and does not constrain alignment based on optimal_io_size when it is not a multiple of physical_sector_size.

The testing was a bit complicated and required use of the scsi_debug device directly.  I'd appreciate a sanity check before it is applied.

Thanks for considering,
Kevin

[^1]: https://www.saout.de/pipermail/dm-crypt/2016-January/004934.html
[^2]: https://www.spinics.net/lists/linux-usb/msg125988.html
[^3]: https://www.spinics.net/lists/util-linux-ng/msg11693.html
[^4]: https://linux-blog.anracom.com/2018/12/03/linux-ssd-partition-alignment-problems-with-external-usb-to-sata-controllers-i/
[^5]: https://www.redhat.com/archives/linux-lvm/2018-June/msg00049.html
[^6]: https://unix.stackexchange.com/a/496607
[^7]: https://www.spinics.net/lists/util-linux-ng/msg11702.html
[^8]: https://github.com/karelzak/util-linux/commit/acb7651f8
[^9]: https://gitlab.com/cryptsetup/cryptsetup/commit/b80278c0
[^10]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923561