Skip to content

Commit d60a601

Browse files
joannekoongMiklos Szeredi
authored andcommitted
fuse: support large folios for writethrough writes
Add support for folios larger than one page size for writethrough writes. Signed-off-by: Joanne Koong <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 63c69ad commit d60a601

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

fs/fuse/file.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,8 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
11461146
size_t tmp;
11471147
struct folio *folio;
11481148
pgoff_t index = pos >> PAGE_SHIFT;
1149-
unsigned bytes = min(PAGE_SIZE - offset, num);
1149+
unsigned int bytes;
1150+
unsigned int folio_offset;
11501151

11511152
again:
11521153
folio = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN,
@@ -1159,7 +1160,10 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
11591160
if (mapping_writably_mapped(mapping))
11601161
flush_dcache_folio(folio);
11611162

1162-
tmp = copy_folio_from_iter_atomic(folio, offset, bytes, ii);
1163+
folio_offset = ((index - folio->index) << PAGE_SHIFT) + offset;
1164+
bytes = min(folio_size(folio) - folio_offset, num);
1165+
1166+
tmp = copy_folio_from_iter_atomic(folio, folio_offset, bytes, ii);
11631167
flush_dcache_folio(folio);
11641168

11651169
if (!tmp) {
@@ -1179,18 +1183,19 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
11791183
}
11801184

11811185
ap->folios[ap->num_folios] = folio;
1186+
ap->descs[ap->num_folios].offset = folio_offset;
11821187
ap->descs[ap->num_folios].length = tmp;
11831188
ap->num_folios++;
11841189

11851190
count += tmp;
11861191
pos += tmp;
11871192
num -= tmp;
11881193
offset += tmp;
1189-
if (offset == PAGE_SIZE)
1194+
if (offset == folio_size(folio))
11901195
offset = 0;
11911196

1192-
/* If we copied full page, mark it uptodate */
1193-
if (tmp == PAGE_SIZE)
1197+
/* If we copied full folio, mark it uptodate */
1198+
if (tmp == folio_size(folio))
11941199
folio_mark_uptodate(folio);
11951200

11961201
if (folio_test_uptodate(folio)) {

0 commit comments

Comments
 (0)