Skip to content

cifs: cache the directory content for shroot

Ronnie Sahlberg linux-cifs 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 0 repliesNew

V3 from the cover letter

* always take out shroot on the master tcon
* fix bug where we would still do one FindFirst even if we had everything cached

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3cifs: return cached_fid from open_shrootfs/cifs/smb2inode.c fs/cifs/smb2ops.c fs/cifs/smb2proto.h+23 -130 replies
2/3cifs: compute full_path already in cifs_readdir()fs/cifs/readdir.c+16 -140 replies
3/3cifs: cache the directory content for shrootfs/cifs/cifsglob.h fs/cifs/misc.c fs/cifs/readdir.c +1 more+205 -80 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3 V1] cifs: cache the directory content for shroot

Steve, Aurelien, List

Please find updated version.
With these patches we now server readdir() out of cache for shroot which eliminates at least three roundtrips:
* the initial Create+QueryDirectory
* the Query_Directory that fails with no more files
* the Close

Since we only cache name, inode and type we will still have the Create/GetInfo/Close calls for every direcotry member.
To solve that and eliminate those calls I chatted with Steve and we could cache all information about those child objects for ~1 second.

That would not plug into cifs_readdir() but in parts different parts of the cifs.ko code so it should into its own patch for
"fetch stat() data for objects from the directory cache, if available". That would be a different patch series.

V3:
* always take out shroot on the master tcon
* fix bug where we would still do one FindFirst even if we had everything cached

V2: addressing Aureliens comments
* Fix comment style
* Describe what ctx->pos == 2 means
* use is_smb1_server()

See initial implementation of a mechanism to cache the directory entries for
a shared cache handle (shroot).
We cache all the entries during the initial readdir() scan, using the context from the vfs layer as the key to handle if there are multiple concurrent readir() scans of the same directory.
Then if/when we have successfully cached the entire direcotry we will server any subsequent readdir() from out of cache, avoinding making any query direcotry calls to the server.

As with all of shroot, the cache is kept until the direcotry lease is broken.

The first two patches are small and just a preparation for the third patch. They go as separate patches to make review easier.
The third patch adds the actual meat of the dirent caching .

For now this might not be too exciting because the only cache the root handle. I hope in the future we will expand the directory caching to handle any/many direcotries.