Subject: bug#9500: [PATCH]: use posix_fallocate where supported

From: Goswin von Brederlow <[email-masked]>
Date: Sat, 26 Nov 2011 04:55:08 +0100

Pádraig Brady <[email-masked]> writes:

> On 11/25/2011 10:13 AM, Pádraig Brady wrote:
>
>> Hmm, one of your points above got me thinking.
>> Might fallocate() fail to allocate an extent with ENOSPC,
>> but there could be fragmented space available to write()?
>> That would scupper benefit (2) above :(
>> I'll ask [email-masked]
>
> And the response from there is that fallocate() will
> check the free blocks first, and then try to allocate
> as a contiguous extent, but that part is not guaranteed.
> So we still get benefit (2).
>
> cheers,
> Pádraig.

Don't forget that a sparse file uses less space than its size. So any cp
mode that checks for zero filled blocks and omits them on the
destination might use less blocks than the source uses or than the
fiemap indicates.

So cp can only fail on ENOSPC from fallocate() if it does not skip zero
filled blocks. I.e. when --sparse=never or --sparse=auto doesn't detect
a sparse file. But that is quite often the case.

MfG
        Goswin