linux/fs/nfs
Mike Snitzer 867da60d46 nfs: avoid i_lock contention in nfs_clear_invalid_mapping
Multi-threaded buffered reads to the same file exposed significant
inode spinlock contention in nfs_clear_invalid_mapping().

Eliminate this spinlock contention by checking flags without locking,
instead using smp_rmb and smp_load_acquire accordingly, but then take
spinlock and double-check these inode flags.

Also refactor nfs_set_cache_invalid() slightly to use
smp_store_release() to pair with nfs_clear_invalid_mapping()'s
smp_load_acquire().

While this fix is beneficial for all multi-threaded buffered reads
issued by an NFS client, this issue was identified in the context of
surprisingly low LOCALIO performance with 4K multi-threaded buffered
read IO.  This fix dramatically speeds up LOCALIO performance:

before: read: IOPS=1583k, BW=6182MiB/s (6482MB/s)(121GiB/20002msec)
after:  read: IOPS=3046k, BW=11.6GiB/s (12.5GB/s)(232GiB/20001msec)

Fixes: 17dfeb9113 ("NFS: Fix races in nfs_revalidate_mapping")
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
2024-11-04 10:24:19 -05:00
..
blocklayout
filelayout nfs: pass struct nfsd_file to nfs_init_pgio and nfs_init_commit 2024-09-23 15:03:30 -04:00
flexfilelayout pnfs/flexfiles: enable localio support 2024-09-23 15:03:30 -04:00
cache_lib.c
cache_lib.h
callback_proc.c
callback_xdr.c SUNRPC: Fix integer overflow in decode_rc_list() 2024-10-03 16:19:13 -04:00
callback.c sunrpc: allow svc threads to fail initialisation cleanly 2024-09-20 19:31:03 -04:00
callback.h
client.c nfs_common: fix localio to cope with racing nfs_local_probe() 2024-11-04 10:24:19 -05:00
delegation.c NFS: remove revoked delegation from server's delegation list 2024-10-09 15:39:22 -04:00
delegation.h
dir.c nfs: Annotate struct nfs_cache_array with __counted_by() 2024-09-23 15:03:12 -04:00
direct.c
dns_resolve.c
dns_resolve.h
export.c
file.c
fs_context.c nfs: add 'noalignwrite' option for lock-less 'lost writes' prevention 2024-09-23 15:03:13 -04:00
fscache.c netfs: Speed up buffered reading 2024-09-12 12:20:41 +02:00
fscache.h netfs: Speed up buffered reading 2024-09-12 12:20:41 +02:00
getroot.c nfs: fix the comment of nfs_get_root 2024-09-23 15:03:13 -04:00
inode.c nfs: avoid i_lock contention in nfs_clear_invalid_mapping 2024-11-04 10:24:19 -05:00
internal.h nfs/localio: use dedicated workqueues for filesystem read and write 2024-09-23 15:03:30 -04:00
io.c
iostat.h
Kconfig nfs_common: factor out nfs_errtbl and nfs_stat_to_errno 2024-09-23 15:03:29 -04:00
localio.c nfs_common: fix localio to cope with racing nfs_local_probe() 2024-11-04 10:24:19 -05:00
Makefile nfs: add LOCALIO support 2024-09-23 15:03:30 -04:00
mount_clnt.c
namespace.c
netns.h
nfs2super.c
nfs2xdr.c nfs_common: factor out nfs_errtbl and nfs_stat_to_errno 2024-09-23 15:03:29 -04:00
nfs3_fs.h
nfs3acl.c
nfs3client.c
nfs3proc.c
nfs3super.c
nfs3xdr.c nfs_common: factor out nfs_errtbl and nfs_stat_to_errno 2024-09-23 15:03:29 -04:00
nfs4_fs.h nfs: simplify and guarantee owner uniqueness. 2024-09-23 15:03:12 -04:00
nfs4client.c
nfs4file.c
nfs4getroot.c
nfs4idmap.c
nfs4idmap.h
nfs4namespace.c
nfs4proc.c NFS: Fix attribute delegation behaviour on exclusive create 2024-11-04 10:24:19 -05:00
nfs4renewd.c
nfs4session.c
nfs4session.h
nfs4state.c NFSv4: Prevent NULL-pointer dereference in nfs42_complete_copies() 2024-10-03 16:19:13 -04:00
nfs4super.c
nfs4sysctl.c
nfs4trace.c
nfs4trace.h
nfs4xdr.c NFS Client Updates for Linux 6.12 2024-09-24 15:44:18 -07:00
nfs42.h
nfs42proc.c NFSv4: Prevent NULL-pointer dereference in nfs42_complete_copies() 2024-10-03 16:19:13 -04:00
nfs42xattr.c
nfs42xdr.c
nfs.h
nfsroot.c
nfstrace.c
nfstrace.h nfs: add LOCALIO support 2024-09-23 15:03:30 -04:00
pagelist.c nfs: enable localio for non-pNFS IO 2024-09-23 15:03:30 -04:00
pnfs_dev.c
pnfs_nfs.c nfs: pass struct nfsd_file to nfs_init_pgio and nfs_init_commit 2024-09-23 15:03:30 -04:00
pnfs.c NFSv4: Fix clearing of layout segments in layoutreturn 2024-08-22 17:01:10 -04:00
pnfs.h
proc.c
read.c nfs: Remove unnecessary NULL check before kfree() 2024-09-23 15:03:12 -04:00
super.c NFSv3: only use NFS timeout for MOUNT when protocols are compatible 2024-11-04 10:24:18 -05:00
symlink.c
sysctl.c
sysfs.c
sysfs.h
unlink.c
write.c nfs: enable localio for non-pNFS IO 2024-09-23 15:03:30 -04:00