All of lore.kernel.org
 help / color / mirror / Atom feed
From: hehuiwen <huiwen.he@linux.dev>
To: Steve French <smfrench@gmail.com>
Cc: linkinjeon@kernel.org, pc@manguebit.org,
	ronniesahlberg@gmail.com, sprasad@microsoft.com, tom@talpey.com,
	bharathsm@microsoft.com, senozhatsky@chromium.org,
	dhowells@redhat.com, metze@samba.org, chenxiaosong@kylinos.cn,
	linux-cifs@vger.kernel.org
Subject: Re: [PATCH v2 3/9] smb/client: handle smb2_set_sparse() failure in EOF-extending fallocate
Date: Thu, 25 Jun 2026 10:25:44 +0800	[thread overview]
Message-ID: <28c08c0f-6806-491b-89e2-8b20e67dac77@linux.dev> (raw)
In-Reply-To: <CAH2r5ms8bqK-Ywa0RsLPbB8fJikhA3N44oMRBFLzwD+J--nrDw@mail.gmail.com>

Hi Steve,

I I agree with your point. On local filesystems such as ext4, XFS and 
btrfs,fallocate can reserve space for the requested range, including a 
range beyond EOF, while leaving other holes in the file untouched.

However, patches 3 and 4 do not introduce new clear-sparse cases. They 
only stop ignoring errors from the existing smb2_set_sparse(..., false) 
calls. In the paths where CIFS still relies on FSCTL_SET_SPARSE to 
provide the preallocation guarantee, failure from that operation should 
fail fallocate; otherwise we can return success while the requested 
range may remain sparse.

But you reminded me to rethink two related questions:

1.Is clearing the SMB sparse attribute a reasonable approximation for 
Linux fallocate semantics in some limited cases? Linux fallocate is
byte-range based, while FSCTL_SET_SPARSE is a file-level operation,
so it may not be a good fit as a general range allocation mechanism.

2.If that approximation is acceptable only for limited cases, are all
current fallocate paths that use smb2_set_sparse(..., false) actually 
safe? In other words, do we need to tighten the current cases where
CIFS relies on clearing the sparse attribute to emulate fallocate?

I will check the current code paths more carefully and make sure the all
operations are actually safe, assuming that clearing the sparse 
attribute can be used to approximate fallocate semantics in some limited 
cases.

I would be glad to hear your thoughts on this.

Thanks,
Huiwen


在 2026/6/25 05:26, Steve French 写道:
> So presumably I should skip patches 3 and 4 since it is allowed to have a
> sparse file which has allocated beyond end of file, and also allowed to
> have a falloc in a file that has holes - so we shouldn't be failing
> fallocate just because clearing sparse bit fails. Any thoughts?
> 
> On Tue, Jun 23, 2026 at 11:05 PM hehuiwen <huiwen.he@linux.dev> wrote:
> 
>> Hi Steve,
>>
>> Yes, that is possible. I checked ext4, XFS and btrfs with examples like:
>>
>>           truncate -s 1M file
>>           fallocate -n -o 2M -l 1M file
>>           filefrag -v file
>>
>> and:
>>
>>           truncate -s 1M file
>>           fallocate -o 2M -l 1M file
>>           filefrag -v file
>>
>> With FALLOC_FL_KEEP_SIZE, the file size stays at 1M while the range
>> [2M, 3M) is preallocated. Without FALLOC_FL_KEEP_SIZE, the file size
>> grows to 3M, but the filesystems still only allocate the requested
>> range [2M, 3M). Holes before that range are not removed.
>>
>> Patch 3 only changes the error handling around the existing
>> smb2_set_sparse(..., false) call. I agree that clearing the sparse
>> attribute is not a general byte-range allocation mechanism.
>>
>> Patch 9 handles the sparse EOF-adjacent case differently: small ranges
>> are allocated by writing zeroes only to the requested range, and larger
>> ranges remain unsupported. That avoids clearing the sparse attribute
>> for this case.
>>
>> Thanks,
>> Huiwen
>>
>>
>> 在 2026/6/24 10:48, Steve French 写道:
>>> Would it be possible in Linux to have a sparse file but still with
>>> space reserved beyond end of file?  In other words are there cases
>>> where you could have a file with holes in it in Linux which still
>>> fallocated beyond end of file.  What happens to ext4, xfs, btrfs if
>>> you try that?  Does fallocate beyond of file remove all holes in a
>>> (sparse) file?
>>
>>
> 


  parent reply	other threads:[~2026-06-25  2:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-24  2:15 [PATCH v2 0/9] smb/client: fix mode 0 fallocate handling Huiwen He
2026-06-24  2:15 ` [PATCH v2 1/9] smb/client: name the default fallocate mode Huiwen He
2026-06-24  2:15 ` [PATCH v2 2/9] smb/client: preserve errors from smb2_set_sparse() Huiwen He
2026-06-24  2:15 ` [PATCH v2 3/9] smb/client: handle smb2_set_sparse() failure in EOF-extending fallocate Huiwen He
2026-06-24  2:48   ` Steve French
2026-06-24  4:04     ` hehuiwen
     [not found]       ` <CAH2r5ms8bqK-Ywa0RsLPbB8fJikhA3N44oMRBFLzwD+J--nrDw@mail.gmail.com>
2026-06-25  2:25         ` hehuiwen [this message]
2026-06-24  2:15 ` [PATCH v2 4/9] smb/client: handle smb2_set_sparse() failure in non-extending fallocate Huiwen He
2026-06-24  2:15 ` [PATCH v2 5/9] smb/client: do not account EOF extension as allocation Huiwen He
2026-06-24 21:49   ` Steve French
2026-06-24  2:15 ` [PATCH v2 6/9] smb/client: verify allocation after EOF-extending fallocate Huiwen He
2026-06-24  2:15 ` [PATCH v2 7/9] smb/client: handle overlapping allocated ranges in fallocate Huiwen He
2026-06-24  2:15 ` [PATCH v2 8/9] smb/client: reduce fallocate zero buffer allocation Huiwen He
2026-06-24  2:15 ` [PATCH v2 9/9] smb/client: emulate small sparse fallocate ranges at EOF Huiwen He

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=28c08c0f-6806-491b-89e2-8b20e67dac77@linux.dev \
    --to=huiwen.he@linux.dev \
    --cc=bharathsm@microsoft.com \
    --cc=chenxiaosong@kylinos.cn \
    --cc=dhowells@redhat.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=metze@samba.org \
    --cc=pc@manguebit.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=senozhatsky@chromium.org \
    --cc=smfrench@gmail.com \
    --cc=sprasad@microsoft.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.