aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gallagher <andrewjcg@fb.com>2013-11-05 06:55:43 -0500
committerMiklos Szeredi <mszeredi@suse.cz>2014-01-22 13:36:58 -0500
commit451418fc928b5ec1ee96a9afac807b6312811a2a (patch)
tree447f2e957ae82c8e3701bd7f9b127aef564bd4a2
parent063ec1e595f8a82b5a8fd0acb3e88c8b49a1e6c1 (diff)
fuse: don't invalidate attrs when not using atime
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>
-rw-r--r--fs/fuse/dir.c14
-rw-r--r--fs/fuse/file.c4
-rw-r--r--fs/fuse/fuse_i.h2
3 files changed, 16 insertions, 4 deletions
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index c3eb2c46c8f1..1d1292c581c3 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -112,6 +112,16 @@ void fuse_invalidate_attr(struct inode *inode)
112 get_fuse_inode(inode)->i_time = 0; 112 get_fuse_inode(inode)->i_time = 0;
113} 113}
114 114
115/**
116 * Mark the attributes as stale due to an atime change. Avoid the invalidate if
117 * atime is not used.
118 */
119void fuse_invalidate_atime(struct inode *inode)
120{
121 if (!IS_RDONLY(inode))
122 fuse_invalidate_attr(inode);
123}
124
115/* 125/*
116 * Just mark the entry as stale, so that a next attempt to look it up 126 * Just mark the entry as stale, so that a next attempt to look it up
117 * will result in a new lookup call to userspace 127 * will result in a new lookup call to userspace
@@ -1371,7 +1381,7 @@ static int fuse_readdir(struct file *file, struct dir_context *ctx)
1371 } 1381 }
1372 1382
1373 __free_page(page); 1383 __free_page(page);
1374 fuse_invalidate_attr(inode); /* atime changed */ 1384 fuse_invalidate_atime(inode);
1375 return err; 1385 return err;
1376} 1386}
1377 1387
@@ -1404,7 +1414,7 @@ static char *read_link(struct dentry *dentry)
1404 link[req->out.args[0].size] = '\0'; 1414 link[req->out.args[0].size] = '\0';
1405 out: 1415 out:
1406 fuse_put_request(fc, req); 1416 fuse_put_request(fc, req);
1407 fuse_invalidate_attr(inode); /* atime changed */ 1417 fuse_invalidate_atime(inode);
1408 return link; 1418 return link;
1409} 1419}
1410 1420
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 7e70506297bc..d53af8f15236 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -687,7 +687,7 @@ static int fuse_readpage(struct file *file, struct page *page)
687 SetPageUptodate(page); 687 SetPageUptodate(page);
688 } 688 }
689 689
690 fuse_invalidate_attr(inode); /* atime changed */ 690 fuse_invalidate_atime(inode);
691 out: 691 out:
692 unlock_page(page); 692 unlock_page(page);
693 return err; 693 return err;
@@ -716,7 +716,7 @@ static void fuse_readpages_end(struct fuse_conn *fc, struct fuse_req *req)
716 fuse_read_update_size(inode, pos, 716 fuse_read_update_size(inode, pos,
717 req->misc.read.attr_ver); 717 req->misc.read.attr_ver);
718 } 718 }
719 fuse_invalidate_attr(inode); /* atime changed */ 719 fuse_invalidate_atime(inode);
720 } 720 }
721 721
722 for (i = 0; i < req->num_pages; i++) { 722 for (i = 0; i < req->num_pages; i++) {
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 7d2730912667..dc44b9e3a0c9 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -788,6 +788,8 @@ void fuse_invalidate_attr(struct inode *inode);
788 788
789void fuse_invalidate_entry_cache(struct dentry *entry); 789void fuse_invalidate_entry_cache(struct dentry *entry);
790 790
791void fuse_invalidate_atime(struct inode *inode);
792
791/** 793/**
792 * Acquire reference to fuse_conn 794 * Acquire reference to fuse_conn
793 */ 795 */