Data alignment in block devices
CentOS 7
[root@]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core)
Problem:
mkfs.xfs warning: device is not properly aligned
[root@]# parted -a optimal /dev/mapper/mpathb mkpart primary 0% 100% [root@]# parted /dev/mapper/mpathb align-check opt 1 1 aligned parted /dev/mapper/mpathb p Model: Linux device-mapper (multipath) (dm) Disk /dev/mapper/mpathb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 33.6MB 21.5GB 21.4GB primary [root@]# mkfs.xfs /dev/mapper/mpathb1 warning: device is not properly aligned /dev/mapper/mpathb1 Use -f to force usage of a misaligned device
Why it happened?
[root@]# blkid -i /dev/mapper/mpathb
DEVNAME=/dev/mapper/mpathb
MINIMUM_IO_SIZE=8192
OPTIMAL_IO_SIZE=33553920
PHYSICAL_SECTOR_SIZE=512
LOGICAL_SECTOR_SIZE=512
Cause OPTIMAL_IO_SIZE is huge.
You can find which devices are touched by this problem:
[root@]# find /sys/devices/ -name optimal_io_size | xargs tail -n 1
You can test if that is the cause by mounting file with 0 zero value:
[root@]# echo 0 > /tmp/zero [root@]# mount --bind /tmp/zero /sys/devices/virtual/block/dm-2/queue/optimal_io_size
What is optimal_io_size? Storage vendors can also supply “I/O hints” about a device’s preferred
minimum unit for random I/O (‘minimum_io_size’) and streaming I/O
(‘optimal_io_size’). For example, these hints may correspond to a RAID
device’s chunk size and stripe size respectively. https://people.redhat.com
VPD (vital product data)
How to solve the problem globally for LVM? Disable data_alignment_detection in configuration.
[root@]# grep align /etc/lvm/lvm.conf | grep -v '^\s#'
md_chunk_alignment = 1
data_alignment_detection = 0
data_alignment = 0
data_alignment_offset_detection = 1
What is the root cause?
VPD and kernel
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=09b6b51b0b6c1b9bb61815baf205e4d74c89ff04
unsigned skip_vpd_pages:1; /* do not read VPD pages */
No comments yet.