ostree/tests/kolainst
Jonathan Lebon 193ef29f3f lib/deploy: Use fallocate for early prune space check
The `f_bfree` member of the `statvfs` struct is documented as the
"number of free blocks". However, different filesystems have different
interpretations of this. E.g. on XFS, this is truly the number of blocks
free for allocating data. On ext4 however, it includes blocks that
are actually reserved by the filesystem and cannot be used for file
data. (Note this is separate from the distinction between `f_bfree` and
`f_bavail` which isn't relevant to us here since we're privileged.)

If a kernel and initrd is sized just right so that it's still within the
`f_bfree` limit but above what we can actually allocate, the early prune
code won't kick in since it'll think that there is enough space. So we
end up hitting `ENOSPC` when we actually copy the files in.

Rework the early prune code to instead use `fallocate` which guarantees
us that a file of a certain size can fit on the filesystem. `fallocate`
requires filesystem support, but all the filesystems we care about for
the bootfs support it (including even FAT).

(There's technically a TOCTOU race here that existed also with the
`statvfs` code where free space could change between when we check
and when we copy. Ideally we'd be able to pass down that fd to the
copying bits, but anyway in practice the bootfs is pretty much owned by
libostree and one doesn't expect concurrent writes during a finalization
operation.)
2023-05-29 12:17:05 -04:00
..
data-shared Support overlayfs whiteouts on checkout 2022-09-28 12:26:31 +02:00
destructive lib/deploy: Use fallocate for early prune space check 2023-05-29 12:17:05 -04:00
nondestructive itest-pull-space: Use mkfs.ext4, align to at least 512b 2023-03-14 17:07:01 -04:00
.gitignore tests/inst: Add destructive test framework 2020-08-17 14:34:04 +00:00
destructive-stamp.ign tests/inst: Add destructive test framework 2020-08-17 14:34:04 +00:00
install-wrappers.sh tests/inst: Add destructive test framework 2020-08-17 14:34:04 +00:00
Makefile tests/kolainst: Add make localinstall 2023-04-14 15:19:17 -04:00
README.md tests/kola: Move to tests/kolainst 2020-05-27 15:16:50 +00:00