Optimizing Performance of SSDs and Advanced Format Drives

The following information is taken from a FAQ entry on the ZFS on Linux project web site, reference: https://github.com/zfsonlinux/zfs/wiki/faq.

Advanced Format (AF) is a disk format that natively uses a sector size of 4,096 bytes instead of 512 bytes. To maintain compatibility with legacy systems, AF disks emulate a sector size of 512 bytes.

The default behavior of ZFS is to automatically detect the sector size of the drive. However, when attempting to detect the sector size of an AF drive, ZFS will not be able to detect the native sector size, and will instead trust the drive when it reports the emulated size. This can result in poorly aligned disk access that degrades performance of the pool.

Therefore, the ability to set the  property has been added to the   command. This allows users to explicitly assign the sector size when devices are first added to a pool (typically at pool creation time or when adding a  to the pool). The  values range from 9 to 16, with the default value 0 meaning that ZFS should auto-detect the sector size.

This issue is rare on hard disk drives, and so it might not be necessary to alter the  value. However, there are reports that SSDs can benefit from setting the  property explicitly to match the 4096 byte sector size.

The value of  is actually a bit shift value, so the   value for 512 bytes is 9 (29 = 512) while the   value for 4,096 bytes is 12 (212 = 4,096). To force the pool to use 4,096 byte sectors at pool creation time:

 $ sudo zpool create -o ashift=12 tank mirror sda sdb

To force the pool to use 4,096 byte sectors when adding a vdev to a pool:

 $ sudo zpool add -o ashift=12 tank mirror sdc sdd

Note: Do not set the  property to a value that will assign a sector size larger than the device physical block size. The logical and physical block sizes can be read from sysfs:

 cat /sys/class/block/ /queue/logical_block_size cat /sys/class/block/ /queue/physical_block_size