]> git.dujemihanovic.xyz Git - linux.git/commit
cifs: Fix lack of credit renegotiation on read retry
authorDavid Howells <dhowells@redhat.com>
Thu, 22 Aug 2024 22:06:48 +0000 (23:06 +0100)
committerSteve French <stfrench@microsoft.com>
Wed, 28 Aug 2024 12:47:36 +0000 (07:47 -0500)
commit6a5dcd487791e0c2d86622064602a5c7459941ed
treef00c28fb7fbd09eba113a5c664df973e263ce43b
parent86987d84b968b69a610fd00ab9006c13db193b4e
cifs: Fix lack of credit renegotiation on read retry

When netfslib asks cifs to issue a read operation, it prefaces this with a
call to ->clamp_length() which cifs uses to negotiate credits, providing
receive capacity on the server; however, in the event that a read op needs
reissuing, netfslib doesn't call ->clamp_length() again as that could
shorten the subrequest, leaving a gap.

This causes the retried read to be done with zero credits which causes the
server to reject it with STATUS_INVALID_PARAMETER.  This is a problem for a
DIO read that is requested that would go over the EOF.  The short read will
be retried, causing EINVAL to be returned to the user when it fails.

Fix this by making cifs_req_issue_read() negotiate new credits if retrying
(NETFS_SREQ_RETRYING now gets set in the read side as well as the write
side in this instance).

This isn't sufficient, however: the new credits might not be sufficient to
complete the remainder of the read, so also add an additional field,
rreq->actual_len, that holds the actual size of the op we want to perform
without having to alter subreq->len.

We then rely on repeated short reads being retried until we finish the read
or reach the end of file and make a zero-length read.

Also fix a couple of places where the subrequest start and length need to
be altered by the amount so far transferred when being used.

Fixes: 69c3c023af25 ("cifs: Implement netfslib hooks")
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Steve French <sfrench@samba.org>
cc: Paulo Alcantara <pc@manguebit.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: linux-cifs@vger.kernel.org
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/netfs/io.c
fs/smb/client/cifsglob.h
fs/smb/client/file.c
fs/smb/client/smb2ops.c
fs/smb/client/smb2pdu.c
fs/smb/client/trace.h