aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2018-02-08 09:17:38 -0500
committerMiklos Szeredi <mszeredi@redhat.com>2018-03-20 12:11:43 -0400
commitdf0e91d488276086bc07da2e389986cae0048c37 (patch)
treeb02f6993a75e9f16f10299613e6e9e7ff51869ae
parentc698ca5278934c0ae32297a8725ced2e27585d7f (diff)
fuse: atomic_o_trunc should truncate pagecache
Fuse has an "atomic_o_trunc" mode, where userspace filesystem uses the O_TRUNC flag in the OPEN request to truncate the file atomically with the open. In this mode there's no need to send a SETATTR request to userspace after the open, so fuse_do_setattr() checks this mode and returns. But this misses the important step of truncating the pagecache. Add the missing parts of truncation to the ATTR_OPEN branch. Reported-by: Chad Austin <chadaustin@fb.com> Fixes: 6ff958edbf39 ("fuse: add atomic open+truncate support") Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Cc: <stable@vger.kernel.org>
-rw-r--r--fs/fuse/dir.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 24967382a7b1..7a980b4462d9 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1629,8 +1629,19 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
1629 return err; 1629 return err;
1630 1630
1631 if (attr->ia_valid & ATTR_OPEN) { 1631 if (attr->ia_valid & ATTR_OPEN) {
1632 if (fc->atomic_o_trunc) 1632 /* This is coming from open(..., ... | O_TRUNC); */
1633 WARN_ON(!(attr->ia_valid & ATTR_SIZE));
1634 WARN_ON(attr->ia_size != 0);
1635 if (fc->atomic_o_trunc) {
1636 /*
1637 * No need to send request to userspace, since actual
1638 * truncation has already been done by OPEN. But still
1639 * need to truncate page cache.
1640 */
1641 i_size_write(inode, 0);
1642 truncate_pagecache(inode, 0);
1633 return 0; 1643 return 0;
1644 }
1634 file = NULL; 1645 file = NULL;
1635 } 1646 }
1636 1647