diff options
author | Miklos Szeredi <mszeredi@redhat.com> | 2018-02-08 15:17:38 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-07-03 11:23:07 +0200 |
commit | ebdc37febe594035d8cf3f5424ce97a926d2cddf (patch) | |
tree | c9dbe9b95819424c391f800c95002379d82118a4 /fs/fuse | |
parent | f1e9a633e660cbb792c2bc8409e7defd964bae95 (diff) | |
download | linux-stable-ebdc37febe594035d8cf3f5424ce97a926d2cddf.tar.gz linux-stable-ebdc37febe594035d8cf3f5424ce97a926d2cddf.tar.bz2 linux-stable-ebdc37febe594035d8cf3f5424ce97a926d2cddf.zip |
fuse: atomic_o_trunc should truncate pagecache
commit df0e91d488276086bc07da2e389986cae0048c37 upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/fuse')
-rw-r--r-- | fs/fuse/dir.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 4bbad745415a..cca8dd3bda09 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1633,8 +1633,19 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr, return err; if (attr->ia_valid & ATTR_OPEN) { - if (fc->atomic_o_trunc) + /* This is coming from open(..., ... | O_TRUNC); */ + WARN_ON(!(attr->ia_valid & ATTR_SIZE)); + WARN_ON(attr->ia_size != 0); + if (fc->atomic_o_trunc) { + /* + * No need to send request to userspace, since actual + * truncation has already been done by OPEN. But still + * need to truncate page cache. + */ + i_size_write(inode, 0); + truncate_pagecache(inode, 0); return 0; + } file = NULL; } |