On 10/12/2021 11.10, Paolo Bonzini wrote:
On 12/10/21 09:46, Thomas Huth wrote:
platform_test_xfs_fd() is only used to decide whether to invoke
XFS_IOC_DIOINFO; but failures of XFS_IOC_DIOINFO are ignored anyway, so
we can get rid of is_xfs in BDRVRawState, too.
After staring at the code for a while, I wonder why we're not simply using
fstat() here instead to get the st_blksize value... wouldn't that be
better anyway since it also works with other file system types?
The value that XFS_IOC_DIOINFO returns is the logical sector size of the
underlying device; it should be 512 or 4096, but more likely 512. It can be
smaller than st_blksize, because often it will be if it is 512 but the
st_blksize is usually 4096.
If it is wrong, QEMU will do unnecessary read/modify/write operations for
disk writes that are not 4K-aligned.
Ok, true, I've checked it and XFS_IOC_DIOINFO return 512 on my laptop
indeed, while fstat->st_blksize is 4096 instead. So it's not the same :-/
Thomas