- Minor
For 4Kn drives I have noticed that if you add a new drive to the array and let it format it as xfs, the sector size in xfs is set to 512 instead of 4096.
If you do the same via the pool, the sector size is 4096, great.
If you format the drive via the cli with mkfs.xfs, the sector size is 4096, great.
Please can explain why the 4Kn drives in the array seem to format with a default 512 sector size using xfs?
Here is my tests, ignore the fact these examples use a 4Kn nvme ssd, I get the same results for 4Kn hdd, but did not have one to hand when writing this.
As you can see the drive is 4Kn:
root@Tower:/etc# lsblk -o NAME,LOG-SEC,PHY-SEC,SIZE
NAME LOG-SEC PHY-SEC SIZE
nvme0n1 4096 4096 931.5G
└─nvme0n1p1 4096 4096 931.5G
Created via array, sector size is 512.
root@Tower:/etc# xfs_info /dev/nvme0n1p1
meta-data=/dev/nvme0n1p1 isize=512 agcount=4, agsize=61047597 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=1
= reflink=1 bigtime=1 inobtcount=1 nrext64=1
= exchange=0
data = bsize=4096 blocks=244190385, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1, parent=0
log =internal log bsize=4096 blocks=119233, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
Created via pool, sector size is 4096.
root@Tower:/etc# xfs_info /dev/nvme0n1p1
meta-data=/dev/nvme0n1p1 isize=512 agcount=4, agsize=61047596 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=1
= reflink=1 bigtime=1 inobtcount=1 nrext64=1
= exchange=0
data = bsize=4096 blocks=244190384, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1, parent=0
log =internal log bsize=4096 blocks=119233, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
Created via cli, sector size is 4096.
root@Tower:/etc# mkfs.xfs /dev/nvme0n1p1
meta-data=/dev/nvme0n1p1 isize=512 agcount=4, agsize=61047597 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=1
= reflink=1 bigtime=1 inobtcount=1 nrext64=1
= exchange=0
data = bsize=4096 blocks=244190388, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1, parent=0
log =internal log bsize=4096 blocks=119233, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
Discarding blocks...Done.
You can see in the C source the default for mkfs.xfs is actually to use the physical sector of the drive, and for a 4Kn drive, this is 4096.
https://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git/tree/mkfs/xfs_mkfs.c#n2130
Comment from source:
/* * Unless specified manually on the command line use the * advertised sector size of the device. We use the physical * sector size unless the requested block size is smaller * than that, then we can use logical, but warn about the * inefficiency. * * Some architectures have a page size > XFS_MAX_SECTORSIZE. * In that case, a ramdisk or persistent memory device may * advertise a physical sector size that is too big to use. */