Commit b1009979 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Linus Torvalds

fuse: fix page invalidation

Other than truncate, there are two cases, when fuse tries to get rid
of cached pages:

 a) in open, if KEEP_CACHE flag is not set
 b) in getattr, if file size changed spontaneously

Until now invalidate_mapping_pages() were used, which didn't get rid
of mapped pages.  This is wrong, and becomes more wrong as dirty pages
are introduced.  So instead properly invalidate all pages with
invalidate_inode_pages2().
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e00d2c2d
...@@ -87,7 +87,7 @@ void fuse_finish_open(struct inode *inode, struct file *file, ...@@ -87,7 +87,7 @@ void fuse_finish_open(struct inode *inode, struct file *file,
if (outarg->open_flags & FOPEN_DIRECT_IO) if (outarg->open_flags & FOPEN_DIRECT_IO)
file->f_op = &fuse_direct_io_file_operations; file->f_op = &fuse_direct_io_file_operations;
if (!(outarg->open_flags & FOPEN_KEEP_CACHE)) if (!(outarg->open_flags & FOPEN_KEEP_CACHE))
invalidate_mapping_pages(inode->i_mapping, 0, -1); invalidate_inode_pages2(inode->i_mapping);
ff->fh = outarg->fh; ff->fh = outarg->fh;
file->private_data = fuse_file_get(ff); file->private_data = fuse_file_get(ff);
} }
......
...@@ -143,7 +143,7 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr) ...@@ -143,7 +143,7 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr)
if (S_ISREG(inode->i_mode) && oldsize != attr->size) { if (S_ISREG(inode->i_mode) && oldsize != attr->size) {
if (attr->size < oldsize) if (attr->size < oldsize)
fuse_truncate(inode->i_mapping, attr->size); fuse_truncate(inode->i_mapping, attr->size);
invalidate_mapping_pages(inode->i_mapping, 0, -1); invalidate_inode_pages2(inode->i_mapping);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment