aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2016-09-09 19:48:15 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2016-09-12 16:55:11 -0400
commitf4702d61eb53466251eeb677f9784e047e1caf0c (patch)
tree87ef653ed65085473df70fbd4d87d2b0c7e9e50e
parent7f3037a5ec0672e03f96d4b0b86169c4c48e479e (diff)
f2fs: add common iget in add_fsync_inode
There is no functional change. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/recovery.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index ba0fc2ec7caf..1269277773f5 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -68,14 +68,20 @@ static struct fsync_inode_entry *get_fsync_inode(struct list_head *head,
68 return NULL; 68 return NULL;
69} 69}
70 70
71static struct fsync_inode_entry *add_fsync_inode(struct list_head *head, 71static struct fsync_inode_entry *add_fsync_inode(struct f2fs_sb_info *sbi,
72 struct inode *inode) 72 struct list_head *head, nid_t ino)
73{ 73{
74 struct inode *inode = f2fs_iget(sbi->sb, ino);
74 struct fsync_inode_entry *entry; 75 struct fsync_inode_entry *entry;
75 76
77 if (IS_ERR(inode))
78 return ERR_CAST(inode);
79
76 entry = kmem_cache_alloc(fsync_entry_slab, GFP_F2FS_ZERO); 80 entry = kmem_cache_alloc(fsync_entry_slab, GFP_F2FS_ZERO);
77 if (!entry) 81 if (!entry) {
78 return NULL; 82 iput(inode);
83 return ERR_PTR(-ENOMEM);
84 }
79 85
80 entry->inode = inode; 86 entry->inode = inode;
81 list_add_tail(&entry->list, head); 87 list_add_tail(&entry->list, head);
@@ -105,16 +111,10 @@ static int recover_dentry(struct inode *inode, struct page *ipage,
105 111
106 entry = get_fsync_inode(dir_list, pino); 112 entry = get_fsync_inode(dir_list, pino);
107 if (!entry) { 113 if (!entry) {
108 dir = f2fs_iget(inode->i_sb, pino); 114 entry = add_fsync_inode(F2FS_I_SB(inode), dir_list, pino);
109 if (IS_ERR(dir)) { 115 if (IS_ERR(entry)) {
110 err = PTR_ERR(dir); 116 dir = ERR_CAST(entry);
111 goto out; 117 err = PTR_ERR(entry);
112 }
113
114 entry = add_fsync_inode(dir_list, dir);
115 if (!entry) {
116 err = -ENOMEM;
117 iput(dir);
118 goto out; 118 goto out;
119 } 119 }
120 } 120 }
@@ -228,7 +228,6 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
228{ 228{
229 unsigned long long cp_ver = cur_cp_version(F2FS_CKPT(sbi)); 229 unsigned long long cp_ver = cur_cp_version(F2FS_CKPT(sbi));
230 struct curseg_info *curseg; 230 struct curseg_info *curseg;
231 struct inode *inode;
232 struct page *page = NULL; 231 struct page *page = NULL;
233 block_t blkaddr; 232 block_t blkaddr;
234 int err = 0; 233 int err = 0;
@@ -266,23 +265,15 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
266 * CP | dnode(F) | inode(DF) 265 * CP | dnode(F) | inode(DF)
267 * For this case, we should not give up now. 266 * For this case, we should not give up now.
268 */ 267 */
269 inode = f2fs_iget(sbi->sb, ino_of_node(page)); 268 entry = add_fsync_inode(sbi, head, ino_of_node(page));
270 if (IS_ERR(inode)) { 269 if (IS_ERR(entry)) {
271 err = PTR_ERR(inode); 270 err = PTR_ERR(entry);
272 if (err == -ENOENT) { 271 if (err == -ENOENT) {
273 err = 0; 272 err = 0;
274 goto next; 273 goto next;
275 } 274 }
276 break; 275 break;
277 } 276 }
278
279 /* add this fsync inode to the list */
280 entry = add_fsync_inode(head, inode);
281 if (!entry) {
282 err = -ENOMEM;
283 iput(inode);
284 break;
285 }
286 } 277 }
287 entry->blkaddr = blkaddr; 278 entry->blkaddr = blkaddr;
288 279