mkfs.xfs: Don't stagger AG for a single disk
PATCH 1/1 mkfs.xfs: Don't stagger AG for a single disk
When sunit and swidth are used mkfs.xfs tries to avoid all allocation groups aligning on the same stripe and will attempt to stagger them across the stripes that make up swidth. If there is only one stripe then there is no benefit in this optimisation.
$ truncate -s10G xfs_10G_su256k_sw1.image
$ mkfs.xfs -d su=256k,sw=1 xfs_10G_su256k_sw1.image
meta-data=xfs_10G_su256k_sw1.image isize=512 agcount=16, agsize=163776 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=2620416, imaxpct=25
= sunit=64 swidth=64 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=64 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0A side effect of the optimisation is that the size adjustment used to stager the allocation groups causes the last sunit of storage to be unused.
$ echo $((2620416*4096)) 10733223936 $ ls -l xfs_10G_su256k_sw1.image -rw-rw-r--. 1 test test 10737418240 Aug 30 10:54 xfs_10G_su256k_sw1.image
Skip this optimisation when sunit == swidth.
--- mkfs/xfs_mkfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mkfs/xfs_mkfs.c +3 -1
@@ -2534,7 +2534,9 @@ reported by the device (%u).\n"), } } } -if (dswidth && ((agsize % dswidth) ==0 ) && (agcount >1 )) { +if (dswidth && ((agsize % dswidth) ==0 ) + && (dswidth != dsunit) + && (agcount >1 )) {/* This is a non-optimal configuration because all AGs * start on the same disk in the stripe. Changing * the AG size by one sunit will guarantee that this
Signature · 1 line
1.8.3.1
Quoted 20 lines · Donald Douwsma
When sunit and swidth are used mkfs.xfs tries to avoid all allocation groups aligning on the same stripe and will attempt to stagger them across the stripes that make up swidth. If there is only one stripe then there is no benefit in this optimisation.
$ truncate -s10G xfs_10G_su256k_sw1.image $ mkfs.xfs -d su=256k,sw=1 xfs_10G_su256k_sw1.image meta-data=xfs_10G_su256k_sw1.image isize=512 agcount=16, agsize=163776 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=2620416, imaxpct=25 = sunit=64 swidth=64 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=64 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0A side effect of the optimisation is that the size adjustment used to stager the allocation groups causes the last sunit of storage to be unused.
Quoted 8 lines
$ echo $((2620416*4096)) 10733223936 $ ls -l xfs_10G_su256k_sw1.image -rw-rw-r--. 1 test test 10737418240 Aug 30 10:54 xfs_10G_su256k_sw1.imageSkip this optimisation when sunit == swidth.
Signed-off-by Donald Douwsma <[email protected]>
Interesting. Yeah, I suppose this makes sense, though I'm surprised anyone would notice. :)
Thanks,
-Eric
Quoted 20 lines
--- mkfs/xfs_mkfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)mkfs/xfs_mkfs.c +3
-1@@ -2534,7 +2534,9 @@ reported by the device (%u).\n"), } } } -if (dswidth && ((agsize % dswidth) ==0 ) && (agcount >1 )) { +if (dswidth && ((agsize % dswidth) ==0 ) + && (dswidth != dsunit) + && (agcount >1 )) {/* This is a non-optimal configuration because all AGs * start on the same disk in the stripe. Changing * the AG size by one sunit will guarantee that this
Quoted 18 lines · Eric Sandeen
Quoted 17 lines · Donald Douwsma
When sunit and swidth are used mkfs.xfs tries to avoid all allocation groups aligning on the same stripe and will attempt to stagger them across the stripes that make up swidth. If there is only one stripe then there is no benefit in this optimisation.
$ truncate -s10G xfs_10G_su256k_sw1.image $ mkfs.xfs -d su=256k,sw=1 xfs_10G_su256k_sw1.image meta-data=xfs_10G_su256k_sw1.image isize=512 agcount=16, agsize=163776 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=2620416, imaxpct=25 = sunit=64 swidth=64 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=64 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
Quoted 2 lines
Quoted 2 lines
A side effect of the optimisation is that the size adjustment used to stager the allocation groups causes the last sunit of storage to be unused.
Actually it shrinks the agsize by one sunit, leading to the discrepancy of sunit * agcount, for the above example 4MB.
Quoted 11 lines
Quoted 8 lines
$ echo $((2620416*4096)) 10733223936 $ ls -l xfs_10G_su256k_sw1.image -rw-rw-r--. 1 test test 10737418240 Aug 30 10:54 xfs_10G_su256k_sw1.imageSkip this optimisation when sunit == swidth.
Signed-off-by Donald Douwsma <[email protected]>Interesting. Yeah, I suppose this makes sense, though I'm surprised anyone would notice. :)
Sysadmins see the dependency and worry that something went wrong. If you run xfs_growfs on the mounted volume it creates a tiny allocation group to add this space in, which adds to the confusion.
The broader question is what should mkfs be doing when this optimisation is active.
The space could be added to the last AG, but I think silently dropping it is not ideal.