Page MenuHomeFreeBSD

cp: Adjust the sparse file tests.

Authored by des on Feb 7 2023, 1:10 PM.
Referenced Files
Unknown Object (File)
Thu, Dec 7, 12:45 PM
Unknown Object (File)
Sat, Dec 2, 3:09 PM
Unknown Object (File)
Mon, Nov 27, 1:19 AM
Unknown Object (File)
Nov 7 2023, 12:44 PM
Unknown Object (File)
Aug 19 2023, 4:45 AM
Unknown Object (File)
Jul 22 2023, 8:08 PM
Unknown Object (File)
Jun 27 2023, 8:45 AM
Unknown Object (File)
Jun 24 2023, 4:23 AM


  • The sparsity check was ineffective: it compared the apparent size in bytes to the actual size in blocks.
  • Some of the seq commands were missing an argument.
  • Based on empirical evidence, 1 MB holes are not necessarily large enough to be preserved by the underlying filesystem. Increase the hole size to 16 MB.

MFC after: 1 week
Sponsored by: Klara, Inc.

Diff Detail

rG FreeBSD src repository
Lint Not Applicable
Tests Not Applicable

Event Timeline

des requested review of this revision.Feb 7 2023, 1:10 PM
This revision is now accepted and ready to land.Feb 8 2023, 2:29 PM
markj added inline comments.

Hmm, I think this is a bit too simplistic. On ZFS I see:

markj@nuc> jot 4096 1 1 > 1
markj@nuc> du -h 1
512B    1
markj@nuc> du -hA 1
8.0K    1
markj@nuc> dd if=/dev/random of=2 bs=4K count=1
1+0 records in
1+0 records out
4096 bytes transferred in 0.000220 secs (18653284 bytes/sec)
markj@nuc> du -h 2
4.5K    2
markj@nuc> du -hA 2
4.0K    2

Neither of these files is sparse obviously, and it looks like ZFS is reporting the size of the dnode as well as a compressed size.

I can't think of a way to check for holes from the shell.

des marked an inline comment as done.Feb 8 2023, 3:55 PM
des added inline comments.

That's a good point. I suppose I could write a hole detection tool in C. It's still better than the previous version (which would report every file as sparse).

des marked an inline comment as done.

Use a custom tool to detect sparseness.

This revision now requires review to proceed.Feb 8 2023, 4:21 PM
This revision is now accepted and ready to land.Feb 8 2023, 4:46 PM
This revision was automatically updated to reflect the committed changes.