S390x/arm64 stat() bug

If we call stat() on a just created file on s390x or arm64, then the value of struct stat's st_blocks field is often wrong (usually 1).

Steps to reproduce:

  • Create a file large enough to occupy a handful of blocks.
  • Run sync for good measure (doesn’t make any difference).
  • Run the stat command get all stat information of that file and save its output. It is likely that it reports that the file occupies only one block.
  • Run stat repeatedly, and compare its output with the output we got in the previous point. After a few tries it will report the correct number of blocks.

This build runs the above steps:

As you can see, all three supported Ubuntu releases are affected on s390x and arm64, while amd64 and ppc64le are apparently not affected at all.
Interestingly, both s390x and arm64 have their root file system mounted through shiftfs, while amd64 and ppc64le use the good old ext4.

Have you made your script executable?

Of course, you can see that the script have been executed in all the jobs of the build that I linked above.