Skip to content

nfsd: open file caching for v2/3

Jeff Layton linux-nfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest18 patches 33 repliesIn review
  2. v19 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- changelog cleanups and clarifications
- allow COMMIT to use cached open files
- tracepoints for nfsd_file cache
- proactively close open files prior to REMOVE, or a RENAME over a positive dentry

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/18nfsd: include linux/nfs4.h in export.hfs/nfsd/export.h+1 -01 reply
2/18nfsd: move some file caching helpers to a common headerfs/nfsd/filecache.h fs/nfsd/nfs4state.c+27 -153 replies
3/18nfsd: convert laundry_wq to something less nfsd4 specificfs/nfsd/nfs4state.c fs/nfsd/nfsd.h fs/nfsd/nfssvc.c+19 -199 replies
4/18nfsd: add a new struct file caching facility to nfsdfs/nfsd/Makefile fs/nfsd/filecache.c fs/nfsd/filecache.h +1 more+365 -29 replies
5/18nfsd: hook up nfsd_write to the new nfsd_file cachefs/nfsd/nfs3proc.c fs/nfsd/nfsproc.c fs/nfsd/vfs.c +1 more+14 -260 replies
6/18nfsd: hook up nfsd_read to the nfsd_file cachefs/nfsd/vfs.c+7 -133 replies
7/18sunrpc: add a new cache_detail operation for when a cache is flushedinclude/linux/sunrpc/cache.h net/sunrpc/cache.c+4 -00 replies
8/18nfsd: add a ->flush routine to svc_export_cachefs/nfsd/export.c fs/nfsd/filecache.c fs/nfsd/filecache.h+40 -140 replies
9/18nfsd: allow the file cache expire time to be tunablefs/nfsd/filecache.c+9 -50 replies
10/18nfsd: handle NFSD_MAY_NOT_BREAK_LEASE in open file cachefs/nfsd/filecache.c fs/nfsd/filecache.h fs/nfsd/vfs.c +1 more+41 -50 replies
11/18nfsd: hook nfsd_commit up to the nfsd_file cachefs/nfsd/vfs.c+7 -70 replies
12/18nfsd: move include of state.h from trace.c to trace.hfs/nfsd/trace.c fs/nfsd/trace.h+2 -21 reply
13/18nfsd: add new tracepoints for nfsd_file cachefs/nfsd/filecache.c fs/nfsd/trace.h+115 -30 replies
14/18nfsd: have _fh_update take a knfsd_fh instead of a svc_fhfs/nfsd/nfsfh.c+12 -101 reply
15/18nfsd: have set_version_and_fsid_type take a knfsd_fh instead of svc_fhfs/nfsd/nfsfh.c+8 -51 reply
16/18nfsd: add a fh_compose_shallowfs/nfsd/nfsfh.c fs/nfsd/nfsfh.h+60 -545 replies
17/18nfsd: close cached files prior to a REMOVE or RENAME that would replace targetfs/nfsd/filecache.c fs/nfsd/filecache.h fs/nfsd/trace.h +1 more+66 -20 replies
18/18nfsd: call flush_delayed_fput from nfsd_file_close_fhfs/file_table.c fs/nfsd/filecache.c fs/nfsd/filecache.h +2 more+87 -100 replies

Reviews trailers per patch

5 of 18 patches have a Reviewed-by or Acked-by.

PatchChristoph Hellwig
1/18R-b
2/18R-b
3/18
4/18
5/18
6/18
7/18
8/18
9/18
10/18
11/18
12/18R-b
13/18
14/18R-b
15/18R-b
16/18
17/18
18/18

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 00/18] nfsd: open file caching for v2/3

v2:
- changelog cleanups and clarifications
- allow COMMIT to use cached open files
- tracepoints for nfsd_file cache
- proactively close open files prior to REMOVE, or a RENAME over a positive dentry

This is the v2 set of this series. It's a little larger than the v1 series, but adds a bit more functionality.

The last several patches you may be less-inclined to take. Since one of our use-cases is a reexporter for NFS, we want to avoid triggering sillyrenames when possible. Closing files proactively prior to a REMOVE or RENAME is something we want to do. I'm less sure however whether it's something you'll want to bother with for more general uses. Your call there.

I'd still like to see this merged for v4.3 if possible.

Original cover letter follows:

---------------------[snip]------------------------

Hi Bruce!

This patchset adds a new open file cache for knfsd. As you well know, nfsd basically does an open() - read/write() - close() cycle for every nfsv3 READ or WRITE. It's also common for clients to "spray" several read and write requests in parallel or in quick succession, so we could skip a lot of that by simply caching these open filps.

The idea here is to cache them in a hashtable for a little while (1s by default) in the expectation that clients may try to issue more reads or writes in quick succession. When there are any entries in the hashtable, there is a recurring workqueue job that will clean the cache.

I've also added some hooks into sunrpc cache code that should allow us to purge the cache on an unexport event, so this shouldn't cause any problems with unmounting once you've unexported the fs.

I did a little testing with it, but my test rig is pretty slow, and I couldn't measure much of a performance difference on a bog standard local fs.

We do have some patches that allow the reexporting of NFSv4.1 via knfsd. Since NFS has a relatively slow open routine, this provides a rather large speedup.

Without these patches:

$ dd if=/dev/urandom of=/mnt/dp01/ddfile bs=4k count=256 oflag=direct
256+0 records in
256+0 records out
1048576 bytes (1.0 MB) copied, 54.3109 s, 19.3 kB/s

With these patches:

$ dd if=/dev/urandom of=/mnt/dp01/ddfile bs=4k count=256 oflag=direct
256+0 records in
256+0 records out
1048576 bytes (1.0 MB) copied, 1.05437 s, 995 kB/s

It should also be possible to hook this code up to the nfs4_file too, but I haven't done that in this set. I'd like to get this in and settled before we start looking at that, since it'll mean a bit of reengineering of the NFSv4 code not to pass around struct file pointers.

I'd like to have these considered for the v4.3 merge window if they look reasonable.

Jeff Layton (18):
nfsd: include linux/nfs4.h in export.h
nfsd: move some file caching helpers to a common header
nfsd: convert laundry_wq to something less nfsd4 specific
nfsd: add a new struct file caching facility to nfsd
nfsd: hook up nfsd_write to the new nfsd_file cache
nfsd: hook up nfsd_read to the nfsd_file cache
sunrpc: add a new cache_detail operation for when a cache is flushed
nfsd: add a ->flush routine to svc_export_cache
nfsd: allow the file cache expire time to be tunable
nfsd: handle NFSD_MAY_NOT_BREAK_LEASE in open file cache
nfsd: hook nfsd_commit up to the nfsd_file cache
nfsd: move include of state.h from trace.c to trace.h
nfsd: add new tracepoints for nfsd_file cache
nfsd: have _fh_update take a knfsd_fh instead of a svc_fh
nfsd: have set_version_and_fsid_type take a knfsd_fh instead of svc_fh
nfsd: add a fh_compose_shallow
nfsd: close cached files prior to a REMOVE or RENAME that would
replace target
nfsd: call flush_delayed_fput from nfsd_file_close_fh

 fs/file_table.c              |   1 +
 fs/nfsd/Makefile             |   3 +-
 fs/nfsd/export.c             |  14 ++
 fs/nfsd/export.h             |   1 +
 fs/nfsd/filecache.c          | 451 +++++++++++++++++++++++++++++++++++++++++++
 fs/nfsd/filecache.h          |  51 +++++
 fs/nfsd/nfs3proc.c           |   2 +-
 fs/nfsd/nfs4state.c          |  40 +---
 fs/nfsd/nfsd.h               |   1 +
 fs/nfsd/nfsfh.c              | 139 ++++++-------
 fs/nfsd/nfsfh.h              |   2 +
 fs/nfsd/nfsproc.c            |   2 +-
 fs/nfsd/nfssvc.c             |  22 ++-
 fs/nfsd/trace.c              |   2 -
 fs/nfsd/trace.h              | 126 ++++++++++++
 fs/nfsd/vfs.c                | 146 ++++++++------
 fs/nfsd/vfs.h                |   3 +-
 include/linux/sunrpc/cache.h |   1 +
 net/sunrpc/cache.c           |   3 +
 19 files changed, 851 insertions(+), 159 deletions(-)
 create mode 100644 fs/nfsd/filecache.c
 create mode 100644 fs/nfsd/filecache.h
Signature · 1 line
2.4.3