Re: [PATCH 17/27] f2fs: Add f2fs_get_node_folio()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2025/2/18 13:51, Matthew Wilcox (Oracle) wrote:
Change __get_node_page() to return a folio and convert back to a page in
f2fs_get_node_page() and f2fs_get_node_page_ra().

Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
---
  fs/f2fs/f2fs.h |  1 +
  fs/f2fs/node.c | 18 +++++++++++++-----
  2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index bbaa61da83a8..8f23bb082c6f 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3689,6 +3689,7 @@ struct page *f2fs_new_inode_page(struct inode *inode);
  struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs);
  void f2fs_ra_node_page(struct f2fs_sb_info *sbi, nid_t nid);
  struct page *f2fs_get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid);
+struct folio *f2fs_get_node_folio(struct f2fs_sb_info *sbi, pgoff_t nid);
  struct page *f2fs_get_node_page_ra(struct page *parent, int start);
  int f2fs_move_node_page(struct page *node_page, int gc_type);
  void f2fs_flush_inline_data(struct f2fs_sb_info *sbi);
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index da28e295c701..2d161ddda9c3 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1449,7 +1449,7 @@ void f2fs_ra_node_page(struct f2fs_sb_info *sbi, nid_t nid)
  	f2fs_put_page(apage, err ? 1 : 0);
  }
-static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
+static struct folio *__get_node_folio(struct f2fs_sb_info *sbi, pgoff_t nid,
  					struct page *parent, int start)
  {
  	struct folio *folio;
@@ -1462,7 +1462,7 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
  repeat:
  	folio = f2fs_grab_cache_folio(NODE_MAPPING(sbi), nid, false);
  	if (IS_ERR(folio))
-		return ERR_CAST(folio);
+		return folio;
err = read_node_page(&folio->page, 0);
  	if (err < 0) {
@@ -1493,7 +1493,7 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
  	}
  page_hit:
  	if (likely(nid == nid_of_node(&folio->page)))
-		return &folio->page;
+		return folio;
f2fs_warn(sbi, "inconsistent node block, nid:%lu, node_footer[nid:%u,ino:%u,ofs:%u,cpver:%llu,blkaddr:%u]",
  			  nid, nid_of_node(&folio->page), ino_of_node(&folio->page),
@@ -1512,17 +1512,25 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
  	return ERR_PTR(err);
  }
+struct folio *f2fs_get_node_folio(struct f2fs_sb_info *sbi, pgoff_t nid)
+{
+	return __get_node_folio(sbi, nid, NULL, 0);
+}
+
  struct page *f2fs_get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
  {
-	return __get_node_page(sbi, nid, NULL, 0);
+	struct folio *folio = __get_node_folio(sbi, nid, NULL, 0);
+

	if (IS_ERR(folio))
		return ERR_CAST(folio));

+	return &folio->page;
  }
struct page *f2fs_get_node_page_ra(struct page *parent, int start)
  {
  	struct f2fs_sb_info *sbi = F2FS_P_SB(parent);
  	nid_t nid = get_nid(parent, start, false);
+	struct folio *folio = __get_node_folio(sbi, nid, parent, start);

	if (IS_ERR(folio))
		return ERR_CAST(folio));

-	return __get_node_page(sbi, nid, parent, start);
+	return &folio->page;
  }
static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino)





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux