]> git.dujemihanovic.xyz Git - linux.git/commit
netfs, cifs: Fix handling of short DIO read
authorDavid Howells <dhowells@redhat.com>
Thu, 22 Aug 2024 22:06:49 +0000 (23:06 +0100)
committerSteve French <stfrench@microsoft.com>
Wed, 28 Aug 2024 12:47:36 +0000 (07:47 -0500)
commit1da29f2c39b67b846b74205c81bf0ccd96d34727
treeaa1da79c2709eba48da12b38c6738e99100445ca
parent6a5dcd487791e0c2d86622064602a5c7459941ed
netfs, cifs: Fix handling of short DIO read

Short DIO reads, particularly in relation to cifs, are not being handled
correctly by cifs and netfslib.  This can be tested by doing a DIO read of
a file where the size of read is larger than the size of the file.  When it
crosses the EOF, it gets a short read and this gets retried, and in the
case of cifs, the retry read fails, with the failure being translated to
ENODATA.

Fix this by the following means:

 (1) Add a flag, NETFS_SREQ_HIT_EOF, for the filesystem to set when it
     detects that the read did hit the EOF.

 (2) Make the netfslib read assessment stop processing subrequests when it
     encounters one with that flag set.

 (3) Return rreq->transferred, the accumulated contiguous amount read to
     that point, to userspace for a DIO read.

 (4) Make cifs set the flag and clear the error if the read RPC returned
     ENODATA.

 (5) Make cifs set the flag and clear the error if a short read occurred
     without error and the read-to file position is now at the remote inode
     size.

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/smb2pdu.c
include/linux/netfs.h