Skip to content

Commit

Permalink
fuse: don't invalidate attrs when not using atime
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andrew Gallagher authored and Miklos Szeredi committed Jan 22, 2014
1 parent 063ec1e commit 451418f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
14 changes: 12 additions & 2 deletions fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++) {
Expand Down
2 changes: 2 additions & 0 deletions fs/fuse/fuse_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 451418f

Please sign in to comment.