]> www.infradead.org Git - users/jedix/linux-maple.git/commit
smb: client: Store original IO parameters and prevent zero IO sizes
authorWang Zhaolong <wangzhaolong1@huawei.com>
Mon, 31 Mar 2025 13:33:14 +0000 (21:33 +0800)
committerSteve French <stfrench@microsoft.com>
Tue, 1 Apr 2025 02:12:31 +0000 (21:12 -0500)
commit287906b20035a04a234d1a3c64f760a5678387be
tree8e924fdefe6b0aad8cfde203138902d07d0b88a5
parenta091d9711bdee46a76fa14fad31cb261a6dad74a
smb: client: Store original IO parameters and prevent zero IO sizes

During mount option processing and negotiation with the server, the
original user-specified rsize/wsize values were being modified directly.
This makes it impossible to recover these values after a connection
reset, leading to potential degraded performance after reconnection.

The other problem is that When negotiating read and write sizes, there are
cases where the negotiated values might calculate to zero, especially
during reconnection when server->max_read or server->max_write might be
reset. In general, these values come from the negotiation response.
According to MS-SMB2 specification, these values should be at least 65536
bytes.

This patch improves IO parameter handling:

1. Adds vol_rsize and vol_wsize fields to store the original user-specified
   values separately from the negotiated values
2. Uses got_rsize/got_wsize flags to determine if values were
   user-specified rather than checking for non-zero values, which is more
   reliable
3. Adds a prevent_zero_iosize() helper function to ensure IO sizes are
   never negotiated down to zero, which could happen in edge cases like
   when server->max_read/write is zero

The changes make the CIFS client more resilient to unusual server
responses and reconnection scenarios, preventing potential failures
when IO sizes are calculated to be zero.

Signed-off-by: Wang Zhaolong <wangzhaolong1@huawei.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/fs_context.c
fs/smb/client/fs_context.h
fs/smb/client/smb1ops.c
fs/smb/client/smb2ops.c
fs/smb/common/smb2pdu.h