bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-tar] Detection of sparse files is broken on btrfs


From: Tim Kientzle
Subject: Re: [Bug-tar] Detection of sparse files is broken on btrfs
Date: Tue, 9 Jan 2018 09:02:08 -0800

> Paul Eggert <address@hidden> wrote:
> 
>> POSIX does not require that st_nblocks remain constant across any system 
>> call. It doesn't even require that it remain constant if you merely call 
>> stat twice on the same file, without doing anything else in between.

The real question is then:

What is the most efficient (preferably portable) way for an archiving program 
(such as tar) to determine whether it should archive a particular file as 
sparse or non-sparse?

Historically, we’ve compared st_nblocks to st_size to quickly determine if a 
file is sparse in order to avoid the SEEK_HOLE scan in most cases.  Some 
programs even consider st_nblocks == 0 as an indication that a file is entirely 
sparse.  Based on the claims I’ve read here, it sounds like st_nblocks can no 
longer be trusted for these purposes.

So is there some other way to quickly identify sparse files so we can avoid the 
SEEK_HOLE scan for non-sparse files?

Cheers,

Tim





reply via email to

[Prev in Thread] Current Thread [Next in Thread]