From: "Yuxiang (Kurath) Ji" <kurath0307@icloud.com>
To: joannelkoong@gmail.com, miklos@szeredi.hu
Cc: fuse-devel@lists.linux.dev, regressions@lists.linux.dev,
linux-kernel@vger.kernel.org, jlayton@kernel.org,
"Yuxiang (Kurath) Ji" <kurath0307@icloud.com>
Subject: [PATCH] fuse: keep a write-back error of the data for fsync and close in setattr
Date: Tue, 1 Dec 2026 18:10:31 +0800 [thread overview]
Message-ID: <20261201101031.2981145-1-kurath0307@icloud.com> (raw)
In-Reply-To: <20261201100323.2958149-1-kurath0307@icloud.com>
Before a SETATTR that does not truncate, fuse_do_setattr() writes the
inode out. Since commit 0c58a97f919c ("fuse: remove tmp folio for
writebacks and internal rb tree") the write-back of a page ends only
when the server has answered, so that write-out returns a failure of
the data and clears the mapping's error flag, which fuse_flush()
checks: the call that sets times or mode reports the failure, and the
close() after it returns 0. A program that treats a failure to set
times as cosmetic, such as mv across file systems, then takes its data
for stored and removes the source.
When the write-out fails and the mapping recorded a write-back error,
leave the error on the mapping and go on with the change, so that
fsync() and close() report it, as they did before that commit. NFS
made the same choice for getattr in commit d19e0183a883 ("NFS: Do not
report writeback errors in nfs_getattr()").
Found with a test FUSE file system that fails write-back requests, and
reproduced with fuse-overlayfs over a full upper directory: since 6.16
mv across file systems warns about the times, exits 0 and removes the
source. Building the commit above and its parent showed the change.
Assisted by Claude Code.
Tested on v7.4-rc5 in an x86_64 KVM guest with fuse-overlayfs 1.16:
futimens() and fchmod() return 0 and the close() after them returns
ENOSPC; mv reports the failed close, exits 1 and keeps its source; and
the writer's fsync() still returns ENOSPC after a duplicate's close, a
child's close or a child's exit that follows the attribute call.
Fixes: 0c58a97f919c ("fuse: remove tmp folio for writebacks and internal rb tree")
Signed-off-by: Yuxiang (Kurath) Ji <kurath0307@icloud.com>
---
fs/fuse/dir.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index a04d93d5f..895cd0e0a 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -2212,7 +2212,19 @@ int fuse_do_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
attr->ia_valid &
(ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_MTIME_SET |
ATTR_TIMES_SET)) {
+ errseq_t since = filemap_sample_wb_err(inode->i_mapping);
+
err = write_inode_now(inode, true);
+ if (err && filemap_check_wb_err(inode->i_mapping, since)) {
+ /*
+ * The data failed to reach the server. That failure
+ * belongs to the file's data, not to this change of its
+ * attributes: leave it on the mapping for fsync() and
+ * close() to report, and go on with the change.
+ */
+ mapping_set_error(inode->i_mapping, err);
+ err = 0;
+ }
if (err)
goto unlock;
--
2.56.1
prev parent reply other threads:[~2026-12-01 10:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 10:03 [REGRESSION] fuse: since 6.16 an attribute change takes the write-back error and close() returns 0 Yuxiang (Kurath) Ji
2026-12-01 10:10 ` Yuxiang (Kurath) Ji [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201101031.2981145-1-kurath0307@icloud.com \
--to=kurath0307@icloud.com \
--cc=fuse-devel@lists.linux.dev \
--cc=jlayton@kernel.org \
--cc=joannelkoong@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=regressions@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®