summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJingbo Xu <jefflexu@linux.alibaba.com>2026-01-15 05:36:07 +0300
committerMiklos Szeredi <mszeredi@redhat.com>2026-03-03 12:05:39 +0300
commit5223e0470e7bb7910038fe3d31171490e00fbbb9 (patch)
tree14dfa55303f0e21febefc834ad052f9c46e2f313
parent9587fde0da0365d300ea1c967e63ad3fe09b883e (diff)
downloadlinux-5223e0470e7bb7910038fe3d31171490e00fbbb9.tar.xz
fuse: fix premature writetrhough request for large folio
When large folio is enabled and the initial folio offset exceeds PAGE_SIZE, e.g. the position resides in the second page of a large folio, after the folio copying the offset (in the page) won't be updated to 0 even though the expected range is successfully copied until the end of the folio. In this case fuse_fill_write_pages() exits prematurelly before the request has reached the max_write/max_pages limit. Fix this by eliminating page offset entirely and use folio offset instead. Fixes: d60a6015e1a2 ("fuse: support large folios for writethrough writes") Reviewed-by: Horst Birthelmer <hbirthelmer@ddn.com> Reviewed-by: Joanne Koong <joannelkoong@gmail.com> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r--fs/fuse/file.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 30a74f61caf0..c61d80e0a70d 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1248,7 +1248,6 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
{
struct fuse_args_pages *ap = &ia->ap;
struct fuse_conn *fc = get_fuse_conn(mapping->host);
- unsigned offset = pos & (PAGE_SIZE - 1);
size_t count = 0;
unsigned int num;
int err = 0;
@@ -1275,7 +1274,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
if (mapping_writably_mapped(mapping))
flush_dcache_folio(folio);
- folio_offset = ((index - folio->index) << PAGE_SHIFT) + offset;
+ folio_offset = offset_in_folio(folio, pos);
bytes = min(folio_size(folio) - folio_offset, num);
tmp = copy_folio_from_iter_atomic(folio, folio_offset, bytes, ii);
@@ -1305,9 +1304,6 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
count += tmp;
pos += tmp;
num -= tmp;
- offset += tmp;
- if (offset == folio_size(folio))
- offset = 0;
/* If we copied full folio, mark it uptodate */
if (tmp == folio_size(folio))
@@ -1319,7 +1315,9 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
ia->write.folio_locked = true;
break;
}
- if (!fc->big_writes || offset != 0)
+ if (!fc->big_writes)
+ break;
+ if (folio_offset + tmp != folio_size(folio))
break;
}