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/3] smb/client: refresh allocation size after fallocate
Date: Mon, 8 Jun 2026 23:28:05 +0800	[thread overview]
Message-ID: <927ef661-e562-436e-aca2-a772463da73e@linux.dev> (raw)
In-Reply-To: <CAH2r5ms=53YHR41Y9qWozAtSO5UP4yqDN4myp-pju7WpP2WLjg@mail.gmail.com>

Hi Steve:

Thanks for your feedback.

I've been tied up with other tasks today and haven't had a
chance to dig into the details yet. My current understanding
is that these failures(213/485/568/701) are mostly around
CIFS fallocate semantics.

My swap series changes CIFS i_blocks accounting so that we
no longer treat EOF extension as real allocation. That makes
the swapfile hole check more accurate, but it can also expose
existing fallocate behavior where the server reports success
without actually allocating the requested range.

generic/568 expects a later write into a fallocated range not to 
increase st_blocks, and generic/701 also depends on fallocate/truncate 
reporting allocation correctly.

I also checked generic/213.  It passes in my setup.  With Samba
"strict allocate = yes", the server attempts to reserve space during
fallocate, so an allocation larger than the available space fails with
ENOSPC, which is what the test expects.

For generic/568, I did a temporary local experiment where CIFS requests 
an AllocationSize update after EOF-extending fallocate and then 
refreshes the cached allocation size. With that, generic/568 can pass 
locally.

So I need more time to understand and verify how CIFS should preserve 
the semantics of all fallocate modes before sending an updated patch.

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
>>
> 
> 


      parent reply	other threads:[~2026-06-08 15:28 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
2026-06-08 15:28     ` hehuiwen [this message]

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=927ef661-e562-436e-aca2-a772463da73e@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.