]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/2.6.36.2/fuse-fix-attributes-after-open-o_trunc.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / releases / 2.6.36.2 / fuse-fix-attributes-after-open-o_trunc.patch
CommitLineData
d9b1f36d
GKH
1From a0822c55779d9319939eac69f00bb729ea9d23da Mon Sep 17 00:00:00 2001
2From: Ken Sumrall <ksumrall@android.com>
3Date: Wed, 24 Nov 2010 12:57:00 -0800
4Subject: fuse: fix attributes after open(O_TRUNC)
5
6From: Ken Sumrall <ksumrall@android.com>
7
8commit a0822c55779d9319939eac69f00bb729ea9d23da upstream.
9
10The attribute cache for a file was not being cleared when a file is opened
11with O_TRUNC.
12
13If the filesystem's open operation truncates the file ("atomic_o_trunc"
14feature flag is set) then the kernel should invalidate the cached st_mtime
15and st_ctime attributes.
16
17Also i_size should be explicitly be set to zero as it is used sometimes
18without refreshing the cache.
19
20Signed-off-by: Ken Sumrall <ksumrall@android.com>
21Cc: Anfei <anfei.zhou@gmail.com>
22Cc: "Anand V. Avati" <avati@gluster.com>
23Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
24Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
25Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
26Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
27
28---
29 fs/fuse/file.c | 10 ++++++++++
30 1 file changed, 10 insertions(+)
31
32--- a/fs/fuse/file.c
33+++ b/fs/fuse/file.c
34@@ -134,6 +134,7 @@ EXPORT_SYMBOL_GPL(fuse_do_open);
35 void fuse_finish_open(struct inode *inode, struct file *file)
36 {
37 struct fuse_file *ff = file->private_data;
38+ struct fuse_conn *fc = get_fuse_conn(inode);
39
40 if (ff->open_flags & FOPEN_DIRECT_IO)
41 file->f_op = &fuse_direct_io_file_operations;
42@@ -141,6 +142,15 @@ void fuse_finish_open(struct inode *inod
43 invalidate_inode_pages2(inode->i_mapping);
44 if (ff->open_flags & FOPEN_NONSEEKABLE)
45 nonseekable_open(inode, file);
46+ if (fc->atomic_o_trunc && (file->f_flags & O_TRUNC)) {
47+ struct fuse_inode *fi = get_fuse_inode(inode);
48+
49+ spin_lock(&fc->lock);
50+ fi->attr_version = ++fc->attr_version;
51+ i_size_write(inode, 0);
52+ spin_unlock(&fc->lock);
53+ fuse_invalidate_attr(inode);
54+ }
55 }
56
57 int fuse_open_common(struct inode *inode, struct file *file, bool isdir)