Commit f4702d61 authored by Jaegeuk Kim's avatar Jaegeuk Kim

f2fs: add common iget in add_fsync_inode

There is no functional change.
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 7f3037a5
...@@ -68,14 +68,20 @@ static struct fsync_inode_entry *get_fsync_inode(struct list_head *head, ...@@ -68,14 +68,20 @@ static struct fsync_inode_entry *get_fsync_inode(struct list_head *head,
return NULL; return NULL;
} }
static struct fsync_inode_entry *add_fsync_inode(struct list_head *head, static struct fsync_inode_entry *add_fsync_inode(struct f2fs_sb_info *sbi,
struct inode *inode) struct list_head *head, nid_t ino)
{ {
struct inode *inode = f2fs_iget(sbi->sb, ino);
struct fsync_inode_entry *entry; struct fsync_inode_entry *entry;
if (IS_ERR(inode))
return ERR_CAST(inode);
entry = kmem_cache_alloc(fsync_entry_slab, GFP_F2FS_ZERO); entry = kmem_cache_alloc(fsync_entry_slab, GFP_F2FS_ZERO);
if (!entry) if (!entry) {
return NULL; iput(inode);
return ERR_PTR(-ENOMEM);
}
entry->inode = inode; entry->inode = inode;
list_add_tail(&entry->list, head); list_add_tail(&entry->list, head);
...@@ -105,16 +111,10 @@ static int recover_dentry(struct inode *inode, struct page *ipage, ...@@ -105,16 +111,10 @@ static int recover_dentry(struct inode *inode, struct page *ipage,
entry = get_fsync_inode(dir_list, pino); entry = get_fsync_inode(dir_list, pino);
if (!entry) { if (!entry) {
dir = f2fs_iget(inode->i_sb, pino); entry = add_fsync_inode(F2FS_I_SB(inode), dir_list, pino);
if (IS_ERR(dir)) { if (IS_ERR(entry)) {
err = PTR_ERR(dir); dir = ERR_CAST(entry);
goto out; err = PTR_ERR(entry);
}
entry = add_fsync_inode(dir_list, dir);
if (!entry) {
err = -ENOMEM;
iput(dir);
goto out; goto out;
} }
} }
...@@ -228,7 +228,6 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head) ...@@ -228,7 +228,6 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
{ {
unsigned long long cp_ver = cur_cp_version(F2FS_CKPT(sbi)); unsigned long long cp_ver = cur_cp_version(F2FS_CKPT(sbi));
struct curseg_info *curseg; struct curseg_info *curseg;
struct inode *inode;
struct page *page = NULL; struct page *page = NULL;
block_t blkaddr; block_t blkaddr;
int err = 0; int err = 0;
...@@ -266,23 +265,15 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head) ...@@ -266,23 +265,15 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
* CP | dnode(F) | inode(DF) * CP | dnode(F) | inode(DF)
* For this case, we should not give up now. * For this case, we should not give up now.
*/ */
inode = f2fs_iget(sbi->sb, ino_of_node(page)); entry = add_fsync_inode(sbi, head, ino_of_node(page));
if (IS_ERR(inode)) { if (IS_ERR(entry)) {
err = PTR_ERR(inode); err = PTR_ERR(entry);
if (err == -ENOENT) { if (err == -ENOENT) {
err = 0; err = 0;
goto next; goto next;
} }
break; break;
} }
/* add this fsync inode to the list */
entry = add_fsync_inode(head, inode);
if (!entry) {
err = -ENOMEM;
iput(inode);
break;
}
} }
entry->blkaddr = blkaddr; entry->blkaddr = blkaddr;
......
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