Commit 1c35a90e authored by Jaegeuk Kim's avatar Jaegeuk Kim

f2fs: fix to recover inline_xattr/data and blocks

This patch fixes not to skip xattr recovery and inline xattr/data recovery
order.
Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent e3b4d43f
...@@ -1205,7 +1205,7 @@ void alloc_nid_failed(struct f2fs_sb_info *, nid_t); ...@@ -1205,7 +1205,7 @@ void alloc_nid_failed(struct f2fs_sb_info *, nid_t);
void recover_node_page(struct f2fs_sb_info *, struct page *, void recover_node_page(struct f2fs_sb_info *, struct page *,
struct f2fs_summary *, struct node_info *, block_t); struct f2fs_summary *, struct node_info *, block_t);
void recover_inline_xattr(struct inode *, struct page *); void recover_inline_xattr(struct inode *, struct page *);
bool recover_xattr_data(struct inode *, struct page *, block_t); void recover_xattr_data(struct inode *, struct page *, block_t);
int recover_inode_page(struct f2fs_sb_info *, struct page *); int recover_inode_page(struct f2fs_sb_info *, struct page *);
int restore_node_summary(struct f2fs_sb_info *, unsigned int, int restore_node_summary(struct f2fs_sb_info *, unsigned int,
struct f2fs_summary_block *); struct f2fs_summary_block *);
......
...@@ -1557,9 +1557,6 @@ void recover_inline_xattr(struct inode *inode, struct page *page) ...@@ -1557,9 +1557,6 @@ void recover_inline_xattr(struct inode *inode, struct page *page)
struct page *ipage; struct page *ipage;
struct f2fs_inode *ri; struct f2fs_inode *ri;
if (!IS_INODE(page))
return;
ipage = get_node_page(sbi, inode->i_ino); ipage = get_node_page(sbi, inode->i_ino);
f2fs_bug_on(IS_ERR(ipage)); f2fs_bug_on(IS_ERR(ipage));
...@@ -1580,16 +1577,13 @@ void recover_inline_xattr(struct inode *inode, struct page *page) ...@@ -1580,16 +1577,13 @@ void recover_inline_xattr(struct inode *inode, struct page *page)
f2fs_put_page(ipage, 1); f2fs_put_page(ipage, 1);
} }
bool recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr) void recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr)
{ {
struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
nid_t prev_xnid = F2FS_I(inode)->i_xattr_nid; nid_t prev_xnid = F2FS_I(inode)->i_xattr_nid;
nid_t new_xnid = nid_of_node(page); nid_t new_xnid = nid_of_node(page);
struct node_info ni; struct node_info ni;
if (!f2fs_has_xattr_block(ofs_of_node(page)))
return false;
/* 1: invalidate the previous xattr nid */ /* 1: invalidate the previous xattr nid */
if (!prev_xnid) if (!prev_xnid)
goto recover_xnid; goto recover_xnid;
...@@ -1617,7 +1611,6 @@ bool recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr) ...@@ -1617,7 +1611,6 @@ bool recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr)
set_node_addr(sbi, &ni, blkaddr, false); set_node_addr(sbi, &ni, blkaddr, false);
update_inode_page(inode); update_inode_page(inode);
return true;
} }
int recover_inode_page(struct f2fs_sb_info *sbi, struct page *page) int recover_inode_page(struct f2fs_sb_info *sbi, struct page *page)
......
...@@ -302,14 +302,19 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode, ...@@ -302,14 +302,19 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
struct node_info ni; struct node_info ni;
int err = 0, recovered = 0; int err = 0, recovered = 0;
/* step 1: recover xattr */
if (IS_INODE(page)) {
recover_inline_xattr(inode, page); recover_inline_xattr(inode, page);
} else if (f2fs_has_xattr_block(ofs_of_node(page))) {
if (recover_inline_data(inode, page)) recover_xattr_data(inode, page, blkaddr);
goto out; goto out;
}
if (recover_xattr_data(inode, page, blkaddr)) /* step 2: recover inline data */
if (recover_inline_data(inode, page))
goto out; goto out;
/* step 3: recover data indices */
start = start_bidx_of_node(ofs_of_node(page), fi); start = start_bidx_of_node(ofs_of_node(page), fi);
end = start + ADDRS_PER_PAGE(page, fi); end = start + ADDRS_PER_PAGE(page, fi);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment