summaryrefslogtreecommitdiffstats
path: root/fs/fuse/fuse_i.h
diff options
context:
space:
mode:
authorMiklos Szeredi2018-10-01 10:07:04 +0200
committerMiklos Szeredi2018-10-01 10:07:04 +0200
commit5d7bc7e8680c7ca4c8a4f139ce2a54ccb8131ef0 (patch)
treee1d3c9478d7fb32a90e20ec02e55b0ff40a647b8 /fs/fuse/fuse_i.h
parentfuse: allow caching readdir (diff)
downloadkernel-qcow2-linux-5d7bc7e8680c7ca4c8a4f139ce2a54ccb8131ef0.tar.gz
kernel-qcow2-linux-5d7bc7e8680c7ca4c8a4f139ce2a54ccb8131ef0.tar.xz
kernel-qcow2-linux-5d7bc7e8680c7ca4c8a4f139ce2a54ccb8131ef0.zip
fuse: allow using readdir cache
The cache is only used if it's completed, not while it's still being filled; this constraint could be lifted later, if it turns out to be useful. Introduce state in struct fuse_file that indicates the position within the cache. After a seek, reset the position to the beginning of the cache and search the cache for the current position. If the current position is not found in the cache, then fall back to uncached readdir. It can also happen that page(s) disappear from the cache, in which case we must also fall back to uncached readdir. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/fuse/fuse_i.h')
-rw-r--r--fs/fuse/fuse_i.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index d2fa7588533e..49e42635e3ac 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -163,6 +163,21 @@ struct fuse_file {
/** Entry on inode's write_files list */
struct list_head write_entry;
+ /* Readdir related */
+ struct {
+ /*
+ * Protects below fields against (crazy) parallel readdir on
+ * same open file. Uncontended in the normal case.
+ */
+ struct mutex lock;
+
+ /* Dir stream position */
+ loff_t pos;
+
+ /* Offset in cache */
+ loff_t cache_off;
+ } readdir;
+
/** RB node to be linked on fuse_conn->polled_files */
struct rb_node polled_node;