Skip to contentSkip to conversation

Meaning of struct statx->stx_blksize field

DISCUSSION Zeno Endemann 1 participant 1 message Apr 27 VFS

lore
Share & tools
lore
#0 lore raw

Hi,

The man page of statx(2) describes the stx_blksize like so:

Quoted 3 lines

The "preferred" block size for efficient filesystem I/O. (Writing to a file in smaller chunks may cause an inefficient read-modify-rewrite.)

However, from observation it rather looks like that field is set to the "block size" (meaning the allocation unit) of the file system the given file resides on - at least for ext4 and vfat.

To my understanding that value is fairly unrelated to a good IO transfer size and for the most part not really relevant for userspace apps. For avoiding inefficient read-modify rewrite the actual relevant thing is writing in multiples of the page size (unless the page cache is bypassed, in which case I guess stx_dio_offset_align is the value to use).

Can someone confirm my interpretation, so the man page can be corrected? Or do I misunderstand or overlook something?

Thanks,

Zeno Endemann