linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/12] Start converting buffer_heads to use folios
@ 2022-12-15 21:43 Matthew Wilcox (Oracle)
  2022-12-15 21:43 ` [PATCH 01/12] buffer: Add b_folio as an alias of b_page Matthew Wilcox (Oracle)
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-12-15 21:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel

I was hoping that filesystems would convert from buffer_heads to iomap,
but that's not happening particularly quickly.  So the buffer_head
infrastructure needs to be converted from being page-based to being
folio-based.  This is the initial patchset that I hope Andrew will take
for 6.3.  I have a lot of followup patches, but many of them should go
through individual filesystem trees (ext4, f2fs, etc).  They can wait
for 6.4.

Matthew Wilcox (Oracle) (12):
  buffer: Add b_folio as an alias of b_page
  buffer: Replace obvious uses of b_page with b_folio
  buffer: Use b_folio in touch_buffer()
  buffer: Use b_folio in end_buffer_async_read()
  buffer: Use b_folio in end_buffer_async_write()
  page_io: Remove buffer_head include
  buffer: Use b_folio in mark_buffer_dirty()
  gfs2: Replace obvious uses of b_page with b_folio
  jbd2: Replace obvious uses of b_page with b_folio
  nilfs2: Replace obvious uses of b_page with b_folio
  reiserfs: Replace obvious uses of b_page with b_folio
  mpage: Use b_folio in do_mpage_readpage()

 fs/buffer.c                   | 54 +++++++++++++++++------------------
 fs/gfs2/glops.c               |  2 +-
 fs/gfs2/log.c                 |  2 +-
 fs/gfs2/meta_io.c             |  2 +-
 fs/jbd2/commit.c              |  8 ++----
 fs/jbd2/journal.c             |  2 +-
 fs/mpage.c                    |  2 +-
 fs/nilfs2/btnode.c            |  2 +-
 fs/nilfs2/btree.c             |  2 +-
 fs/nilfs2/gcinode.c           |  2 +-
 fs/nilfs2/mdt.c               |  4 +--
 fs/nilfs2/segment.c           |  2 +-
 fs/reiserfs/journal.c         |  4 +--
 fs/reiserfs/tail_conversion.c |  2 +-
 include/linux/buffer_head.h   |  5 +++-
 mm/page_io.c                  |  1 -
 16 files changed, 47 insertions(+), 49 deletions(-)

-- 
2.35.1


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

* [PATCH 01/12] buffer: Add b_folio as an alias of b_page
  2022-12-15 21:43 [PATCH 00/12] Start converting buffer_heads to use folios Matthew Wilcox (Oracle)
@ 2022-12-15 21:43 ` Matthew Wilcox (Oracle)
  2022-12-15 21:43 ` [PATCH 02/12] buffer: Replace obvious uses of b_page with b_folio Matthew Wilcox (Oracle)
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-12-15 21:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel

Buffer heads point to the allocation (ie the folio), not the page.
This is currently the same thing for all filesystems that use buffer
heads, so this is a safe transitional step.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/buffer_head.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 33fa5e94aa80..8f14dca5fed7 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -61,7 +61,10 @@ typedef void (bh_end_io_t)(struct buffer_head *bh, int uptodate);
 struct buffer_head {
 	unsigned long b_state;		/* buffer state bitmap (see above) */
 	struct buffer_head *b_this_page;/* circular list of page's buffers */
-	struct page *b_page;		/* the page this bh is mapped to */
+	union {
+		struct page *b_page;	/* the page this bh is mapped to */
+		struct folio *b_folio;	/* the folio this bh is mapped to */
+	};
 
 	sector_t b_blocknr;		/* start block number */
 	size_t b_size;			/* size of mapping */
-- 
2.35.1


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

* [PATCH 02/12] buffer: Replace obvious uses of b_page with b_folio
  2022-12-15 21:43 [PATCH 00/12] Start converting buffer_heads to use folios Matthew Wilcox (Oracle)
  2022-12-15 21:43 ` [PATCH 01/12] buffer: Add b_folio as an alias of b_page Matthew Wilcox (Oracle)
@ 2022-12-15 21:43 ` Matthew Wilcox (Oracle)
  2022-12-15 21:43 ` [PATCH 03/12] buffer: Use b_folio in touch_buffer() Matthew Wilcox (Oracle)
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-12-15 21:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel

These cases just check if it's NULL, or use b_page to get to the page's
address space.  They are assumptions that b_page never points to a
tail page.

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

diff --git a/fs/buffer.c b/fs/buffer.c
index d9c6d1fbb6dd..e1055fe0b366 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -321,7 +321,7 @@ static void end_buffer_async_read_io(struct buffer_head *bh, int uptodate)
 {
 	/* Decrypt if needed */
 	if (uptodate &&
-	    fscrypt_inode_uses_fs_layer_crypto(bh->b_page->mapping->host)) {
+	    fscrypt_inode_uses_fs_layer_crypto(bh->b_folio->mapping->host)) {
 		struct decrypt_bh_ctx *ctx = kmalloc(sizeof(*ctx), GFP_ATOMIC);
 
 		if (ctx) {
@@ -570,7 +570,7 @@ void write_boundary_block(struct block_device *bdev,
 void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode)
 {
 	struct address_space *mapping = inode->i_mapping;
-	struct address_space *buffer_mapping = bh->b_page->mapping;
+	struct address_space *buffer_mapping = bh->b_folio->mapping;
 
 	mark_buffer_dirty(bh);
 	if (!mapping->private_data) {
@@ -1073,7 +1073,7 @@ __getblk_slow(struct block_device *bdev, sector_t block,
  * and then attach the address_space's inode to its superblock's dirty
  * inode list.
  *
- * mark_buffer_dirty() is atomic.  It takes bh->b_page->mapping->private_lock,
+ * mark_buffer_dirty() is atomic.  It takes bh->b_folio->mapping->private_lock,
  * i_pages lock and mapping->host->i_lock.
  */
 void mark_buffer_dirty(struct buffer_head *bh)
@@ -1117,8 +1117,8 @@ void mark_buffer_write_io_error(struct buffer_head *bh)
 
 	set_buffer_write_io_error(bh);
 	/* FIXME: do we need to set this in both places? */
-	if (bh->b_page && bh->b_page->mapping)
-		mapping_set_error(bh->b_page->mapping, -EIO);
+	if (bh->b_folio && bh->b_folio->mapping)
+		mapping_set_error(bh->b_folio->mapping, -EIO);
 	if (bh->b_assoc_map)
 		mapping_set_error(bh->b_assoc_map, -EIO);
 	rcu_read_lock();
@@ -1154,7 +1154,7 @@ void __bforget(struct buffer_head *bh)
 {
 	clear_buffer_dirty(bh);
 	if (bh->b_assoc_map) {
-		struct address_space *buffer_mapping = bh->b_page->mapping;
+		struct address_space *buffer_mapping = bh->b_folio->mapping;
 
 		spin_lock(&buffer_mapping->private_lock);
 		list_del_init(&bh->b_assoc_buffers);
-- 
2.35.1


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

* [PATCH 03/12] buffer: Use b_folio in touch_buffer()
  2022-12-15 21:43 [PATCH 00/12] Start converting buffer_heads to use folios Matthew Wilcox (Oracle)
  2022-12-15 21:43 ` [PATCH 01/12] buffer: Add b_folio as an alias of b_page Matthew Wilcox (Oracle)
  2022-12-15 21:43 ` [PATCH 02/12] buffer: Replace obvious uses of b_page with b_folio Matthew Wilcox (Oracle)
@ 2022-12-15 21:43 ` Matthew Wilcox (Oracle)
  2022-12-15 21:43 ` [PATCH 04/12] buffer: Use b_folio in end_buffer_async_read() Matthew Wilcox (Oracle)
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-12-15 21:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel

Removes a call to compound_head() in this path.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index e1055fe0b366..8a02fdaeec9a 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -60,7 +60,7 @@ static void submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
 inline void touch_buffer(struct buffer_head *bh)
 {
 	trace_block_touch_buffer(bh);
-	mark_page_accessed(bh->b_page);
+	folio_mark_accessed(bh->b_folio);
 }
 EXPORT_SYMBOL(touch_buffer);
 
-- 
2.35.1


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

* [PATCH 04/12] buffer: Use b_folio in end_buffer_async_read()
  2022-12-15 21:43 [PATCH 00/12] Start converting buffer_heads to use folios Matthew Wilcox (Oracle)
                   ` (2 preceding siblings ...)
  2022-12-15 21:43 ` [PATCH 03/12] buffer: Use b_folio in touch_buffer() Matthew Wilcox (Oracle)
@ 2022-12-15 21:43 ` Matthew Wilcox (Oracle)
  2022-12-15 21:43 ` [PATCH 05/12] buffer: Use b_folio in end_buffer_async_write() Matthew Wilcox (Oracle)
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-12-15 21:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel

Removes a call to compound_head() in SetPageError(), saving 76 bytes
of text.

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

diff --git a/fs/buffer.c b/fs/buffer.c
index 8a02fdaeec9a..5bdcc040eca3 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -246,18 +246,18 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
 	unsigned long flags;
 	struct buffer_head *first;
 	struct buffer_head *tmp;
-	struct page *page;
-	int page_uptodate = 1;
+	struct folio *folio;
+	int folio_uptodate = 1;
 
 	BUG_ON(!buffer_async_read(bh));
 
-	page = bh->b_page;
+	folio = bh->b_folio;
 	if (uptodate) {
 		set_buffer_uptodate(bh);
 	} else {
 		clear_buffer_uptodate(bh);
 		buffer_io_error(bh, ", async page read");
-		SetPageError(page);
+		folio_set_error(folio);
 	}
 
 	/*
@@ -265,14 +265,14 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
 	 * two buffer heads end IO at almost the same time and both
 	 * decide that the page is now completely done.
 	 */
-	first = page_buffers(page);
+	first = folio_buffers(folio);
 	spin_lock_irqsave(&first->b_uptodate_lock, flags);
 	clear_buffer_async_read(bh);
 	unlock_buffer(bh);
 	tmp = bh;
 	do {
 		if (!buffer_uptodate(tmp))
-			page_uptodate = 0;
+			folio_uptodate = 0;
 		if (buffer_async_read(tmp)) {
 			BUG_ON(!buffer_locked(tmp));
 			goto still_busy;
@@ -285,9 +285,9 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
 	 * If all of the buffers are uptodate then we can set the page
 	 * uptodate.
 	 */
-	if (page_uptodate)
-		SetPageUptodate(page);
-	unlock_page(page);
+	if (folio_uptodate)
+		folio_mark_uptodate(folio);
+	folio_unlock(folio);
 	return;
 
 still_busy:
-- 
2.35.1


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

* [PATCH 05/12] buffer: Use b_folio in end_buffer_async_write()
  2022-12-15 21:43 [PATCH 00/12] Start converting buffer_heads to use folios Matthew Wilcox (Oracle)
                   ` (3 preceding siblings ...)
  2022-12-15 21:43 ` [PATCH 04/12] buffer: Use b_folio in end_buffer_async_read() Matthew Wilcox (Oracle)
@ 2022-12-15 21:43 ` Matthew Wilcox (Oracle)
  2022-12-15 21:43 ` [PATCH 06/12] page_io: Remove buffer_head include Matthew Wilcox (Oracle)
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-12-15 21:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel

Save 76 bytes from avoiding the call to compound_head() in SetPageError().
Also avoid the call to compound_head() in end_page_writeback().

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

diff --git a/fs/buffer.c b/fs/buffer.c
index 5bdcc040eca3..c44ca40530c3 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -344,21 +344,21 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate)
 	unsigned long flags;
 	struct buffer_head *first;
 	struct buffer_head *tmp;
-	struct page *page;
+	struct folio *folio;
 
 	BUG_ON(!buffer_async_write(bh));
 
-	page = bh->b_page;
+	folio = bh->b_folio;
 	if (uptodate) {
 		set_buffer_uptodate(bh);
 	} else {
 		buffer_io_error(bh, ", lost async page write");
 		mark_buffer_write_io_error(bh);
 		clear_buffer_uptodate(bh);
-		SetPageError(page);
+		folio_set_error(folio);
 	}
 
-	first = page_buffers(page);
+	first = folio_buffers(folio);
 	spin_lock_irqsave(&first->b_uptodate_lock, flags);
 
 	clear_buffer_async_write(bh);
@@ -372,7 +372,7 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate)
 		tmp = tmp->b_this_page;
 	}
 	spin_unlock_irqrestore(&first->b_uptodate_lock, flags);
-	end_page_writeback(page);
+	folio_end_writeback(folio);
 	return;
 
 still_busy:
-- 
2.35.1


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

* [PATCH 06/12] page_io: Remove buffer_head include
  2022-12-15 21:43 [PATCH 00/12] Start converting buffer_heads to use folios Matthew Wilcox (Oracle)
                   ` (4 preceding siblings ...)
  2022-12-15 21:43 ` [PATCH 05/12] buffer: Use b_folio in end_buffer_async_write() Matthew Wilcox (Oracle)
@ 2022-12-15 21:43 ` Matthew Wilcox (Oracle)
  2022-12-15 21:43 ` [PATCH 07/12] buffer: Use b_folio in mark_buffer_dirty() Matthew Wilcox (Oracle)
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-12-15 21:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel

page_io never uses buffer_heads to do I/O.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/page_io.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 3a5f921b932e..905d9fcc0c96 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -18,7 +18,6 @@
 #include <linux/swap.h>
 #include <linux/bio.h>
 #include <linux/swapops.h>
-#include <linux/buffer_head.h>
 #include <linux/writeback.h>
 #include <linux/frontswap.h>
 #include <linux/blkdev.h>
-- 
2.35.1


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

* [PATCH 07/12] buffer: Use b_folio in mark_buffer_dirty()
  2022-12-15 21:43 [PATCH 00/12] Start converting buffer_heads to use folios Matthew Wilcox (Oracle)
                   ` (5 preceding siblings ...)
  2022-12-15 21:43 ` [PATCH 06/12] page_io: Remove buffer_head include Matthew Wilcox (Oracle)
@ 2022-12-15 21:43 ` Matthew Wilcox (Oracle)
  2022-12-15 21:43 ` [PATCH 08/12] gfs2: Replace obvious uses of b_page with b_folio Matthew Wilcox (Oracle)
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-12-15 21:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel

Removes about four calls to compound_head().  Two of them are inline
which removes 132 bytes from the kernel text.

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

diff --git a/fs/buffer.c b/fs/buffer.c
index c44ca40530c3..7e42d67bcaad 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1095,16 +1095,16 @@ void mark_buffer_dirty(struct buffer_head *bh)
 	}
 
 	if (!test_set_buffer_dirty(bh)) {
-		struct page *page = bh->b_page;
+		struct folio *folio = bh->b_folio;
 		struct address_space *mapping = NULL;
 
-		lock_page_memcg(page);
-		if (!TestSetPageDirty(page)) {
-			mapping = page_mapping(page);
+		folio_memcg_lock(folio);
+		if (!folio_test_set_dirty(folio)) {
+			mapping = folio->mapping;
 			if (mapping)
-				__set_page_dirty(page, mapping, 0);
+				__folio_mark_dirty(folio, mapping, 0);
 		}
-		unlock_page_memcg(page);
+		folio_memcg_unlock(folio);
 		if (mapping)
 			__mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
 	}
-- 
2.35.1


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

* [PATCH 08/12] gfs2: Replace obvious uses of b_page with b_folio
  2022-12-15 21:43 [PATCH 00/12] Start converting buffer_heads to use folios Matthew Wilcox (Oracle)
                   ` (6 preceding siblings ...)
  2022-12-15 21:43 ` [PATCH 07/12] buffer: Use b_folio in mark_buffer_dirty() Matthew Wilcox (Oracle)
@ 2022-12-15 21:43 ` Matthew Wilcox (Oracle)
  2022-12-15 21:43 ` [PATCH 09/12] jbd2: " Matthew Wilcox (Oracle)
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-12-15 21:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel

These places just use b_page to get to the buffer's address_space.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/gfs2/glops.c   | 2 +-
 fs/gfs2/log.c     | 2 +-
 fs/gfs2/meta_io.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index d78b61ecc1cd..081422644ec5 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -39,7 +39,7 @@ static void gfs2_ail_error(struct gfs2_glock *gl, const struct buffer_head *bh)
 	       "AIL buffer %p: blocknr %llu state 0x%08lx mapping %p page "
 	       "state 0x%lx\n",
 	       bh, (unsigned long long)bh->b_blocknr, bh->b_state,
-	       bh->b_page->mapping, bh->b_page->flags);
+	       bh->b_folio->mapping, bh->b_folio->flags);
 	fs_err(sdp, "AIL glock %u:%llu mapping %p\n",
 	       gl->gl_name.ln_type, gl->gl_name.ln_number,
 	       gfs2_glock2aspace(gl));
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 723639376ae2..1fcc829f02ab 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -127,7 +127,7 @@ __acquires(&sdp->sd_ail_lock)
 			continue;
 		gl = bd->bd_gl;
 		list_move(&bd->bd_ail_st_list, &tr->tr_ail1_list);
-		mapping = bh->b_page->mapping;
+		mapping = bh->b_folio->mapping;
 		if (!mapping)
 			continue;
 		spin_unlock(&sdp->sd_ail_lock);
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index 3c41b864ee5b..924361fa510b 100644
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -334,7 +334,7 @@ int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh)
 
 void gfs2_remove_from_journal(struct buffer_head *bh, int meta)
 {
-	struct address_space *mapping = bh->b_page->mapping;
+	struct address_space *mapping = bh->b_folio->mapping;
 	struct gfs2_sbd *sdp = gfs2_mapping2sbd(mapping);
 	struct gfs2_bufdata *bd = bh->b_private;
 	struct gfs2_trans *tr = current->journal_info;
-- 
2.35.1


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

* [PATCH 09/12] jbd2: Replace obvious uses of b_page with b_folio
  2022-12-15 21:43 [PATCH 00/12] Start converting buffer_heads to use folios Matthew Wilcox (Oracle)
                   ` (7 preceding siblings ...)
  2022-12-15 21:43 ` [PATCH 08/12] gfs2: Replace obvious uses of b_page with b_folio Matthew Wilcox (Oracle)
@ 2022-12-15 21:43 ` Matthew Wilcox (Oracle)
  2022-12-15 21:44 ` [PATCH 10/12] nilfs2: " Matthew Wilcox (Oracle)
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-12-15 21:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel

These places just use b_page to get to the buffer's address_space
or have already been converted to folio.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/jbd2/commit.c  | 8 ++------
 fs/jbd2/journal.c | 2 +-
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 4810438b7856..96a1ebc6342d 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -63,16 +63,12 @@ static void journal_end_buffer_io_sync(struct buffer_head *bh, int uptodate)
 static void release_buffer_page(struct buffer_head *bh)
 {
 	struct folio *folio;
-	struct page *page;
 
 	if (buffer_dirty(bh))
 		goto nope;
 	if (atomic_read(&bh->b_count) != 1)
 		goto nope;
-	page = bh->b_page;
-	if (!page)
-		goto nope;
-	folio = page_folio(page);
+	folio = bh->b_folio;
 	if (folio->mapping)
 		goto nope;
 
@@ -1040,7 +1036,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
 			 * already detached from the mapping and buffers cannot
 			 * get reused.
 			 */
-			mapping = READ_ONCE(bh->b_page->mapping);
+			mapping = READ_ONCE(bh->b_folio->mapping);
 			if (mapping && !sb_is_blkdev_sb(mapping->host->i_sb)) {
 				clear_buffer_mapped(bh);
 				clear_buffer_new(bh);
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 2696f43e7239..4095fe91457f 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2938,7 +2938,7 @@ struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh)
 	} else {
 		J_ASSERT_BH(bh,
 			(atomic_read(&bh->b_count) > 0) ||
-			(bh->b_page && bh->b_page->mapping));
+			(bh->b_folio && bh->b_folio->mapping));
 
 		if (!new_jh) {
 			jbd_unlock_bh_journal_head(bh);
-- 
2.35.1


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

* [PATCH 10/12] nilfs2: Replace obvious uses of b_page with b_folio
  2022-12-15 21:43 [PATCH 00/12] Start converting buffer_heads to use folios Matthew Wilcox (Oracle)
                   ` (8 preceding siblings ...)
  2022-12-15 21:43 ` [PATCH 09/12] jbd2: " Matthew Wilcox (Oracle)
@ 2022-12-15 21:44 ` Matthew Wilcox (Oracle)
  2022-12-15 21:44 ` [PATCH 11/12] reiserfs: " Matthew Wilcox (Oracle)
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-12-15 21:44 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel

These places just use b_page to get to the buffer's address_space
or the index of the page the buffer is in.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/nilfs2/btnode.c  | 2 +-
 fs/nilfs2/btree.c   | 2 +-
 fs/nilfs2/gcinode.c | 2 +-
 fs/nilfs2/mdt.c     | 4 ++--
 fs/nilfs2/segment.c | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c
index e74fda212620..e956f886a1a1 100644
--- a/fs/nilfs2/btnode.c
+++ b/fs/nilfs2/btnode.c
@@ -188,7 +188,7 @@ int nilfs_btnode_prepare_change_key(struct address_space *btnc,
 		struct page *opage = obh->b_page;
 		lock_page(opage);
 retry:
-		/* BUG_ON(oldkey != obh->b_page->index); */
+		/* BUG_ON(oldkey != obh->b_folio->index); */
 		if (unlikely(oldkey != opage->index))
 			NILFS_PAGE_BUG(opage,
 				       "invalid oldkey %lld (newkey=%lld)",
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
index b9d15c3df3cc..6b914217b0c7 100644
--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -398,7 +398,7 @@ int nilfs_btree_broken_node_block(struct buffer_head *bh)
 	if (buffer_nilfs_checked(bh))
 		return 0;
 
-	inode = bh->b_page->mapping->host;
+	inode = bh->b_folio->mapping->host;
 	ret = nilfs_btree_node_broken((struct nilfs_btree_node *)bh->b_data,
 				      bh->b_size, inode, bh->b_blocknr);
 	if (likely(!ret))
diff --git a/fs/nilfs2/gcinode.c b/fs/nilfs2/gcinode.c
index b0d22ff24b67..48fe71d309cb 100644
--- a/fs/nilfs2/gcinode.c
+++ b/fs/nilfs2/gcinode.c
@@ -140,7 +140,7 @@ int nilfs_gccache_wait_and_mark_dirty(struct buffer_head *bh)
 {
 	wait_on_buffer(bh);
 	if (!buffer_uptodate(bh)) {
-		struct inode *inode = bh->b_page->mapping->host;
+		struct inode *inode = bh->b_folio->mapping->host;
 
 		nilfs_err(inode->i_sb,
 			  "I/O error reading %s block for GC (ino=%lu, vblocknr=%llu)",
diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c
index cbf4fa60eea2..19c8158605ed 100644
--- a/fs/nilfs2/mdt.c
+++ b/fs/nilfs2/mdt.c
@@ -563,7 +563,7 @@ int nilfs_mdt_freeze_buffer(struct inode *inode, struct buffer_head *bh)
 	struct page *page;
 	int blkbits = inode->i_blkbits;
 
-	page = grab_cache_page(shadow->inode->i_mapping, bh->b_page->index);
+	page = grab_cache_page(shadow->inode->i_mapping, bh->b_folio->index);
 	if (!page)
 		return -ENOMEM;
 
@@ -595,7 +595,7 @@ nilfs_mdt_get_frozen_buffer(struct inode *inode, struct buffer_head *bh)
 	struct page *page;
 	int n;
 
-	page = find_lock_page(shadow->inode->i_mapping, bh->b_page->index);
+	page = find_lock_page(shadow->inode->i_mapping, bh->b_folio->index);
 	if (page) {
 		if (page_has_buffers(page)) {
 			n = bh_offset(bh) >> inode->i_blkbits;
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 3335ef352915..05a151e5c52b 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -1581,7 +1581,7 @@ nilfs_segctor_update_payload_blocknr(struct nilfs_sc_info *sci,
 			nblocks = le32_to_cpu(finfo->fi_nblocks);
 			ndatablk = le32_to_cpu(finfo->fi_ndatablk);
 
-			inode = bh->b_page->mapping->host;
+			inode = bh->b_folio->mapping->host;
 
 			if (mode == SC_LSEG_DSYNC)
 				sc_op = &nilfs_sc_dsync_ops;
-- 
2.35.1


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

* [PATCH 11/12] reiserfs: Replace obvious uses of b_page with b_folio
  2022-12-15 21:43 [PATCH 00/12] Start converting buffer_heads to use folios Matthew Wilcox (Oracle)
                   ` (9 preceding siblings ...)
  2022-12-15 21:44 ` [PATCH 10/12] nilfs2: " Matthew Wilcox (Oracle)
@ 2022-12-15 21:44 ` Matthew Wilcox (Oracle)
  2022-12-15 21:44 ` [PATCH 12/12] mpage: Use b_folio in do_mpage_readpage() Matthew Wilcox (Oracle)
  2023-01-12 12:01 ` [PATCH 00/12] Start converting buffer_heads to use folios Jan Kara
  12 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-12-15 21:44 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel

These places just use b_page to get to the buffer's address_space
or call page_folio() on b_page to get a folio.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/reiserfs/journal.c         | 4 ++--
 fs/reiserfs/tail_conversion.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 9f62da7471c9..9ce4ec296b74 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -601,7 +601,7 @@ static int journal_list_still_alive(struct super_block *s,
  */
 static void release_buffer_page(struct buffer_head *bh)
 {
-	struct folio *folio = page_folio(bh->b_page);
+	struct folio *folio = bh->b_folio;
 	if (!folio->mapping && folio_trylock(folio)) {
 		folio_get(folio);
 		put_bh(bh);
@@ -866,7 +866,7 @@ static int write_ordered_buffers(spinlock_t * lock,
 		 * will ever write the buffer. We're safe if we write the
 		 * page one last time after freeing the journal header.
 		 */
-		if (buffer_dirty(bh) && unlikely(bh->b_page->mapping == NULL)) {
+		if (buffer_dirty(bh) && unlikely(bh->b_folio->mapping == NULL)) {
 			spin_unlock(lock);
 			write_dirty_buffer(bh, 0);
 			spin_lock(lock);
diff --git a/fs/reiserfs/tail_conversion.c b/fs/reiserfs/tail_conversion.c
index b0ae088dffc7..2cec61af2a9e 100644
--- a/fs/reiserfs/tail_conversion.c
+++ b/fs/reiserfs/tail_conversion.c
@@ -177,7 +177,7 @@ void reiserfs_unmap_buffer(struct buffer_head *bh)
 	 * BUG() on attempt to write not mapped buffer
 	 */
 	if ((!list_empty(&bh->b_assoc_buffers) || bh->b_private) && bh->b_page) {
-		struct inode *inode = bh->b_page->mapping->host;
+		struct inode *inode = bh->b_folio->mapping->host;
 		struct reiserfs_journal *j = SB_JOURNAL(inode->i_sb);
 		spin_lock(&j->j_dirty_buffers_lock);
 		list_del_init(&bh->b_assoc_buffers);
-- 
2.35.1


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

* [PATCH 12/12] mpage: Use b_folio in do_mpage_readpage()
  2022-12-15 21:43 [PATCH 00/12] Start converting buffer_heads to use folios Matthew Wilcox (Oracle)
                   ` (10 preceding siblings ...)
  2022-12-15 21:44 ` [PATCH 11/12] reiserfs: " Matthew Wilcox (Oracle)
@ 2022-12-15 21:44 ` Matthew Wilcox (Oracle)
  2023-01-12 12:01 ` [PATCH 00/12] Start converting buffer_heads to use folios Jan Kara
  12 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-12-15 21:44 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel

Remove this conversion of a folio back to a page.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/mpage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/mpage.c b/fs/mpage.c
index 0f8ae954a579..db59cbf6affc 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -198,7 +198,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args)
 	/*
 	 * Then do more get_blocks calls until we are done with this folio.
 	 */
-	map_bh->b_page = &folio->page;
+	map_bh->b_folio = folio;
 	while (page_block < blocks_per_page) {
 		map_bh->b_state = 0;
 		map_bh->b_size = 0;
-- 
2.35.1


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

* Re: [PATCH 00/12] Start converting buffer_heads to use folios
  2022-12-15 21:43 [PATCH 00/12] Start converting buffer_heads to use folios Matthew Wilcox (Oracle)
                   ` (11 preceding siblings ...)
  2022-12-15 21:44 ` [PATCH 12/12] mpage: Use b_folio in do_mpage_readpage() Matthew Wilcox (Oracle)
@ 2023-01-12 12:01 ` Jan Kara
  12 siblings, 0 replies; 14+ messages in thread
From: Jan Kara @ 2023-01-12 12:01 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: Andrew Morton, linux-fsdevel

On Thu 15-12-22 21:43:50, Matthew Wilcox (Oracle) wrote:
> I was hoping that filesystems would convert from buffer_heads to iomap,
> but that's not happening particularly quickly.  So the buffer_head
> infrastructure needs to be converted from being page-based to being
> folio-based.  This is the initial patchset that I hope Andrew will take
> for 6.3.  I have a lot of followup patches, but many of them should go
> through individual filesystem trees (ext4, f2fs, etc).  They can wait
> for 6.4.

FWIW I went through all the patches and they look fine to me so feel free
to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> 
> Matthew Wilcox (Oracle) (12):
>   buffer: Add b_folio as an alias of b_page
>   buffer: Replace obvious uses of b_page with b_folio
>   buffer: Use b_folio in touch_buffer()
>   buffer: Use b_folio in end_buffer_async_read()
>   buffer: Use b_folio in end_buffer_async_write()
>   page_io: Remove buffer_head include
>   buffer: Use b_folio in mark_buffer_dirty()
>   gfs2: Replace obvious uses of b_page with b_folio
>   jbd2: Replace obvious uses of b_page with b_folio
>   nilfs2: Replace obvious uses of b_page with b_folio
>   reiserfs: Replace obvious uses of b_page with b_folio
>   mpage: Use b_folio in do_mpage_readpage()
> 
>  fs/buffer.c                   | 54 +++++++++++++++++------------------
>  fs/gfs2/glops.c               |  2 +-
>  fs/gfs2/log.c                 |  2 +-
>  fs/gfs2/meta_io.c             |  2 +-
>  fs/jbd2/commit.c              |  8 ++----
>  fs/jbd2/journal.c             |  2 +-
>  fs/mpage.c                    |  2 +-
>  fs/nilfs2/btnode.c            |  2 +-
>  fs/nilfs2/btree.c             |  2 +-
>  fs/nilfs2/gcinode.c           |  2 +-
>  fs/nilfs2/mdt.c               |  4 +--
>  fs/nilfs2/segment.c           |  2 +-
>  fs/reiserfs/journal.c         |  4 +--
>  fs/reiserfs/tail_conversion.c |  2 +-
>  include/linux/buffer_head.h   |  5 +++-
>  mm/page_io.c                  |  1 -
>  16 files changed, 47 insertions(+), 49 deletions(-)
> 
> -- 
> 2.35.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

end of thread, other threads:[~2023-01-12 12:07 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-15 21:43 [PATCH 00/12] Start converting buffer_heads to use folios Matthew Wilcox (Oracle)
2022-12-15 21:43 ` [PATCH 01/12] buffer: Add b_folio as an alias of b_page Matthew Wilcox (Oracle)
2022-12-15 21:43 ` [PATCH 02/12] buffer: Replace obvious uses of b_page with b_folio Matthew Wilcox (Oracle)
2022-12-15 21:43 ` [PATCH 03/12] buffer: Use b_folio in touch_buffer() Matthew Wilcox (Oracle)
2022-12-15 21:43 ` [PATCH 04/12] buffer: Use b_folio in end_buffer_async_read() Matthew Wilcox (Oracle)
2022-12-15 21:43 ` [PATCH 05/12] buffer: Use b_folio in end_buffer_async_write() Matthew Wilcox (Oracle)
2022-12-15 21:43 ` [PATCH 06/12] page_io: Remove buffer_head include Matthew Wilcox (Oracle)
2022-12-15 21:43 ` [PATCH 07/12] buffer: Use b_folio in mark_buffer_dirty() Matthew Wilcox (Oracle)
2022-12-15 21:43 ` [PATCH 08/12] gfs2: Replace obvious uses of b_page with b_folio Matthew Wilcox (Oracle)
2022-12-15 21:43 ` [PATCH 09/12] jbd2: " Matthew Wilcox (Oracle)
2022-12-15 21:44 ` [PATCH 10/12] nilfs2: " Matthew Wilcox (Oracle)
2022-12-15 21:44 ` [PATCH 11/12] reiserfs: " Matthew Wilcox (Oracle)
2022-12-15 21:44 ` [PATCH 12/12] mpage: Use b_folio in do_mpage_readpage() Matthew Wilcox (Oracle)
2023-01-12 12:01 ` [PATCH 00/12] Start converting buffer_heads to use folios Jan Kara

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).