I created an XFS file system using default parameters at the time of creation of a system. Now looking at the output of xfs_info
, it show 0 for the values of sunit
and swidth
. I can't seem to find an explanation of what 0 means in this context. (The discussions of sunit
and swidth
that I have found are focused on setting the correct values for these parameters, not setting them to 0.)
# xfs_info .
meta-data=/dev/mapper/centos-root isize=256 agcount=8, agsize=268435455 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=1927677952, imaxpct=5
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=521728, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
This must be an ignorant question, for which I apologize because I am an XFS newbie, but what is the meaning of 0 values for sunit
and swidth
? How can I find out what XFS is really using for those parameter values, and how those values relate to the values that would be appropriate for my RAID array? (This is an XFS system on top of LVM on top of hardware RAID.)
This is an old question, but I think a more comprehensive answer can be useful.
In short: when using software RAID, let XFS autodetect the underlying array geometry. If using hardware RAID on recent kernel, XFS should be capable of autodetecting the correct parameters; if no, you can use
su/sw/sunit/swidth
to specify them.Knowing the underlying geometry helps the XFS allocator to avoid crossing two disks when possible, conserving IOPS for other works (ie: less data disk are engaged).
In the specific example above, where
mkfs.xfs
report bothsunit=0
andswidth=0
, it means XFS did not detect any specific RAID geometry on the block device where the filesystem was created.Long answer: Let's start from
su
andsw
. From the (somewhat outdated) XFS faq:Note that in this context, "stripe size" refer to the single stripe unit size, also called chunk size by Linux MD RAID. Again from the faq:
sunit
andswidth
are another method to express the same RAID geometry, this times in 512B sectors. From mkfs.xfs man page:In short:
As you can see, they are two different methods to inform XFS about the underlying RAID geometry. However, the faq tell us about a catch in how
mkfs.xfs
reportssunit
andswidth
:Basically, when making a filesystem you specify
sunit
andswidth
in 512B sectors, while the very samemkfs.xfs
report them in 4K block size. This difference is a common source of confusion.if you're not using RAID,
sunit
andswidth
options are obsolete, its for RAID optimizationfor more info about
sunit
andswidth
refer to XFS FAQZero means zero optimization of extent allocation wrt the underlying RAID structure, that's right.
So if you are concerned with performance and you simply can recreate the FS, analyze the # of drives and their chunk size in your raid set/controller and set
sunit
andswidth
accordingly inmkfs.xfs
.And if (and only if) you need to create partition(s) on the RAID LUN, make sure the first starts at a 1 MByte boundary (2048s if sector = 512 bytes), as this is what most RAID chunk sizes are divisible by.