diff mbox series

[v3,04/10] fuse: convert fuse_page_mkwrite to use folios

Message ID 1cb4f72d82dce708ca20ff90be622ac302ac2653.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 | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

Comments

Joanne Koong Sept. 27, 2024, 10:42 p.m. UTC | #1
On Fri, Sep 27, 2024 at 1:46 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 | 20 +++++++++++++++-----
>  1 file changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index 1f7fe5416139..c8a5fa579615 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -483,6 +483,16 @@ static void fuse_wait_on_page_writeback(struct inode *inode, pgoff_t index)
>         wait_event(fi->page_waitq, !fuse_page_is_writeback(inode, index));
>  }
>
> +static void fuse_wait_on_folio_writeback(struct inode *inode,
> +                                        struct folio *folio)
> +{
> +       struct fuse_inode *fi = get_fuse_inode(inode);
> +       pgoff_t last = folio_next_index(folio) - 1;
> +
> +       wait_event(fi->page_waitq,
> +                  !fuse_range_is_writeback(inode, folio_index(folio), last));
> +}
> +
>  /*
>   * Wait for all pending writepages on the inode to finish.
>   *
> @@ -2527,17 +2537,17 @@ static void fuse_vma_close(struct vm_area_struct *vma)
>   */
>  static vm_fault_t fuse_page_mkwrite(struct vm_fault *vmf)
>  {
> -       struct page *page = vmf->page;
> +       struct folio *folio = page_folio(vmf->page);
>         struct inode *inode = file_inode(vmf->vma->vm_file);
>
>         file_update_time(vmf->vma->vm_file);
> -       lock_page(page);
> -       if (page->mapping != inode->i_mapping) {
> -               unlock_page(page);
> +       folio_lock(folio);
> +       if (folio->mapping != inode->i_mapping) {
> +               folio_unlock(folio);
>                 return VM_FAULT_NOPAGE;
>         }
>
> -       fuse_wait_on_page_writeback(inode, page->index);
> +       fuse_wait_on_folio_writeback(inode, folio);
>         return VM_FAULT_LOCKED;
>  }
>
> --
> 2.43.0
>
>
diff mbox series

Patch

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 1f7fe5416139..c8a5fa579615 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -483,6 +483,16 @@  static void fuse_wait_on_page_writeback(struct inode *inode, pgoff_t index)
 	wait_event(fi->page_waitq, !fuse_page_is_writeback(inode, index));
 }
 
+static void fuse_wait_on_folio_writeback(struct inode *inode,
+					 struct folio *folio)
+{
+	struct fuse_inode *fi = get_fuse_inode(inode);
+	pgoff_t last = folio_next_index(folio) - 1;
+
+	wait_event(fi->page_waitq,
+		   !fuse_range_is_writeback(inode, folio_index(folio), last));
+}
+
 /*
  * Wait for all pending writepages on the inode to finish.
  *
@@ -2527,17 +2537,17 @@  static void fuse_vma_close(struct vm_area_struct *vma)
  */
 static vm_fault_t fuse_page_mkwrite(struct vm_fault *vmf)
 {
-	struct page *page = vmf->page;
+	struct folio *folio = page_folio(vmf->page);
 	struct inode *inode = file_inode(vmf->vma->vm_file);
 
 	file_update_time(vmf->vma->vm_file);
-	lock_page(page);
-	if (page->mapping != inode->i_mapping) {
-		unlock_page(page);
+	folio_lock(folio);
+	if (folio->mapping != inode->i_mapping) {
+		folio_unlock(folio);
 		return VM_FAULT_NOPAGE;
 	}
 
-	fuse_wait_on_page_writeback(inode, page->index);
+	fuse_wait_on_folio_writeback(inode, folio);
 	return VM_FAULT_LOCKED;
 }