• David Howells's avatar
    netfs, cifs: Fix handling of short DIO read · 1da29f2c
    David Howells authored
    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: 69c3c023 ("cifs: Implement netfslib hooks")
    Signed-off-by: default avatarDavid 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: default avatarSteve French <stfrench@microsoft.com>
    1da29f2c
smb2pdu.c 171 KB