linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] fuse: drop usage of folio_index
       [not found] <20250427185908.90450-1-ryncsn@gmail.com>
@ 2025-04-27 18:59 ` Kairui Song
  2025-04-28  0:37   ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: Kairui Song @ 2025-04-27 18:59 UTC (permalink / raw)
  To: linux-mm
  Cc: Andrew Morton, Matthew Wilcox, David Hildenbrand, Hugh Dickins,
	Chris Li, Yosry Ahmed, Huang, Ying, Nhat Pham, Johannes Weiner,
	linux-kernel, Kairui Song, Miklos Szeredi, Joanne Koong,
	Josef Bacik, linux-fsdevel

From: Kairui Song <kasong@tencent.com>

folio_index is only needed for mixed usage of page cache and swap
cache, for pure page cache usage, the caller can just use
folio->index instead.

It can't be a swap cache folio here.  Swap mapping may only call into fs
through `swap_rw` and that is not supported for fuse.  So just drop it
and use folio->index instead.

uigned-off-by: Kairui Song <kasong@tencent.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Joanne Koong <joannelkoong@gmail.com>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Kairui Song <kasong@tencent.com>
---
 fs/fuse/file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 754378dd9f71..6f19a4daa559 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -487,7 +487,7 @@ static inline bool fuse_folio_is_writeback(struct inode *inode,
 					   struct folio *folio)
 {
 	pgoff_t last = folio_next_index(folio) - 1;
-	return fuse_range_is_writeback(inode, folio_index(folio), last);
+	return fuse_range_is_writeback(inode, folio->index, last);
 }
 
 static void fuse_wait_on_folio_writeback(struct inode *inode,
@@ -2349,7 +2349,7 @@ static bool fuse_writepage_need_send(struct fuse_conn *fc, struct folio *folio,
 		return true;
 
 	/* Discontinuity */
-	if (data->orig_folios[ap->num_folios - 1]->index + 1 != folio_index(folio))
+	if (data->orig_folios[ap->num_folios - 1]->index + 1 != folio->index)
 		return true;
 
 	/* Need to grow the pages array?  If so, did the expansion fail? */
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/6] fuse: drop usage of folio_index
  2025-04-27 18:59 ` [PATCH 1/6] fuse: drop usage of folio_index Kairui Song
@ 2025-04-28  0:37   ` Matthew Wilcox
  2025-04-29  8:54     ` Kairui Song
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2025-04-28  0:37 UTC (permalink / raw)
  To: Kairui Song
  Cc: linux-mm, Andrew Morton, David Hildenbrand, Hugh Dickins,
	Chris Li, Yosry Ahmed, Huang, Ying, Nhat Pham, Johannes Weiner,
	linux-kernel, Miklos Szeredi, Joanne Koong, Josef Bacik,
	linux-fsdevel

On Mon, Apr 28, 2025 at 02:59:03AM +0800, Kairui Song wrote:
> folio_index is only needed for mixed usage of page cache and swap
> cache, for pure page cache usage, the caller can just use
> folio->index instead.
> 
> It can't be a swap cache folio here.  Swap mapping may only call into fs
> through `swap_rw` and that is not supported for fuse.  So just drop it
> and use folio->index instead.
> 
> uigned-off-by: Kairui Song <kasong@tencent.com>
> Cc: Miklos Szeredi <miklos@szeredi.hu>
> Cc: Joanne Koong <joannelkoong@gmail.com>
> Cc: Josef Bacik <josef@toxicpanda.com>
> Cc: linux-fsdevel@vger.kernel.org
> Signed-off-by: Kairui Song <kasong@tencent.com>

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>

> @@ -2349,7 +2349,7 @@ static bool fuse_writepage_need_send(struct fuse_conn *fc, struct folio *folio,
>  		return true;
>  
>  	/* Discontinuity */
> -	if (data->orig_folios[ap->num_folios - 1]->index + 1 != folio_index(folio))
> +	if (data->orig_folios[ap->num_folios - 1]->index + 1 != folio->index)
>  		return true;

This looks like a pre-existing bug.

-	if (data->orig_folios[ap->num_folios - 1]->index + 1 != folio_index(folio))
+	prev_folio = data->orig_folios[ap->num_folios - 1];
+	if (prev_folio->index + folio_nr_pages(prev_folio) != folio->index)
		return true;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/6] fuse: drop usage of folio_index
  2025-04-28  0:37   ` Matthew Wilcox
@ 2025-04-29  8:54     ` Kairui Song
  0 siblings, 0 replies; 3+ messages in thread
From: Kairui Song @ 2025-04-29  8:54 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: linux-mm, Andrew Morton, David Hildenbrand, Hugh Dickins,
	Chris Li, Yosry Ahmed, Huang, Ying, Nhat Pham, Johannes Weiner,
	linux-kernel, Miklos Szeredi, Joanne Koong, Josef Bacik,
	linux-fsdevel

On Mon, Apr 28, 2025 at 8:38 AM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Mon, Apr 28, 2025 at 02:59:03AM +0800, Kairui Song wrote:
> > folio_index is only needed for mixed usage of page cache and swap
> > cache, for pure page cache usage, the caller can just use
> > folio->index instead.
> >
> > It can't be a swap cache folio here.  Swap mapping may only call into fs
> > through `swap_rw` and that is not supported for fuse.  So just drop it
> > and use folio->index instead.
> >
> > uigned-off-by: Kairui Song <kasong@tencent.com>
> > Cc: Miklos Szeredi <miklos@szeredi.hu>
> > Cc: Joanne Koong <joannelkoong@gmail.com>
> > Cc: Josef Bacik <josef@toxicpanda.com>
> > Cc: linux-fsdevel@vger.kernel.org
> > Signed-off-by: Kairui Song <kasong@tencent.com>
>
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Thanks for the review.

>
> > @@ -2349,7 +2349,7 @@ static bool fuse_writepage_need_send(struct fuse_conn *fc, struct folio *folio,
> >               return true;
> >
> >       /* Discontinuity */
> > -     if (data->orig_folios[ap->num_folios - 1]->index + 1 != folio_index(folio))
> > +     if (data->orig_folios[ap->num_folios - 1]->index + 1 != folio->index)
> >               return true;
>
> This looks like a pre-existing bug.
>
> -       if (data->orig_folios[ap->num_folios - 1]->index + 1 != folio_index(folio))
> +       prev_folio = data->orig_folios[ap->num_folios - 1];
> +       if (prev_folio->index + folio_nr_pages(prev_folio) != folio->index)
>                 return true;
>

It seems FUSE does not work with high order folios yet, a lot of
allocation and operation here are assuming folio size == PAGE_SIZE. I
think I'll just leave it here.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-29  8:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20250427185908.90450-1-ryncsn@gmail.com>
2025-04-27 18:59 ` [PATCH 1/6] fuse: drop usage of folio_index Kairui Song
2025-04-28  0:37   ` Matthew Wilcox
2025-04-29  8:54     ` Kairui Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).