Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Jingbo Xu and committed by
Miklos Szeredi
5223e047 9587fde0

+4 -6
+4 -6
fs/fuse/file.c
··· 1248 1248 { 1249 1249 struct fuse_args_pages *ap = &ia->ap; 1250 1250 struct fuse_conn *fc = get_fuse_conn(mapping->host); 1251 - unsigned offset = pos & (PAGE_SIZE - 1); 1252 1251 size_t count = 0; 1253 1252 unsigned int num; 1254 1253 int err = 0; ··· 1274 1275 if (mapping_writably_mapped(mapping)) 1275 1276 flush_dcache_folio(folio); 1276 1277 1277 - folio_offset = ((index - folio->index) << PAGE_SHIFT) + offset; 1278 + folio_offset = offset_in_folio(folio, pos); 1278 1279 bytes = min(folio_size(folio) - folio_offset, num); 1279 1280 1280 1281 tmp = copy_folio_from_iter_atomic(folio, folio_offset, bytes, ii); ··· 1304 1305 count += tmp; 1305 1306 pos += tmp; 1306 1307 num -= tmp; 1307 - offset += tmp; 1308 - if (offset == folio_size(folio)) 1309 - offset = 0; 1310 1308 1311 1309 /* If we copied full folio, mark it uptodate */ 1312 1310 if (tmp == folio_size(folio)) ··· 1315 1319 ia->write.folio_locked = true; 1316 1320 break; 1317 1321 } 1318 - if (!fc->big_writes || offset != 0) 1322 + if (!fc->big_writes) 1323 + break; 1324 + if (folio_offset + tmp != folio_size(folio)) 1319 1325 break; 1320 1326 } 1321 1327