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/3] smb/client: refresh allocation size after fallocate
Date: Mon, 8 Jun 2026 00:20:04 +0800 [thread overview]
Message-ID: <a398b181-776b-4bf4-a916-1da4f82b0741@linux.dev> (raw)
In-Reply-To: <CAH2r5ms=53YHR41Y9qWozAtSO5UP4yqDN4myp-pju7WpP2WLjg@mail.gmail.com>
Hi Steve,
Thanks for testing.
This may be related to the fallocate patch now refreshing i_blocks from
the server-reported AllocationSize. It seems generic/568 may have passed
before because the client-side i_blocks estimate was too optimistic,
rather than because the fallocated range was really allocated.
I need to verify this more carefully. I will look into it tomorrow.
Thanks,
Huiwen
在 2026/6/7 23:35, Steve French 写道:
> This regresses xfstests generic/568.
>
> generic/568 1s ... - output mismatch (see
> /home/smfrench/xfstests-dev/results//sambamfs/generic/568.out.bad)
> --- tests/generic/568.out 2025-08-22 09:54:32.333796989 -0500
> +++ /home/smfrench/xfstests-dev/results//sambamfs/generic/568.out.bad
> 2026-06-07 10:32:28.896135808 -0500
> @@ -1,4 +1,4 @@
> QA output created by 568
> wrote 2/2 bytes at offset block_size - 1
> XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> -OK: File did not grow.
> +ERROR: File grew from 512 B to 1536 B when writing to the fallocated range.
> ...
> (Run 'diff -u /home/smfrench/xfstests-dev/tests/generic/568.out
> /home/smfrench/xfstests-dev/results//sambamfs/generic/568.out.bad' to
> see the entire diff)
>
> On Fri, Jun 5, 2026 at 11:36 AM Huiwen He <huiwen.he@linux.dev> wrote:
>>
>> From: Huiwen He <hehuiwen@kylinos.cn>
>>
>> SMB3 fallocate extends EOF using FILE_END_OF_FILE_INFORMATION, but the
>> server may also update the file's AllocationSize. If the client keeps
>> the old cached i_blocks value after fallocate, the swapfile hole check
>> can still see:
>>
>> i_blocks * 512 < i_size
>>
>> and reject the file as sparse.
>>
>> This shows up in xfstests generic/496 as:
>>
>> generic/496 [not run] fallocated swap not supported here
>>
>> After a successful EOF-extending fallocate, query FILE_ALL_INFORMATION on
>> the open handle and update i_blocks from the returned AllocationSize. If
>> the query fails, leave the fallocate result unchanged and force a later
>> attribute revalidation by setting cifsi->time to zero.
>>
>> With this client-side refresh, and with a server that really allocates the
>> fallocated range, for example Samba configured with:
>>
>> [scratch_share]
>> strict allocate = yes
>>
>> generic/496 can pass the swapfile hole check.
>>
>> Signed-off-by: Huiwen He <hehuiwen@kylinos.cn>
>> Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
>> ---
>> fs/smb/client/smb2ops.c | 15 +++++++++++++++
>> 1 file changed, 15 insertions(+)
>>
>> diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
>> index d4875f9532b4..89230141b5dd 100644
>> --- a/fs/smb/client/smb2ops.c
>> +++ b/fs/smb/client/smb2ops.c
>> @@ -3698,8 +3698,23 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
>> rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
>> cfile->fid.volatile_fid, cfile->pid, new_eof);
>> if (rc == 0) {
>> + struct smb2_file_all_info file_inf;
>> + u64 asize;
>> + int qrc;
>> +
>> netfs_resize_file(&cifsi->netfs, new_eof, true);
>> cifs_setsize(inode, new_eof);
>> +
>> + qrc = SMB2_query_info(xid, tcon, cfile->fid.persistent_fid,
>> + cfile->fid.volatile_fid, &file_inf);
>> + spin_lock(&inode->i_lock);
>> + if (qrc == 0) {
>> + asize = le64_to_cpu(file_inf.AllocationSize);
>> + inode->i_blocks = CIFS_INO_BLOCKS(asize);
>> + } else {
>> + cifsi->time = 0;
>> + }
>> + spin_unlock(&inode->i_lock);
>> }
>> goto out;
>> }
>> --
>> 2.43.0
>>
>
>
next prev parent reply other threads:[~2026-06-07 16:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 16:35 [PATCH v2 0/3] smb: client: fix i_blocks accounting for swapfile xfstests Huiwen He
2026-06-05 16:35 ` [PATCH v2 1/3] smb/client: update i_blocks after contiguous writes Huiwen He
2026-06-05 16:35 ` [PATCH v2 2/3] smb/client: do not account EOF extension as allocation Huiwen He
2026-06-07 15:33 ` Steve French
2026-06-05 16:35 ` [PATCH v2 3/3] smb/client: refresh allocation size after fallocate Huiwen He
2026-06-07 15:35 ` Steve French
2026-06-07 16:20 ` hehuiwen [this message]
2026-06-08 15:28 ` hehuiwen
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=a398b181-776b-4bf4-a916-1da4f82b0741@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.