Linux filesystem development
 help / color / mirror / Atom feed
* Re: Meaning of struct statx->stx_blksize field
@ 2026-05-03 12:41 Andreas Dilger
  2026-05-03 13:53 ` Zeno Endemann
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Dilger @ 2026-05-03 12:41 UTC (permalink / raw)
  To: Zeno Endemann; +Cc: linux-fsdevel

On Apr 27, 2026, at 06:41, Zeno Endemann <zeno.endemann@mailbox.org> wrote:
> 
> Hi,
> 
> The man page of statx(2) describes the stx_blksize like so:
> 
> > The "preferred" block size for efficient filesystem I/O.
> > (Writing to a file in smaller chunks may cause an
> > inefficient read-modify-rewrite.)

The statx(2) interface is meant to be able to emulate the stat(2)
interface, where 'stx_blksize' is reporting the same information
as 'st_blksize' exactly as documented (preferred IO size),

> 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.

IIRC, ext2/ext3/ext4 have always returned the blocksize for stat(2)
st_blksize, so that doesn't prevent the two from being the same. 

> 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).

That is probably more an effect of history rather than anything
related to statx() itself.  ext4 doesn't really have any other
preference on the IO size other than the blocksize.   

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


Cheers, Andreas






^ permalink raw reply	[flat|nested] 3+ messages in thread
* Meaning of struct statx->stx_blksize field
@ 2026-04-27 10:41 Zeno Endemann
  0 siblings, 0 replies; 3+ messages in thread
From: Zeno Endemann @ 2026-04-27 10:41 UTC (permalink / raw)
  To: linux-fsdevel

Hi,

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

 > 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-03 13:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-03 12:41 Meaning of struct statx->stx_blksize field Andreas Dilger
2026-05-03 13:53 ` Zeno Endemann
  -- strict thread matches above, loose matches on Subject: below --
2026-04-27 10:41 Zeno Endemann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox