Bug#661580: mkfs.xfs fails to detect correct sector size
Package: xfsprogs
Version: 3.1.7
Severity: important
File: /sbin/mkfs.xfs
Hi,
since I recently bought a harddisk with 4K sector size I've been checking for correct alignment and blocksizes in various things. One of them being xfs.
When I partition the disk in parted it shows correctly to have a logical blocksize of 512 byte and physical blocksize of 4096 byte. But mkfs.xfs does not detect that the physical blocksize is 4096 byte and creates a filesystem with:
meta-data=/dev/sde1 isize=256 agcount=32, agsize=22892696 blks
= sectsz=512 attr=2
data = bsize=4096 blocks=732566272, imaxpct=5
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0
log =internal bsize=4096 blocks=357698, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0This often results in access to the disk that is not aligned to the blocksize with the resulting degradation in performance.
Further, manually selecting the right sector size of 4096 still causes lots of unaligned access while formating and while mounting the filesystem. It does seem to fix the problem for actual use though.
MfG
Goswin
-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 3.1.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=de_DE (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash
Versions of packages xfsprogs depends on:
ii libblkid1 2.20.1-1 ii libc6 2.13-21 ii libreadline5 5.2-11 ii libuuid1 2.19.1-5
xfsprogs recommends no packages.
Versions of packages xfsprogs suggests:
pn acl 2.2.51-4 pn attr 1:2.4.46-3 pn quota <none> pn xfsdump <none>
-- no debconf information
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Carlos, didn't you plan to look into this issue?
Goswin, how do you determin that mkfs is still doing unaligned I/O when forcing the large sevtor size? Once we set the sector size XFS can't do I/O smaller than it.
Quoted 60 lines · Goswin von Brederlow
Package: xfsprogs
Version: 3.1.7
Severity: important
File:/sbin/mkfs.xfsHi,
since I recently bought a harddisk with 4K sector size I've been checking for correct alignment and blocksizes in various things. One of them being xfs.
When I partition the disk in parted it shows correctly to have a logical blocksize of 512 byte and physical blocksize of 4096 byte. But mkfs.xfs does not detect that the physical blocksize is 4096 byte and creates a filesystem with:
meta-data=/dev/sde1 isize=256 agcount=32, agsize=22892696 blks = sectsz=512 attr=2 data = bsize=4096 blocks=732566272, imaxpct=5 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 log =internal bsize=4096 blocks=357698, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0This often results in access to the disk that is not aligned to the blocksize with the resulting degradation in performance.
Further, manually selecting the right sector size of 4096 still causes lots of unaligned access while formating and while mounting the filesystem. It does seem to fix the problem for actual use though.
MfG
Goswin-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)Kernel: Linux 3.1.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=de_DE (charmap=ISO-8859-1)
Shell:/bin/shlinked to/bin/dashVersions of packages xfsprogs depends on:
ii libblkid1 2.20.1-1 ii libc6 2.13-21 ii libreadline5 5.2-11 ii libuuid1 2.19.1-5xfsprogs recommends no packages.
Versions of packages xfsprogs suggests:
pn acl 2.2.51-4 pn attr 1:2.4.46-3 pn quota <none> pn xfsdump <none>
Quoted 7 lines
-- no debconf information
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
---end quoted text---
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 7 lines · Christoph Hellwig
Carlos, didn't you plan to look into this issue?
Goswin, how do you determin that mkfs is still doing unaligned I/O when forcing the large sevtor size? Once we set the sector size XFS can't do I/O smaller than it.
On Tue, Feb 28, 2012 at 08:49:14AM +0100, Goswin von Brederlow wrote:
Yes, I was looking to it some time ago, but iirc it was already implemented and I was just fixins some issues on the code already implemented. I just got a new box and I'm recovering my backup (including code trees). I'll take a look on this later today and let you know on which steps this is.
Signature · 7 lines
--Carlos _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 5 lines · Christoph Hellwig
Carlos, didn't you plan to look into this issue?
Goswin, how do you determin that mkfs is still doing unaligned I/O when forcing the large sevtor size? Once we set the sector size XFS can't do I/O smaller than it.
I'm writing a nbd-server that uses async IO via libaio (the linux kernel AIO interface). This has some alignment requirements so I set nbd to use a 4k blocksize and added asserts that all requests are page aligned (both offset and size of the request). That worked fine for dd and mkfs.ext4 but fails on mount in general or mkfs.xfs.
So next I added a printf("WARNING: unaligned read/write") and handled unaligned access in the server to see how extensive the problem is. With ext4 I get ONE single read request of 512 Byte on mount and everything else properly 4k aligned. With xfs I get a ton of them.
If you want I can add a log of the read/write requests a mkfs.xfs and mount generates.
MfG
Goswin
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 5 lines · Christoph Hellwig
Carlos, didn't you plan to look into this issue?
Goswin, how do you determin that mkfs is still doing unaligned I/O when forcing the large sevtor size? Once we set the sector size XFS can't do I/O smaller than it.
I did think this was supposed to be working already:
get_topology(&xi, &ft);
if (ft.sectoralign) {
/*
* Older Linux software RAID versions want the sector size
* to match the block size to avoid switching I/O sizes.
* For the legacy libdisk case we thus set the sector size to
* match the block size. For systems using libblkid we assume
* that the kernel is recent enough to not require this and
* ft.sectoralign will never be set.
*/
sectorsize = blocksize;
} else if (!ssflag) {
/*
* Unless specified manually on the command line use the
* advertised sector size of the device.
*/
sectorsize = ft.sectorsize ? ft.sectorsize : XFS_MIN_SECTORSIZE;
}but it may depend on whether or not it is being built with libblkid support or not...?
I'll try to test it when I have some time, unless Carlos beats me to it.
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 29 lines · Eric Sandeen
Quoted 5 lines · Christoph Hellwig
Carlos, didn't you plan to look into this issue?
Goswin, how do you determin that mkfs is still doing unaligned I/O when forcing the large sevtor size? Once we set the sector size XFS can't do I/O smaller than it.
I did think this was supposed to be working already:
get_topology(&xi, &ft); if (ft.sectoralign) { /* * Older Linux software RAID versions want the sector size * to match the block size to avoid switching I/O sizes. * For the legacy libdisk case we thus set the sector size to * match the block size. For systems using libblkid we assume * that the kernel is recent enough to not require this and * ft.sectoralign will never be set. */ sectorsize = blocksize; } else if (!ssflag) { /* * Unless specified manually on the command line use the * advertised sector size of the device. */ sectorsize = ft.sectorsize ? ft.sectorsize : XFS_MIN_SECTORSIZE; }
Quoted 5 lines
but it may depend on whether or not it is being built with libblkid support or not...?
I'll try to test it when I have some time, unless Carlos beats me to it.
-Eric
I'm asuming libblkid is used, otherwise a sectorsize of 512 would make no sense.
It might be that NBD advertises the geometry wrong, as in ft.sectorsize isn't set correctly. That would make that part at least a kernel bug.
MfG
Goswin
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 5 lines · Goswin von Brederlow
I'm asuming libblkid is used, otherwise a sectorsize of 512 would make no sense.
It might be that NBD advertises the geometry wrong, as in ft.sectorsize isn't set correctly. That would make that part at least a kernel bug.
Now that I've looked at nbd: I can't find any way to transfer the physical or logical block size information to the nbd client. How do you try set it on the server?
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 10 lines · Christoph Hellwig
Quoted 5 lines · Goswin von Brederlow
I'm asuming libblkid is used, otherwise a sectorsize of 512 would make no sense.
It might be that NBD advertises the geometry wrong, as in ft.sectorsize isn't set correctly. That would make that part at least a kernel bug.
Now that I've looked at nbd: I can't find any way to transfer the physical or logical block size information to the nbd client. How do you try set it on the server?
I don't. The protocol doesn't (yet) have an option for this. There are a number of new options planed for the new handshake protocol but the nbd maintainer hasn't had time to implement them yet.
What I do is set the blocksize = 4096 on the nbd-client commandline knowing that that is what the server expects.
MfG
Goswin
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs