aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2024-09-30 09:45:18 -0400
committerMiklos Szeredi <mszeredi@redhat.com>2024-10-25 17:05:50 +0200
commit8807f117be9d15088003e63bfaf0533355371ee8 (patch)
treead95ed0cdb803d7a75c306f9f73da37886b7f6ab
parentfuse: convert fuse_retrieve to use folios (diff)
downloadwireguard-linux-8807f117be9d15088003e63bfaf0533355371ee8.tar.xz
wireguard-linux-8807f117be9d15088003e63bfaf0533355371ee8.zip
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 <joannelkoong@gmail.com> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r--fs/fuse/dev.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index a332cb799967..e25804097ffb 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1654,24 +1654,25 @@ static int fuse_notify_store(struct fuse_conn *fc, unsigned int size,
num = outarg.size;
while (num) {
+ struct folio *folio;
struct page *page;
unsigned int this_num;
- err = -ENOMEM;
- page = find_or_create_page(mapping, index,
- mapping_gfp_mask(mapping));
- if (!page)
+ folio = filemap_grab_folio(mapping, index);
+ err = PTR_ERR(folio);
+ if (IS_ERR(folio))
goto out_iput;
- this_num = min_t(unsigned, num, PAGE_SIZE - offset);
+ page = &folio->page;
+ this_num = min_t(unsigned, num, folio_size(folio) - offset);
err = fuse_copy_page(cs, &page, offset, this_num, 0);
- if (!PageUptodate(page) && !err && offset == 0 &&
- (this_num == PAGE_SIZE || file_size == end)) {
- zero_user_segment(page, this_num, PAGE_SIZE);
- SetPageUptodate(page);
+ if (!folio_test_uptodate(folio) && !err && offset == 0 &&
+ (this_num == folio_size(folio) || file_size == end)) {
+ folio_zero_segment(folio, this_num, folio_size(folio));
+ folio_mark_uptodate(folio);
}
- unlock_page(page);
- put_page(page);
+ folio_unlock(folio);
+ folio_put(folio);
if (err)
goto out_iput;