Skip to content

Commit c91440c

Browse files
joannekoongMiklos Szeredi
authored andcommitted
fuse: support large folios for stores
Add support for folios larger than one page size for stores. Also change variable naming from "this_num" to "nr_bytes". Signed-off-by: Joanne Koong <[email protected]> Reviewed-by: Josef Bacik <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent cacc064 commit c91440c

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

fs/fuse/dev.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,18 +1788,23 @@ static int fuse_notify_store(struct fuse_conn *fc, unsigned int size,
17881788
num = outarg.size;
17891789
while (num) {
17901790
struct folio *folio;
1791-
unsigned int this_num;
1791+
unsigned int folio_offset;
1792+
unsigned int nr_bytes;
1793+
unsigned int nr_pages;
17921794

17931795
folio = filemap_grab_folio(mapping, index);
17941796
err = PTR_ERR(folio);
17951797
if (IS_ERR(folio))
17961798
goto out_iput;
17971799

1798-
this_num = min_t(unsigned, num, folio_size(folio) - offset);
1799-
err = fuse_copy_folio(cs, &folio, offset, this_num, 0);
1800+
folio_offset = ((index - folio->index) << PAGE_SHIFT) + offset;
1801+
nr_bytes = min_t(unsigned, num, folio_size(folio) - folio_offset);
1802+
nr_pages = (offset + nr_bytes + PAGE_SIZE - 1) >> PAGE_SHIFT;
1803+
1804+
err = fuse_copy_folio(cs, &folio, folio_offset, nr_bytes, 0);
18001805
if (!folio_test_uptodate(folio) && !err && offset == 0 &&
1801-
(this_num == folio_size(folio) || file_size == end)) {
1802-
folio_zero_segment(folio, this_num, folio_size(folio));
1806+
(nr_bytes == folio_size(folio) || file_size == end)) {
1807+
folio_zero_segment(folio, nr_bytes, folio_size(folio));
18031808
folio_mark_uptodate(folio);
18041809
}
18051810
folio_unlock(folio);
@@ -1808,9 +1813,9 @@ static int fuse_notify_store(struct fuse_conn *fc, unsigned int size,
18081813
if (err)
18091814
goto out_iput;
18101815

1811-
num -= this_num;
1816+
num -= nr_bytes;
18121817
offset = 0;
1813-
index++;
1818+
index += nr_pages;
18141819
}
18151820

18161821
err = 0;

0 commit comments

Comments
 (0)