st_blocks is a rather vaguely defined field. To quote the Linux stat(2)
man page:
Use of the st_blocks and st_blksize fields may be less portable.
(They were introduced in BSD. The interpretation differs between
systems, and possibly on a single system when NFS mounts are
involved.)
or the FreeBSD one:
st_blocks Actual number of blocks allocated for the file in
512-byte units. As short symbolic links are stored in
the inode, this number may be zero.
and at least for XFS they include speculative preallocations and
in-flight COW fork allocations, and the numbers can change when the way
how data is stored is reorganized. Because of that it doesn't make sense
to require st_blocks to not change after a crash even when fsync or
fdatasync was involved.
Remove the st_blocks checks and the now superfluous XFS always_cow
workaround.
Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>