"Austin S. Hemmelgarn" <ahferro...@gmail.com> wrote: > > A broken filesystem is a broken filesystem. > > > > If you try to change gtar to work around a specific problem, it may fail in > > other situations. > The problem with this is that tar is assuming things that are not > guaranteed to be true. There is absolutely nothing that says that > st_blocks has to be non-zero if there's data in the file. In fact, the
This is not true: POSIX requires st_blocks to be != 0 in case that the file contains data. > behavior that BTRFS used to have of reporting st_blocks to be 0 for > files entirely inlined in the metadata is absolutely correct given the > description of the field by POSIX, because there _are_ no blocks > allocated to the file (because the metadata block is technically > equivalent to the inode, which isn't counted by st_blocks). This is yet > another example of an old interface (in this case, sparse file > detection) being short-sighted (read in this case as non-existent). The internal state of a file system is irrelevant. The only thing that counts is the user space view and if a file contains data (read succeeds in user space), it needs to report st_blocks != 0. > The proper fix for this is that tar (and anything else that handles > sparse files differently) should be parsing the file regardless. It has > to anyway for a normal sparse file to figure out where the sparse > regions are, and optimizing for a file that's completely sparse (and > therefore probably pre-allocated with fallocate) is not all that > reasonable considering that this is going to be a very rare case in > normal usage. This does not help. Even on a decent OS (e.g. Solaris since Summer 2005) and a decent tar implementation (star) that supports SEEK_HOLE since Summer 2005, this method will not work for all filesystems as there may be old filesystem implementations and as there may be NFS... For this reason, star still checks st_blocks in case that SEEK_HOLE did not work. Jörg -- EMail:jo...@schily.net (home) Jörg Schilling D-13353 Berlin joerg.schill...@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.org/private/ http://sourceforge.net/projects/schilytools/files/'