Skip to content

Commit 8807f11

Browse files
josefbacikMiklos Szeredi
authored andcommitted
fuse: convert fuse_notify_store to use folios
This function creates pages in an inode and copies data into them, update the function to use a folio instead of a page, and use the appropriate folio helpers. [SzM: use filemap_grab_folio()] [Hau Tao: The third argument of folio_zero_range() should be the length to be zeroed, not the total length. Fix it by using folio_zero_segment() instead in fuse_notify_store()] Reviewed-by: Joanne Koong <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 71e10dc commit 8807f11

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

fs/fuse/dev.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,24 +1654,25 @@ static int fuse_notify_store(struct fuse_conn *fc, unsigned int size,
16541654

16551655
num = outarg.size;
16561656
while (num) {
1657+
struct folio *folio;
16571658
struct page *page;
16581659
unsigned int this_num;
16591660

1660-
err = -ENOMEM;
1661-
page = find_or_create_page(mapping, index,
1662-
mapping_gfp_mask(mapping));
1663-
if (!page)
1661+
folio = filemap_grab_folio(mapping, index);
1662+
err = PTR_ERR(folio);
1663+
if (IS_ERR(folio))
16641664
goto out_iput;
16651665

1666-
this_num = min_t(unsigned, num, PAGE_SIZE - offset);
1666+
page = &folio->page;
1667+
this_num = min_t(unsigned, num, folio_size(folio) - offset);
16671668
err = fuse_copy_page(cs, &page, offset, this_num, 0);
1668-
if (!PageUptodate(page) && !err && offset == 0 &&
1669-
(this_num == PAGE_SIZE || file_size == end)) {
1670-
zero_user_segment(page, this_num, PAGE_SIZE);
1671-
SetPageUptodate(page);
1669+
if (!folio_test_uptodate(folio) && !err && offset == 0 &&
1670+
(this_num == folio_size(folio) || file_size == end)) {
1671+
folio_zero_segment(folio, this_num, folio_size(folio));
1672+
folio_mark_uptodate(folio);
16721673
}
1673-
unlock_page(page);
1674-
put_page(page);
1674+
folio_unlock(folio);
1675+
folio_put(folio);
16751676

16761677
if (err)
16771678
goto out_iput;

0 commit comments

Comments
 (0)