xfs
[Top] [All Lists]

Re: Files full of zeros with coreutils-8.11 and xfs (FIEMAP related?)

To: Dave Chinner <david@xxxxxxxxxxxxx>
Subject: Re: Files full of zeros with coreutils-8.11 and xfs (FIEMAP related?)
From: Andreas Dilger <adilger@xxxxxxxxx>
Date: Sun, 17 Apr 2011 20:45:56 -0600
Cc: Theodore Tso <tytso@xxxxxxx>, Pádraig Brady <P@xxxxxxxxxxxxxx>, Eric Sandeen <sandeen@xxxxxxxxxxx>, "linux-ext4@xxxxxxxxxxxxxxx" <linux-ext4@xxxxxxxxxxxxxxx>, "coreutils@xxxxxxx" <coreutils@xxxxxxx>, Markus Trippelsdorf <markus@xxxxxxxxxxxxxxx>, xfs-oss <xfs@xxxxxxxxxxx>
In-reply-to: <20110418004040.GS21395@dastard>
References: <20110414140222.GB1679@xxxxxxxxxxxxxx> <4DA70BD3.1070409@xxxxxxxxxxxxxx> <4DA717B2.3020305@xxxxxxxxxxx> <20110414225904.GK21395@dastard> <4DA7836A.5040604@xxxxxxxxxxxxxx> <20110415000940.GL21395@dastard> <76FFF648-CA02-494B-A862-566C66A8CB82@xxxxxxxxx> <20110416005040.GP21395@dastard> <E7438588-5C5A-42B9-9B6C-FADF7CAC6D3A@xxxxxxxxx> <4EEEA16E-1FDB-4430-A372-8F8701196E4C@xxxxxxx> <20110418004040.GS21395@dastard>
On 2011-04-17, at 6:40 PM, Dave Chinner <david@xxxxxxxxxxxxx> wrote:
On Sat, Apr 16, 2011 at 08:21:28AM -0400, Theodore Tso wrote:
On Apr 16, 2011, at 1:11 AM, Andreas Dilger wrote:
In that case, it means cp should just always use FIEMAP_FLAG_SYNC, which is fine.

Except that if someone is copying a large delay allocated file, it will cause
the file to immediately snapped to disk, which might not be the greatest
thing in the world.

Obvious workaround - if the initial fiemap call shows unwritten
extents, redo it with the sync flag set. Though that assumeѕ that
you can trust things like delalloc extents to only cover the range
that valid data exists in. Which, of course, you can't assume,
either. :/

Always passing FIEMAP_FLAG_SYNC is fine in this case. It should only do anything if there is unwritten data, which is the only case we are concerned with at this point.  In any case, this is a simple solution for coreutils until such a time that a more complex solution is added in the kernel (if ever).

Christoph is write, SEEK_HOLE and SEEK_DATA are
a much better API for what cp woulld lke to do.  Unfortunately it hasn't
been implemented yet in the VFS...

Agreed, SEEK_HOLE/SEEK_DATA is the right way to solve this problem.

I don't see how this will change the problem in any meaningful way. There will still need to be code that is traversing the on-disk mapping, and also keeping it coherent with unwritten data in the page cache.

Since FIEMAP already exists for most Linux filesystems, it probably makes sense to implement SEEK_{HOLE,DATA} by calling FIEMAP to get the disk mapping in the first place.

I agree that SEEK_{HOLE,DATA} is an easier programming interface, and probably what cp, tar, etc should use, once it is implemented. 

Cheers, Andreas
<Prev in Thread] Current Thread [Next in Thread>