diff mbox series

[2/6] nilfs2: Convert nilfs_copy_buffer() to use folios

Message ID 20241002040111.1023018-3-willy@infradead.org (mailing list archive)
State New
Headers show
Series Filesystem page flags cleanup | expand

Commit Message

Matthew Wilcox Oct. 2, 2024, 4:01 a.m. UTC
Use folio APIs instead of page APIs.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/nilfs2/page.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Comments

Ryusuke Konishi Oct. 2, 2024, 1:11 p.m. UTC | #1
On Wed, Oct 2, 2024 at 1:02 PM Matthew Wilcox (Oracle) wrote:
>
> Use folio APIs instead of page APIs.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  fs/nilfs2/page.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
> index 9c0b7cddeaae..16bb82cdbc07 100644
> --- a/fs/nilfs2/page.c
> +++ b/fs/nilfs2/page.c
> @@ -98,16 +98,16 @@ void nilfs_forget_buffer(struct buffer_head *bh)
>   */
>  void nilfs_copy_buffer(struct buffer_head *dbh, struct buffer_head *sbh)
>  {
> -       void *kaddr0, *kaddr1;
> +       void *saddr, *daddr;
>         unsigned long bits;
> -       struct page *spage = sbh->b_page, *dpage = dbh->b_page;
> +       struct folio *sfolio = sbh->b_folio, *dfolio = dbh->b_folio;
>         struct buffer_head *bh;
>
> -       kaddr0 = kmap_local_page(spage);
> -       kaddr1 = kmap_local_page(dpage);
> -       memcpy(kaddr1 + bh_offset(dbh), kaddr0 + bh_offset(sbh), sbh->b_size);
> -       kunmap_local(kaddr1);
> -       kunmap_local(kaddr0);
> +       saddr = kmap_local_folio(sfolio, bh_offset(sbh));
> +       daddr = kmap_local_folio(dfolio, bh_offset(dbh));
> +       memcpy(daddr, saddr, sbh->b_size);
> +       kunmap_local(daddr);
> +       kunmap_local(saddr);
>
>         dbh->b_state = sbh->b_state & NILFS_BUFFER_INHERENT_BITS;
>         dbh->b_blocknr = sbh->b_blocknr;
> @@ -121,13 +121,13 @@ void nilfs_copy_buffer(struct buffer_head *dbh, struct buffer_head *sbh)
>                 unlock_buffer(bh);
>         }
>         if (bits & BIT(BH_Uptodate))
> -               SetPageUptodate(dpage);
> +               folio_mark_uptodate(dfolio);
>         else
> -               ClearPageUptodate(dpage);
> +               folio_clear_uptodate(dfolio);
>         if (bits & BIT(BH_Mapped))
> -               SetPageMappedToDisk(dpage);
> +               folio_set_mappedtodisk(dfolio);
>         else
> -               ClearPageMappedToDisk(dpage);
> +               folio_clear_mappedtodisk(dfolio);
>  }
>
>  /**
> --
> 2.43.0

I understand the change.  Also, thank you for converting this function
to be folio-based.

Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>

Thanks,
Ryusuke Konishi
diff mbox series

Patch

diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index 9c0b7cddeaae..16bb82cdbc07 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -98,16 +98,16 @@  void nilfs_forget_buffer(struct buffer_head *bh)
  */
 void nilfs_copy_buffer(struct buffer_head *dbh, struct buffer_head *sbh)
 {
-	void *kaddr0, *kaddr1;
+	void *saddr, *daddr;
 	unsigned long bits;
-	struct page *spage = sbh->b_page, *dpage = dbh->b_page;
+	struct folio *sfolio = sbh->b_folio, *dfolio = dbh->b_folio;
 	struct buffer_head *bh;
 
-	kaddr0 = kmap_local_page(spage);
-	kaddr1 = kmap_local_page(dpage);
-	memcpy(kaddr1 + bh_offset(dbh), kaddr0 + bh_offset(sbh), sbh->b_size);
-	kunmap_local(kaddr1);
-	kunmap_local(kaddr0);
+	saddr = kmap_local_folio(sfolio, bh_offset(sbh));
+	daddr = kmap_local_folio(dfolio, bh_offset(dbh));
+	memcpy(daddr, saddr, sbh->b_size);
+	kunmap_local(daddr);
+	kunmap_local(saddr);
 
 	dbh->b_state = sbh->b_state & NILFS_BUFFER_INHERENT_BITS;
 	dbh->b_blocknr = sbh->b_blocknr;
@@ -121,13 +121,13 @@  void nilfs_copy_buffer(struct buffer_head *dbh, struct buffer_head *sbh)
 		unlock_buffer(bh);
 	}
 	if (bits & BIT(BH_Uptodate))
-		SetPageUptodate(dpage);
+		folio_mark_uptodate(dfolio);
 	else
-		ClearPageUptodate(dpage);
+		folio_clear_uptodate(dfolio);
 	if (bits & BIT(BH_Mapped))
-		SetPageMappedToDisk(dpage);
+		folio_set_mappedtodisk(dfolio);
 	else
-		ClearPageMappedToDisk(dpage);
+		folio_clear_mappedtodisk(dfolio);
 }
 
 /**