fuse: don't invalidate attrs when not using atime
authorAndrew Gallagher <andrewjcg@fb.com>
Tue, 5 Nov 2013 11:55:43 +0000 (03:55 -0800)
committerMiklos Szeredi <mszeredi@suse.cz>
Wed, 22 Jan 2014 18:36:58 +0000 (19:36 +0100)
Various read operations (e.g. readlink, readdir) invalidate the cached
attrs for atime changes.  This patch adds a new function
'fuse_invalidate_atime', which checks for a read-only super block and
avoids the attr invalidation in that case.

Signed-off-by: Andrew Gallagher <andrewjcg@fb.com>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
fs/fuse/dir.c
fs/fuse/file.c
fs/fuse/fuse_i.h

index c3eb2c46c8f1406b5b671dcfbb3b97868d3d86d0..1d1292c581c317ebaa16c54de9f9b85a75086f28 100644 (file)
@@ -112,6 +112,16 @@ void fuse_invalidate_attr(struct inode *inode)
        get_fuse_inode(inode)->i_time = 0;
 }
 
+/**
+ * Mark the attributes as stale due to an atime change.  Avoid the invalidate if
+ * atime is not used.
+ */
+void fuse_invalidate_atime(struct inode *inode)
+{
+       if (!IS_RDONLY(inode))
+               fuse_invalidate_attr(inode);
+}
+
 /*
  * Just mark the entry as stale, so that a next attempt to look it up
  * will result in a new lookup call to userspace
@@ -1371,7 +1381,7 @@ static int fuse_readdir(struct file *file, struct dir_context *ctx)
        }
 
        __free_page(page);
-       fuse_invalidate_attr(inode); /* atime changed */
+       fuse_invalidate_atime(inode);
        return err;
 }
 
@@ -1404,7 +1414,7 @@ static char *read_link(struct dentry *dentry)
                link[req->out.args[0].size] = '\0';
  out:
        fuse_put_request(fc, req);
-       fuse_invalidate_attr(inode); /* atime changed */
+       fuse_invalidate_atime(inode);
        return link;
 }
 
index 7e70506297bc4f6ca4c7afd61ca457627a9d1b3b..d53af8f15236ad40f8f6106d1c8b2f4b3fcc4fa7 100644 (file)
@@ -687,7 +687,7 @@ static int fuse_readpage(struct file *file, struct page *page)
                SetPageUptodate(page);
        }
 
-       fuse_invalidate_attr(inode); /* atime changed */
+       fuse_invalidate_atime(inode);
  out:
        unlock_page(page);
        return err;
@@ -716,7 +716,7 @@ static void fuse_readpages_end(struct fuse_conn *fc, struct fuse_req *req)
                        fuse_read_update_size(inode, pos,
                                              req->misc.read.attr_ver);
                }
-               fuse_invalidate_attr(inode); /* atime changed */
+               fuse_invalidate_atime(inode);
        }
 
        for (i = 0; i < req->num_pages; i++) {
index 7d2730912667e4514ef109c5ad9ece5584b6770b..dc44b9e3a0c9cbcd9a15ff62ae08520410465ab2 100644 (file)
@@ -788,6 +788,8 @@ void fuse_invalidate_attr(struct inode *inode);
 
 void fuse_invalidate_entry_cache(struct dentry *entry);
 
+void fuse_invalidate_atime(struct inode *inode);
+
 /**
  * Acquire reference to fuse_conn
  */