Subject: bug#5918: [dd] conv=sparse option

From: Pádraig Brady <[email-masked]>
Date: Mon, 22 Nov 2010 16:19:25 +0000

On 11/04/10 15:01, Jim Meyering wrote:
> Pádraig Brady wrote:
>> On 10/04/10 01:28, Heinrich Langos wrote:
>>> Hello Andreas, Samuel and list,
>>>
>>> sorry to pick up such an old thread, but I stumbled upon it while
>>> looking for an efficient way to "re-sparse" files that contain a
>>> lot of zero blocks but
>>> 1) had already been expanded
>>> or
>>> 2) are being expanded due to pipes.
>>>
>>> On Sun, Dec 30, 2007 at 10:19:54AM +0100, Andreas Schwab wrote:
>>>> Samuel Thibault <[email-masked]> writes:
>>>>
>>>>> Some time ago, I wrote a conv=sparse option for dd, attached is the
>>>>> patch.
>>>>
>>>> How is it different from cp --sparse=always?
>>>
>>> I'd say in enough ways to make such an option highly desirable.
>>>
>>> a) "dd" will maintain an existing of=target file including the inode
>>>    number, thus respecting existing hard links. "cp" will depending
>>>    on the other options given (e.g. "-a") maintain or break existing
>>>    hard links to an existing target file.
>>
>> I don't think that's possible as holes can only be created at the end of a file.
>> Well I think NTFS supports punching holes in the "middle" but it's not common.
> 
> I would like at least cp to be able to copy sparse files efficiently,
> and considering the FIEMAP patches that Jeff Liu is working on, we
> don't have long to wait.
> 
> BTW, I'm pretty sure it is possible to punch a hole in the middle of
> a file with XFS.  Maybe with other CoW file systems, too?

They're just now adding FALLOC_FL_PUNCH_HOLE to fallocate() in the Linux kernel.
It's supported by xfs and ocfs2, and other filesystems will for now, return EOPNOTSUPP
fallocate(..,FALLOC_FL_PUNCH_HOLE) will return EOPNOTSUPP on older kernels
even for xfs and ocfs2.

cheers,
Pádraig.