Skip to contentSkip to conversation

fuse: cache readdir calls if filesystem opts out of opendir

PATCH Applied Chad Austin 2 participants 2 messages Jan 29, 2019 – Feb 4, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fuse: cache readdir calls if filesystem opts out of opendir

If a filesystem returns ENOSYS from opendir and thus opts out of opendir and releasedir requests, it almost certainly would also like readdir results cached. Default open_flags to FOPEN_KEEP_CACHE and FOPEN_CACHE_DIR in that case.

With this patch, I've measured recursive directory enumeration across large FUSE mounts to be faster than native mounts.

---
 fs/fuse/file.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/fuse/file.c +2 -1
index cc6ffd23b80f..06096b60f1df 100644
@@ -124,7 +124,8 @@ int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file,
 		return -ENOMEM;
 
 	ff->fh = 0;
-	ff->open_flags = FOPEN_KEEP_CACHE; /* Default for no-open */
+	/* Default for no-open */
+	ff->open_flags = FOPEN_KEEP_CACHE | (isdir ? FOPEN_CACHE_DIR : 0);
 	if (isdir ? !fc->no_opendir : !fc->no_open) {
 		struct fuse_open_out outarg;
 		int err;
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 10 lines · Chad Austin

If a filesystem returns ENOSYS from opendir and thus opts out of opendir and releasedir requests, it almost certainly would also like readdir results cached. Default open_flags to FOPEN_KEEP_CACHE and FOPEN_CACHE_DIR in that case.

With this patch, I've measured recursive directory enumeration across large FUSE mounts to be faster than native mounts.

Thanks, applied.

Miklos