All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Dave Kleikamp <shaggy@kernel.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	jfs-discussion@lists.sourceforge.net,
	linux-fsdevel@vger.kernel.org
Subject: [PATCH v2 01/13] jfs: Convert metapage_read_folio to use folio APIs
Date: Wed, 17 Apr 2024 18:56:45 +0100	[thread overview]
Message-ID: <20240417175659.818299-2-willy@infradead.org> (raw)
In-Reply-To: <20240417175659.818299-1-willy@infradead.org>

Use bio_add_folio_nofail() as we just allocated the bio and know
it cannot fail.  Other than that, this is a 1:1 conversion from
page APIs to folio APIs.

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

diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 961569c11159..8266c43ec728 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -266,14 +266,14 @@ static void last_read_complete(struct page *page)
 
 static void metapage_read_end_io(struct bio *bio)
 {
-	struct page *page = bio->bi_private;
+	struct folio *folio = bio->bi_private;
 
 	if (bio->bi_status) {
 		printk(KERN_ERR "metapage_read_end_io: I/O error\n");
-		SetPageError(page);
+		folio_set_error(folio);
 	}
 
-	dec_io(page, last_read_complete);
+	dec_io(&folio->page, last_read_complete);
 	bio_put(bio);
 }
 
@@ -469,20 +469,18 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc)
 
 static int metapage_read_folio(struct file *fp, struct folio *folio)
 {
-	struct page *page = &folio->page;
-	struct inode *inode = page->mapping->host;
+	struct inode *inode = folio->mapping->host;
 	struct bio *bio = NULL;
 	int block_offset;
-	int blocks_per_page = i_blocks_per_page(inode, page);
+	int blocks_per_page = i_blocks_per_folio(inode, folio);
 	sector_t page_start;	/* address of page in fs blocks */
 	sector_t pblock;
 	int xlen;
 	unsigned int len;
 	int offset;
 
-	BUG_ON(!PageLocked(page));
-	page_start = (sector_t)page->index <<
-		     (PAGE_SHIFT - inode->i_blkbits);
+	BUG_ON(!folio_test_locked(folio));
+	page_start = folio_pos(folio) >> inode->i_blkbits;
 
 	block_offset = 0;
 	while (block_offset < blocks_per_page) {
@@ -490,9 +488,9 @@ static int metapage_read_folio(struct file *fp, struct folio *folio)
 		pblock = metapage_get_blocks(inode, page_start + block_offset,
 					     &xlen);
 		if (pblock) {
-			if (!PagePrivate(page))
-				insert_metapage(page, NULL);
-			inc_io(page);
+			if (!folio->private)
+				insert_metapage(&folio->page, NULL);
+			inc_io(&folio->page);
 			if (bio)
 				submit_bio(bio);
 
@@ -501,11 +499,10 @@ static int metapage_read_folio(struct file *fp, struct folio *folio)
 			bio->bi_iter.bi_sector =
 				pblock << (inode->i_blkbits - 9);
 			bio->bi_end_io = metapage_read_end_io;
-			bio->bi_private = page;
+			bio->bi_private = folio;
 			len = xlen << inode->i_blkbits;
 			offset = block_offset << inode->i_blkbits;
-			if (bio_add_page(bio, page, len, offset) < len)
-				goto add_failed;
+			bio_add_folio_nofail(bio, folio, len, offset);
 			block_offset += xlen;
 		} else
 			block_offset++;
@@ -513,15 +510,9 @@ static int metapage_read_folio(struct file *fp, struct folio *folio)
 	if (bio)
 		submit_bio(bio);
 	else
-		unlock_page(page);
+		folio_unlock(folio);
 
 	return 0;
-
-add_failed:
-	printk(KERN_ERR "JFS: bio_add_page failed unexpectedly\n");
-	bio_put(bio);
-	dec_io(page, last_read_complete);
-	return -EIO;
 }
 
 static bool metapage_release_folio(struct folio *folio, gfp_t gfp_mask)
-- 
2.43.0


  reply	other threads:[~2024-04-17 17:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-17 17:56 [PATCH v2 00/13] JFS folio conversion Matthew Wilcox (Oracle)
2024-04-17 17:56 ` Matthew Wilcox (Oracle) [this message]
2024-04-17 17:56 ` [PATCH v2 02/13] jfs: Convert metapage_writepage to metapage_write_folio Matthew Wilcox (Oracle)
2024-04-17 17:56 ` [PATCH v2 03/13] jfs: Convert __get_metapage to use a folio Matthew Wilcox (Oracle)
2024-04-17 17:56 ` [PATCH v2 04/13] jfs: Convert insert_metapage() to take " Matthew Wilcox (Oracle)
2024-04-17 17:56 ` [PATCH v2 05/13] jfs; Convert release_metapage to use " Matthew Wilcox (Oracle)
2024-04-17 17:56 ` [PATCH v2 06/13] jfs: Convert drop_metapage and remove_metapage to take " Matthew Wilcox (Oracle)
2024-04-17 17:56 ` [PATCH v2 07/13] jfs: Convert dec_io " Matthew Wilcox (Oracle)
2024-04-17 17:56 ` [PATCH v2 08/13] jfs; Convert __invalidate_metapages to use " Matthew Wilcox (Oracle)
2024-04-17 17:56 ` [PATCH v2 09/13] jfs: Convert page_to_mp to folio_to_mp Matthew Wilcox (Oracle)
2024-04-17 17:56 ` [PATCH v2 10/13] jfs: Convert inc_io to take a folio Matthew Wilcox (Oracle)
2024-04-17 17:56 ` [PATCH v2 11/13] jfs: Convert force_metapage to use " Matthew Wilcox (Oracle)
2024-04-17 17:56 ` [PATCH v2 12/13] jfs: Change metapage->page to metapage->folio Matthew Wilcox (Oracle)
2024-04-17 17:56 ` [PATCH v2 13/13] fs: Remove i_blocks_per_page Matthew Wilcox (Oracle)
2024-04-18 14:37 ` [PATCH v2 14/13] jfs: Stop using PG_error Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240417175659.818299-2-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=shaggy@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.