Andreas Dilger <adil...@dilger.ca> wrote: > Given that calling SEEK_HOLE is also going to have some cost, my suggestion > would be to ignore st_blocks completely for small files (size < 64KB) and > just read the file in this case, since the overhead of reading will probably > be about the same as checking if any blocks are allocated. If no blocks are > allocated, then the read will not do any disk IO, and if there are blocks > allocated they would have needed to be read from disk anyway and SEEK_HOLE > would be pure overhead.
If you propose to ignore st_blocks completely for small files that are on historic (unmaintained) filesystems without SEEK_HOLE support, this is what star does since years ;-) > To catch larger files that have been written to cache but haven't flushed > data to disk yet, it might still make sense to use SEEK_HOLE on larger files > with st_blocks == 0, especially if they have a recent mtime. Using mtime does not look like a good idea in this context. 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://sf.net/projects/schilytools/files/'