Commit 9c9d5228 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Stefan Bader

fuse: atomic_o_trunc should truncate pagecache

BugLink: https://bugs.launchpad.net/bugs/1784382

commit df0e91d4 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: default avatarChad Austin <chadaustin@fb.com>
Fixes: 6ff958ed ("fuse: add atomic open+truncate support")
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 1aae0926
......@@ -1611,8 +1611,19 @@ int fuse_do_setattr(struct inode *inode, 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;
}
......
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