aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fuse
diff options
context:
space:
mode:
authorKen Sumrall <ksumrall@android.com>2010-11-24 15:57:00 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-11-24 16:50:41 -0500
commita0822c55779d9319939eac69f00bb729ea9d23da (patch)
treea12ff25e7718bb04ac2f85c672c9f9c370a8b167 /fs/fuse
parentc22c7aeff69796f46ae0fcec141538e28f50b24e (diff)
fuse: fix attributes after open(O_TRUNC)
The attribute cache for a file was not being cleared when a file is opened with O_TRUNC. If the filesystem's open operation truncates the file ("atomic_o_trunc" feature flag is set) then the kernel should invalidate the cached st_mtime and st_ctime attributes. Also i_size should be explicitly be set to zero as it is used sometimes without refreshing the cache. Signed-off-by: Ken Sumrall <ksumrall@android.com> Cc: Anfei <anfei.zhou@gmail.com> Cc: "Anand V. Avati" <avati@gluster.com> Signed-off-by: Miklos Szeredi <miklos@szeredi.hu> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/fuse')
-rw-r--r--fs/fuse/file.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index c8224587123f..9242d294fe90 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -134,6 +134,7 @@ EXPORT_SYMBOL_GPL(fuse_do_open);
134void fuse_finish_open(struct inode *inode, struct file *file) 134void fuse_finish_open(struct inode *inode, struct file *file)
135{ 135{
136 struct fuse_file *ff = file->private_data; 136 struct fuse_file *ff = file->private_data;
137 struct fuse_conn *fc = get_fuse_conn(inode);
137 138
138 if (ff->open_flags & FOPEN_DIRECT_IO) 139 if (ff->open_flags & FOPEN_DIRECT_IO)
139 file->f_op = &fuse_direct_io_file_operations; 140 file->f_op = &fuse_direct_io_file_operations;
@@ -141,6 +142,15 @@ void fuse_finish_open(struct inode *inode, struct file *file)
141 invalidate_inode_pages2(inode->i_mapping); 142 invalidate_inode_pages2(inode->i_mapping);
142 if (ff->open_flags & FOPEN_NONSEEKABLE) 143 if (ff->open_flags & FOPEN_NONSEEKABLE)
143 nonseekable_open(inode, file); 144 nonseekable_open(inode, file);
145 if (fc->atomic_o_trunc && (file->f_flags & O_TRUNC)) {
146 struct fuse_inode *fi = get_fuse_inode(inode);
147
148 spin_lock(&fc->lock);
149 fi->attr_version = ++fc->attr_version;
150 i_size_write(inode, 0);
151 spin_unlock(&fc->lock);
152 fuse_invalidate_attr(inode);
153 }
144} 154}
145 155
146int fuse_open_common(struct inode *inode, struct file *file, bool isdir) 156int fuse_open_common(struct inode *inode, struct file *file, bool isdir)