[PATCH] fuse: more flexible caching
Make data caching behavior selectable on a per-open basis instead of
per-mount. Compatibility for the old mount options 'kernel_cache' and
'direct_io' is retained in the userspace library (version 2.4.0-pre1 or
later).
Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 2244535..a8dc885 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -12,6 +12,8 @@
#include <linux/slab.h>
#include <linux/kernel.h>
+static struct file_operations fuse_direct_io_file_operations;
+
int fuse_open_common(struct inode *inode, struct file *file, int isdir)
{
struct fuse_conn *fc = get_fuse_conn(inode);
@@ -70,12 +72,14 @@
else
request_send(fc, req);
err = req->out.h.error;
- if (!err && !(fc->flags & FUSE_KERNEL_CACHE))
- invalidate_inode_pages(inode->i_mapping);
if (err) {
fuse_request_free(ff->release_req);
kfree(ff);
} else {
+ if (!isdir && (outarg.open_flags & FOPEN_DIRECT_IO))
+ file->f_op = &fuse_direct_io_file_operations;
+ if (!(outarg.open_flags & FOPEN_KEEP_CACHE))
+ invalidate_inode_pages(inode->i_mapping);
ff->fh = outarg.fh;
file->private_data = ff;
}
@@ -544,12 +548,6 @@
void fuse_init_file_inode(struct inode *inode)
{
- struct fuse_conn *fc = get_fuse_conn(inode);
-
- if (fc->flags & FUSE_DIRECT_IO)
- inode->i_fop = &fuse_direct_io_file_operations;
- else {
- inode->i_fop = &fuse_file_operations;
- inode->i_data.a_ops = &fuse_file_aops;
- }
+ inode->i_fop = &fuse_file_operations;
+ inode->i_data.a_ops = &fuse_file_aops;
}