linux/fs/nfs
Dominique Martinet e3786b29c5
9p: Fix DIO read through netfs
If a program is watching a file on a 9p mount, it won't see any change in
size if the file being exported by the server is changed directly in the
source filesystem, presumably because 9p doesn't have change notifications,
and because netfs skips the reads if the file is empty.

Fix this by attempting to read the full size specified when a DIO read is
requested (such as when 9p is operating in unbuffered mode) and dealing
with a short read if the EOF was less than the expected read.

To make this work, filesystems using netfslib must not set
NETFS_SREQ_CLEAR_TAIL if performing a DIO read where that read hit the EOF.
I don't want to mandatorily clear this flag in netfslib for DIO because,
say, ceph might make a read from an object that is not completely filled,
but does not reside at the end of file - and so we need to clear the
excess.

This can be tested by watching an empty file over 9p within a VM (such as
in the ktest framework):

        while true; do read content; if [ -n "$content" ]; then echo $content; break; fi; done < /host/tmp/foo

then writing something into the empty file.  The watcher should immediately
display the file content and break out of the loop.  Without this fix, it
remains in the loop indefinitely.

Fixes: 80105ed2fd ("9p: Use netfslib read/write_iter")
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218916
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/1229195.1723211769@warthog.procyon.org.uk
cc: Eric Van Hensbergen <ericvh@kernel.org>
cc: Latchesar Ionkov <lucho@ionkov.net>
cc: Christian Schoenebeck <linux_oss@crudebyte.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Ilya Dryomov <idryomov@gmail.com>
cc: Steve French <sfrench@samba.org>
cc: Paulo Alcantara <pc@manguebit.com>
cc: Trond Myklebust <trond.myklebust@hammerspace.com>
cc: v9fs@lists.linux.dev
cc: linux-afs@lists.infradead.org
cc: ceph-devel@vger.kernel.org
cc: linux-cifs@vger.kernel.org
cc: linux-nfs@vger.kernel.org
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2024-08-13 13:53:09 +02:00
..
blocklayout nfs/blocklayout: add support for NVMe 2024-07-12 11:35:50 -04:00
filelayout nfs: remove dead code for the old swap over NFS implementation 2024-07-08 13:47:51 -04:00
flexfilelayout NFSv4/pNFS: Do layout state recovery upon reboot 2024-07-08 13:47:26 -04:00
cache_lib.c
cache_lib.h
callback_proc.c pNFS: Add a flag argument to pnfs_destroy_layouts_byclid() 2024-07-08 13:47:26 -04:00
callback_xdr.c NFSv4: Add CB_GETATTR support for delegated attributes 2024-07-08 13:47:25 -04:00
callback.c nfsd: stop setting ->pg_stats for unused stats 2024-03-01 09:12:08 -05:00
callback.h NFSv4: Add CB_GETATTR support for delegated attributes 2024-07-08 13:47:25 -04:00
client.c nfs: Block on write congestion 2024-07-08 13:47:27 -04:00
delegation.c NFSv4: Delegreturn must set m/atime when they are delegated 2024-07-08 13:47:25 -04:00
delegation.h NFSv4: Delegreturn must set m/atime when they are delegated 2024-07-08 13:47:25 -04:00
dir.c NFSv4: Add a flags argument to the 'have_delegation' callback 2024-07-08 13:47:25 -04:00
direct.c nfs: drop the incorrect assertion in nfs_swap_rw() 2024-06-24 20:52:11 -07:00
dns_resolve.c NFS: Move common includes outside ifdef 2023-08-24 13:24:15 -04:00
dns_resolve.h
export.c
file.c - 875fa64577da ("mm/hugetlb_vmemmap: fix race with speculative PFN 2024-07-21 17:15:46 -07:00
fs_context.c nfs: keep server info for remounts 2024-05-20 11:37:15 -04:00
fscache.c 9p: Fix DIO read through netfs 2024-08-13 13:53:09 +02:00
fscache.h netfs: Fix handling of USE_PGPRIV2 and WRITE_TO_CACHE flags 2024-08-12 22:03:27 +02:00
getroot.c
inode.c NFSv4: Fix up delegated attributes in nfs_setattr 2024-07-08 13:47:25 -04:00
internal.h nfs: remove nfs_page_length 2024-07-10 13:28:06 -04:00
io.c
iostat.h mm: add comments for allocation helpers explaining why they are macros 2024-07-12 15:52:20 -07:00
Kconfig NFS: Don't enable NFS v2 by default 2024-05-20 11:37:15 -04:00
Makefile
mount_clnt.c NFS: remove unused struct 'mnt_fhstatus' 2024-07-08 13:47:24 -04:00
namespace.c fs: pass the request_mask to generic_fillattr 2023-08-09 08:56:36 +02:00
netns.h nfs: make the rpc_stat per net namespace 2024-03-09 09:14:51 -05:00
nfs2super.c fs: nfs: add missing MODULE_DESCRIPTION() macros 2024-07-08 13:47:24 -04:00
nfs2xdr.c NFS: Guard against READDIR loop when entry names exceed MAXNAMELEN 2023-08-30 11:08:27 -04:00
nfs3_fs.h
nfs3acl.c
nfs3client.c NFS: enable nconnect for RDMA 2024-03-09 09:14:51 -05:00
nfs3proc.c Return the delegation when deleting sillyrenamed files 2024-07-08 13:47:26 -04:00
nfs3super.c fs: nfs: add missing MODULE_DESCRIPTION() macros 2024-07-08 13:47:24 -04:00
nfs3xdr.c NFS: Guard against READDIR loop when entry names exceed MAXNAMELEN 2023-08-30 11:08:27 -04:00
nfs4_fs.h NFSv4.1: constify the stateid argument in nfs41_test_stateid() 2024-07-08 13:47:26 -04:00
nfs4client.c NFSv4.1 another fix for EXCHGID4_FLAG_USE_PNFS_DS for DS server 2024-07-08 13:47:27 -04:00
nfs4file.c filelock: split leases out of struct file_lock 2024-02-05 13:11:44 +01:00
nfs4getroot.c
nfs4idmap.c
nfs4idmap.h
nfs4namespace.c
nfs4proc.c NFSv4.1 another fix for EXCHGID4_FLAG_USE_PNFS_DS for DS server 2024-07-08 13:47:27 -04:00
nfs4renewd.c
nfs4session.c
nfs4session.h
nfs4state.c NFSv4/pNFS: Do layout state recovery upon reboot 2024-07-08 13:47:26 -04:00
nfs4super.c fs: nfs: add missing MODULE_DESCRIPTION() macros 2024-07-08 13:47:24 -04:00
nfs4sysctl.c fs: Remove the now superfluous sentinel elements from ctl_table array 2023-12-28 04:57:57 -08:00
nfs4trace.c nfs/blocklayout: SCSI layout trace points for reservation key reg/unreg 2024-07-08 13:47:27 -04:00
nfs4trace.h nfs/blocklayout: SCSI layout trace points for reservation key reg/unreg 2024-07-08 13:47:27 -04:00
nfs4xdr.c NFSv4: Clean up encode_nfs4_stateid() 2024-07-08 13:47:26 -04:00
nfs42.h NFSv4.2: fix listxattr maximum XDR buffer size 2024-02-28 16:18:18 -05:00
nfs42proc.c nfs42: client needs to strip file mode's suid/sgid bit after ALLOCATE op 2023-10-11 09:37:48 -04:00
nfs42xattr.c mm, slab: remove last vestiges of SLAB_MEM_SPREAD 2024-03-12 20:32:19 -07:00
nfs42xdr.c NFSv4.2: Rework scratch handling for READ_PLUS (again) 2023-08-23 15:58:47 -04:00
nfs.h nfs: move nfs4_xattr_handlers to .rodata 2023-10-09 16:24:20 +02:00
nfsroot.c NFS: Fix an off by one in root_nfs_cat() 2024-03-09 09:14:51 -05:00
nfstrace.c
nfstrace.h nfs: pass explicit offset/count to trace events 2024-07-17 13:15:35 -04:00
pagelist.c nfs: move nfs_wait_on_request to write.c 2024-07-08 13:47:51 -04:00
pnfs_dev.c nfs: remove the unused max_deviceinfo_size field from struct pnfs_layoutdriver_type 2024-07-10 13:23:17 -04:00
pnfs_nfs.c nfs: remove dead code for the old swap over NFS implementation 2024-07-08 13:47:51 -04:00
pnfs.c NFSv4/pNFS: Do layout state recovery upon reboot 2024-07-08 13:47:26 -04:00
pnfs.h nfs: remove the unused max_deviceinfo_size field from struct pnfs_layoutdriver_type 2024-07-10 13:23:17 -04:00
proc.c Return the delegation when deleting sillyrenamed files 2024-07-08 13:47:26 -04:00
read.c NFS Client Updates for Linux 6.11 2024-07-18 17:17:30 -07:00
super.c NFS: make sure lock/nolock overriding local_lock mount option 2024-05-20 11:10:27 -04:00
symlink.c nfs: Remove calls to folio_set_error 2024-05-31 12:31:41 +02:00
sysctl.c fs: Remove the now superfluous sentinel elements from ctl_table array 2023-12-28 04:57:57 -08:00
sysfs.c NFS: Fix sysfs server name memory leak 2023-08-19 10:26:29 -04:00
sysfs.h NFS: Add sysfs links to sunrpc clients for nfs_clients 2023-06-19 15:04:13 -04:00
unlink.c Return the delegation when deleting sillyrenamed files 2024-07-08 13:47:26 -04:00
write.c - 875fa64577da ("mm/hugetlb_vmemmap: fix race with speculative PFN 2024-07-21 17:15:46 -07:00