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>
This commit is contained in:
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user