Skip to content

Why does stat(2) .st_blocks reflect ZFS compression? #11533

Answered by behlendorf
dechamps asked this question in Q&A
Discussion options

You must be logged in to vote

That's a good question. It appears that the definition of st_blocks has been interpreted somewhat differently between platforms. This behavior was originally implemented on Solaris and it was defined in the man page as:

The total number of physical blocks of size 512 bytes actually allocated on disk. This field is not defined for block special or character special files

Unlike Linux's man page it makes no mention of why a file might take fewer physical blocks to store on disk. This is really an internal implementation detail that user space shouldn't need to concern itself with. This philosophy is the same on FreeBSD and it's man page says something very similar.

Actual number of block…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@poettering
Comment options

@Blub
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by ahrens
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #11532 on January 27, 2021 18:33.