diff mbox series

[v3,03/10] fuse: convert fuse_fill_write_pages to use folios

Message ID 00a02299e944530c1be03d2d31b45614bedbc758.1727469663.git.josef@toxicpanda.com (mailing list archive)
State New
Headers show
Series fuse: folio conversions | expand

Commit Message

Josef Bacik Sept. 27, 2024, 8:44 p.m. UTC
Convert this to grab the folio directly, and update all the helpers to
use the folio related functions.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/fuse/file.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

Comments

Joanne Koong Sept. 27, 2024, 10:36 p.m. UTC | #1
On Fri, Sep 27, 2024 at 1:45 PM Josef Bacik <josef@toxicpanda.com> wrote:
>
> Convert this to grab the folio directly, and update all the helpers to
> use the folio related functions.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Joanne Koong <joannelkoong@gmail.com>

> ---
>  fs/fuse/file.c | 28 +++++++++++++++-------------
>  1 file changed, 15 insertions(+), 13 deletions(-)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index 17ac2de61cdb..1f7fe5416139 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -1206,7 +1206,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
>
>         do {
>                 size_t tmp;
> -               struct page *page;
> +               struct folio *folio;
>                 pgoff_t index = pos >> PAGE_SHIFT;
>                 size_t bytes = min_t(size_t, PAGE_SIZE - offset,
>                                      iov_iter_count(ii));
> @@ -1218,25 +1218,27 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
>                 if (fault_in_iov_iter_readable(ii, bytes))
>                         break;
>
> -               err = -ENOMEM;
> -               page = grab_cache_page_write_begin(mapping, index);
> -               if (!page)
> +               folio = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN,
> +                                           mapping_gfp_mask(mapping));
> +               if (IS_ERR(folio)) {
> +                       err = PTR_ERR(folio);
>                         break;
> +               }
>
>                 if (mapping_writably_mapped(mapping))
> -                       flush_dcache_page(page);
> +                       flush_dcache_folio(folio);
>
> -               tmp = copy_page_from_iter_atomic(page, offset, bytes, ii);
> -               flush_dcache_page(page);
> +               tmp = copy_folio_from_iter_atomic(folio, offset, bytes, ii);
> +               flush_dcache_folio(folio);
>
>                 if (!tmp) {
> -                       unlock_page(page);
> -                       put_page(page);
> +                       folio_unlock(folio);
> +                       folio_put(folio);
>                         goto again;
>                 }
>
>                 err = 0;
> -               ap->pages[ap->num_pages] = page;
> +               ap->pages[ap->num_pages] = &folio->page;
>                 ap->descs[ap->num_pages].length = tmp;
>                 ap->num_pages++;
>
> @@ -1248,10 +1250,10 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
>
>                 /* If we copied full page, mark it uptodate */
>                 if (tmp == PAGE_SIZE)
> -                       SetPageUptodate(page);
> +                       folio_mark_uptodate(folio);
>
> -               if (PageUptodate(page)) {
> -                       unlock_page(page);
> +               if (folio_test_uptodate(folio)) {
> +                       folio_unlock(folio);
>                 } else {
>                         ia->write.page_locked = true;
>                         break;
> --
> 2.43.0
>
>
diff mbox series

Patch

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 17ac2de61cdb..1f7fe5416139 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1206,7 +1206,7 @@  static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
 
 	do {
 		size_t tmp;
-		struct page *page;
+		struct folio *folio;
 		pgoff_t index = pos >> PAGE_SHIFT;
 		size_t bytes = min_t(size_t, PAGE_SIZE - offset,
 				     iov_iter_count(ii));
@@ -1218,25 +1218,27 @@  static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
 		if (fault_in_iov_iter_readable(ii, bytes))
 			break;
 
-		err = -ENOMEM;
-		page = grab_cache_page_write_begin(mapping, index);
-		if (!page)
+		folio = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN,
+					    mapping_gfp_mask(mapping));
+		if (IS_ERR(folio)) {
+			err = PTR_ERR(folio);
 			break;
+		}
 
 		if (mapping_writably_mapped(mapping))
-			flush_dcache_page(page);
+			flush_dcache_folio(folio);
 
-		tmp = copy_page_from_iter_atomic(page, offset, bytes, ii);
-		flush_dcache_page(page);
+		tmp = copy_folio_from_iter_atomic(folio, offset, bytes, ii);
+		flush_dcache_folio(folio);
 
 		if (!tmp) {
-			unlock_page(page);
-			put_page(page);
+			folio_unlock(folio);
+			folio_put(folio);
 			goto again;
 		}
 
 		err = 0;
-		ap->pages[ap->num_pages] = page;
+		ap->pages[ap->num_pages] = &folio->page;
 		ap->descs[ap->num_pages].length = tmp;
 		ap->num_pages++;
 
@@ -1248,10 +1250,10 @@  static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
 
 		/* If we copied full page, mark it uptodate */
 		if (tmp == PAGE_SIZE)
-			SetPageUptodate(page);
+			folio_mark_uptodate(folio);
 
-		if (PageUptodate(page)) {
-			unlock_page(page);
+		if (folio_test_uptodate(folio)) {
+			folio_unlock(folio);
 		} else {
 			ia->write.page_locked = true;
 			break;