/usr/bin/fallocate -v -d -l 2 myfile takes forever

Mark Geisert mark@maxrnd.com
Fri Mar 8 09:43:05 GMT 2024


On 3/5/2024 2:43 AM, Mark Geisert via Cygwin wrote:
> On 3/5/2024 12:46 AM, Cedric Blancher via Cygwin wrote:
>> On Mon, 29 Jan 2024 at 10:46, Mark Geisert via Cygwin 
>> <cygwin@cygwin.com> wrote:
>>>
>>> On 1/28/2024 11:56 PM, Mark Geisert via Cygwin wrote:
>>>> On 1/28/2024 10:44 PM, Cedric Blancher via Cygwin wrote:
>>>>> Good morning!
>>>>>
>>>>> rm -f myfile
>>>>> touch myfile
>>>>> /usr/bin/fallocate -v -d -l myfile takes forever with latest Cygwin 
>>>>> 3.5
>>>>                                ^ length goes here, before filename
>>>>
>>>> I believe you need to
>>>>       chattr +S myfile
>>>> after the 'touch' to make the file sparsifiable.
>>>>
>>>> Also, I'm unsure if '-d' makes sense when initially allocating a sparse
>>>> file.  If I leave it off, fallocate does the right thing.
>>>>
>>>> I'm separately investigating the 'takes forever' report.
>>>
>>> It's taking forever because it's in an infinite loop looking for data
>>> followed by a hole, which is not present in a new file being created.
>>> This is due to the '-d' option being specified.  fallocate ought to
>>> diagnose this condition rather than looping forever, but here we are.
>>>
>>> It's possible we have an old fallocate from an old util-linux package.
>>> I'll try to investigate this further when I have time.
>>>
>>
>> Any update on this issue?
> 
> Thanks for the reminder. I'll check repology to see if we can maybe 
> support a newer util-linux. No guarantees its fallocate is any better, 
> but lets first see if it builds at all. Give me a couple days, please.

A newer util-linux package has been uploaded. I find that its fallocate 
operates identically to the earlier one for your example.  So, to 
summarize, when allocating a brand new file:
   1) don't specify '-d' option,
   2) after creating file with 'touch', do 'chattr +S' on it,
   3) using fallocate on the file without step 2 won't sparsify it.

It's easier to see fallocate is working properly by giving it a file 
size large enough to make a difference by sparsifying. My testing shows 
that specifying '-l 2m' to create a 2MB file makes the file occupy 64 
blocks if it's sparsified, 2048 blocks if it isn't. Use 'stat <file>' to 
get the block size of the file. 'ls -l' will show 2MB either way.
HTH,

..mark



More information about the Cygwin mailing list