Skip to content

Commit 5223e04

Browse files
lostjeffleMiklos Szeredi
authored andcommitted
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: d60a601 ("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>
1 parent 9587fde commit 5223e04

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

fs/fuse/file.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,6 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
12481248
{
12491249
struct fuse_args_pages *ap = &ia->ap;
12501250
struct fuse_conn *fc = get_fuse_conn(mapping->host);
1251-
unsigned offset = pos & (PAGE_SIZE - 1);
12521251
size_t count = 0;
12531252
unsigned int num;
12541253
int err = 0;
@@ -1275,7 +1274,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
12751274
if (mapping_writably_mapped(mapping))
12761275
flush_dcache_folio(folio);
12771276

1278-
folio_offset = ((index - folio->index) << PAGE_SHIFT) + offset;
1277+
folio_offset = offset_in_folio(folio, pos);
12791278
bytes = min(folio_size(folio) - folio_offset, num);
12801279

12811280
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,
13051304
count += tmp;
13061305
pos += tmp;
13071306
num -= tmp;
1308-
offset += tmp;
1309-
if (offset == folio_size(folio))
1310-
offset = 0;
13111307

13121308
/* If we copied full folio, mark it uptodate */
13131309
if (tmp == folio_size(folio))
@@ -1319,7 +1315,9 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
13191315
ia->write.folio_locked = true;
13201316
break;
13211317
}
1322-
if (!fc->big_writes || offset != 0)
1318+
if (!fc->big_writes)
1319+
break;
1320+
if (folio_offset + tmp != folio_size(folio))
13231321
break;
13241322
}
13251323

0 commit comments

Comments
 (0)