]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
smb/client: reduce fallocate zero buffer allocation
authorHuiwen He <hehuiwen@kylinos.cn>
Fri, 3 Jul 2026 05:32:57 +0000 (13:32 +0800)
committerSteve French <stfrench@microsoft.com>
Mon, 13 Jul 2026 15:37:55 +0000 (10:37 -0500)
commit9e4ec3be67af41ab859302d7109b34976efd9258
treec15adb91650468c25f10e2d7434f57d991b9db67
parentb09ae45d85dc816987a71db9eebc54b0ae288e94
smb/client: reduce fallocate zero buffer allocation

The fallocate emulation allocates a 1 MiB zero-filled buffer even
though each SMB2_write request is limited to SMB2_MAX_BUFFER_SIZE,
which is 64 KiB. A high-order 1 MiB allocation is more likely to
fail on a fragmented system.

Allocate only the smaller of the requested range and SMB2_MAX_BUFFER_SIZE,
and reuse that zero-filled buffer for every write request. Also reject
a successful write that makes no progress to avoid looping indefinitely.

This reduces the contiguous allocation required by fallocate emulation
without changing the written data or range semantics.

Signed-off-by: Huiwen He <hehuiwen@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/smb2ops.c