aboutsummaryrefslogtreecommitdiff
path: root/fs/f2fs/node.c
diff options
context:
space:
mode:
authorChao Yu <chao@kernel.org>2025-03-05 17:11:47 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2025-03-11 03:25:53 +0000
commit2aac2538a97d35b0a1beb60dce6001f5625b82e6 (patch)
tree6952af0ed6843f43ee3b62e2f47267dcbe157a34 /fs/f2fs/node.c
parent1cf6b5670af1f4e9d5bf2f7201e368733c59cbdd (diff)
f2fs: do sanity check on xattr node footer in f2fs_get_xnode_page()
This patch introduces a new wrapper f2fs_get_xnode_page(), then, caller can use it to load xattr block to page cache, meanwhile it will do sanity check on xattr node footer. Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/node.c')
-rw-r--r--fs/f2fs/node.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 89f1b4b92776..f958ce9f58ae 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1245,7 +1245,7 @@ int f2fs_truncate_xattr_node(struct inode *inode)
if (!nid)
return 0;
- npage = f2fs_get_node_page(sbi, nid);
+ npage = f2fs_get_xnode_page(sbi, nid);
if (IS_ERR(npage))
return PTR_ERR(npage);
@@ -1461,7 +1461,9 @@ static int sanity_check_node_footer(struct f2fs_sb_info *sbi,
enum node_type ntype)
{
if (unlikely(nid != nid_of_node(page) ||
- (ntype == NODE_TYPE_INODE && !IS_INODE(page)))) {
+ (ntype == NODE_TYPE_INODE && !IS_INODE(page)) ||
+ (ntype == NODE_TYPE_XATTR &&
+ !f2fs_has_xattr_block(ofs_of_node(page))))) {
f2fs_warn(sbi, "inconsistent node block, node_type:%d, nid:%lu, "
"node_footer[nid:%u,ino:%u,ofs:%u,cpver:%llu,blkaddr:%u]",
ntype, nid, nid_of_node(page), ino_of_node(page),
@@ -1551,6 +1553,14 @@ struct page *f2fs_get_inode_page(struct f2fs_sb_info *sbi, pgoff_t ino)
return &folio->page;
}
+struct page *f2fs_get_xnode_page(struct f2fs_sb_info *sbi, pgoff_t xnid)
+{
+ struct folio *folio = __get_node_folio(sbi, xnid, NULL, 0,
+ NODE_TYPE_XATTR);
+
+ return &folio->page;
+}
+
struct page *f2fs_get_node_page_ra(struct page *parent, int start)
{
struct f2fs_sb_info *sbi = F2FS_P_SB(parent);