On Sat, Dec 27, 2025, at 10:04, Nicolas George wrote:
> I would suggest: generate a random sequence of octets, *do not write it
> to disk*, scan the whole block device to check it is not there. Then
> write it into a file, remove the file immediately and scan again.
>
> Which I did, and I am humbled to say that you were right. I find that
> quite surprising and would need to look at how it is implemented.
The "does not even hit the underlying storage" behavior is a function of the
Linux page-cache, and most of the widely-used filesystems (certainly ext4 and
xfs) will behave like that unless specifically configured to operate in "sync"
mode.
Note that the page-cache can be flushed into the block device (by the kernel)
for several reasons. You can also ask the kernel to start that flush
("writeback") and wait for it to finish: the "sync" command does this, for
example. Try it: add the "sync" command to your test, just after writing the
file, but before unlinking the file.
--
Henrique de Moraes Holschuh <[email protected]>