FAILED: patch "[PATCH] fuse: don't drop destination page cache on a zero byte copy reply" failed to apply to 6.12-stable tree
Subsystems (2)
Sasha Levin
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x f7585e1ce3418ec282485854b3d8d31c6a961e37
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From f7585e1ce3418ec282485854b3d8d31c6a961e37 Mon Sep 17 00:00:00 2001
From: Joanne Koong <[email protected]>
Date: Tue, 15 Sep 2026 16:53:41 -0700
Subject: [PATCH] fuse: don't drop destination page cache on a zero byte copy
reply
__fuse_copy_file_range() clears the destination page cache after the server replies:
truncate_inode_pages_range(inode_out->i_mapping, ALIGN_DOWN(pos_out, PAGE_SIZE), ALIGN(pos_out + bytes_copied, PAGE_SIZE) - 1);
A server may legitimately reply that it copied nothing, eg if the source file turns out to be shorter than the size the kernel has cached for it.
If pos_out is 0 as well, the end of the range is ALIGN(0, PAGE_SIZE) - 1, which is -1. lend is a uoff_t and truncate_inode_pages_range() takes -1 as its end of file sentinel, so rather than clearing nothing it drops every folio in the destination mapping.
That is not only a cache drop. truncate_cleanup_folio() calls folio_cancel_dirty(), and fuse_writeback_range() only wrote back [pos_out, pos_out + len - 1], so dirty data elsewhere in the destination file is discarded without ever reaching the server.
Skip the call when the server copied nothing, since there is nothing stale to clear in that case.
--- fs/fuse/file.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/fuse/file.c +5 -3
@@ -3062,9 +3062,11 @@ static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in, goto out; } -truncate_inode_pages_range (inode_out->i_mapping, -ALIGN_DOWN (pos_out,PAGE_SIZE ), -ALIGN (pos_out + bytes_copied,PAGE_SIZE ) -1 ); +if (bytes_copied) +truncate_inode_pages_range (inode_out->i_mapping, +ALIGN_DOWN (pos_out,PAGE_SIZE ), +ALIGN (pos_out + bytes_copied, +PAGE_SIZE ) -1 );file_update_time (file_out);fuse_write_update_attr (inode_out, pos_out + bytes_copied, bytes_copied);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 fuse: don't drop destination page cache on a zero byte copy reply
From: Joanne Koong <[email protected]>
[ Upstream commit f7585e1ce3418ec282485854b3d8d31c6a961e37 ]
__fuse_copy_file_range() clears the destination page cache after the server replies:
truncate_inode_pages_range(inode_out->i_mapping, ALIGN_DOWN(pos_out, PAGE_SIZE), ALIGN(pos_out + bytes_copied, PAGE_SIZE) - 1);
A server may legitimately reply that it copied nothing, eg if the source file turns out to be shorter than the size the kernel has cached for it.
If pos_out is 0 as well, the end of the range is ALIGN(0, PAGE_SIZE) - 1, which is -1. lend is a uoff_t and truncate_inode_pages_range() takes -1 as its end of file sentinel, so rather than clearing nothing it drops every folio in the destination mapping.
That is not only a cache drop. truncate_cleanup_folio() calls folio_cancel_dirty(), and fuse_writeback_range() only wrote back [pos_out, pos_out + len - 1], so dirty data elsewhere in the destination file is discarded without ever reaching the server.
Skip the call when the server copied nothing, since there is nothing stale to clear in that case.
--- fs/fuse/file.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/fuse/file.c +5 -3
@@ -3344,9 +3344,11 @@ static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in,if (err) goto out; -truncate_inode_pages_range (inode_out->i_mapping, -ALIGN_DOWN (pos_out,PAGE_SIZE ), -ALIGN (pos_out + outarg.size,PAGE_SIZE ) -1 ); +if (outarg.size) +truncate_inode_pages_range (inode_out->i_mapping, +ALIGN_DOWN (pos_out,PAGE_SIZE ), +ALIGN (pos_out + outarg.size, +PAGE_SIZE ) -1 );file_update_time (file_out);fuse_write_update_attr (inode_out, pos_out + outarg.size, outarg.size);
Signature · 1 line
2.53.0