System information
All layers of the Linux I/O stack have been engineered to propagate the various I/O parameters up the
stack. When a layer consumes an attribute or aggregates many devices, the layer must expose
appropriate I/O parameters so that upper-layer devices or tools will have an accurate view of the
storage as it transformed. Some practical examples are:
Only one layer in the I/O stack should adjust for a non-zero al i g nment_o ffset; once a layer
adjusts accordingly, it will export a device with an al i g nment_o ffset of zero.
A striped Device Mapper (DM) device created with LVM must export a mi ni mum_i o _si ze and
o pti mal _i o _si ze relative to the stripe count (number of disks) and user-provided chunk size.
In Red Hat Enterprise Linux 6, Device Mapper and Software Raid (MD) device drivers can be used to
arbitrarily combine devices with different I/O parameters. The kernel's block layer will attempt to
reasonably combine the I/O parameters of the individual devices. The kernel will not prevent
combining heterogeneous devices; however, be aware of the risks associated with doing so.
For instance, a 512-byte device and a 4K device may be combined into a single logical DM device,
which would have a l og i cal _bl o ck_si ze of 4K. File systems layered on such a hybrid device
assume that 4K will be written atomically, but in reality it will span 8 logical block addresses when
issued to the 512-byte device. Using a 4K l og i cal _bl o ck_si ze for the higher-level DM device
increases potential for a partial write to the 512-byte device if there is a system crash.
If combining the I/O parameters of multiple devices results in a conflict, the block layer may issue a
warning that the device is susceptible to partial writes and/or is misaligned.
23.5. Logical Volume Manager
LVM provides userspace tools that are used to manage the kernel's DM devices. LVM will shift the
start of the data area (that a given DM device will use) to account for a non-zero
al i g nment_o ffset associated with any device managed by LVM. This means logical volumes will
be properly aligned (al i g nment_o ffset= 0 ).
By default, LVM will adjust for any al i g nment_o ffset, but this behavior can be disabled by setting
d ata_al ig nment_o ffset_d etecti o n to 0 in /etc/l vm/l vm. co nf. Disabling this is not
recommended.
LVM will also detect the I/O hints for a device. The start of a device's data area will be a multiple of the
mi ni mum_i o _si ze or o pti mal _i o _si ze exposed in sysfs. LVM will use the mi ni mum_i o _si ze
if o pti mal _i o _si ze is undefined (i.e. 0 ).
By default, LVM will automatically determine these I/O hints, but this behavior can be disabled by
setting d ata_al ig nment_d etecti o n to 0 in /etc/l vm/l vm. co nf. Disabling this is not
recommended.
23.6. Part it ion and File Syst em T ools
This section describes how different partition and file system management tools interact with a
device's I/O parameters.
util-linux-ng's libblkid and fdisk
The li bbl ki d library provided with the uti l -l i nux-ng package includes a programmatic API to
access a device's I/O parameters. l i bbl ki d allows applications, especially those that use Direct
I/O, to properly size their I/O requests. The fd i sk utility from uti l-l i nux-ng uses l i bbl ki d to
ut il- linux- ng's libblkid and fdisk
161