blob: d56d951c22537a14a9f103c679e93e64321d863f [file] [log] [blame]
Jaegeuk Kim0a8165d2012-11-29 13:28:09 +09001/*
Jaegeuk Kimd624c962012-11-02 17:13:32 +09002 * fs/f2fs/recovery.c
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#include <linux/fs.h>
12#include <linux/f2fs_fs.h>
13#include "f2fs.h"
14#include "node.h"
15#include "segment.h"
16
17static struct kmem_cache *fsync_entry_slab;
18
19bool space_for_roll_forward(struct f2fs_sb_info *sbi)
20{
21 if (sbi->last_valid_block_count + sbi->alloc_valid_block_count
22 > sbi->user_block_count)
23 return false;
24 return true;
25}
26
27static struct fsync_inode_entry *get_fsync_inode(struct list_head *head,
28 nid_t ino)
29{
30 struct list_head *this;
31 struct fsync_inode_entry *entry;
32
33 list_for_each(this, head) {
34 entry = list_entry(this, struct fsync_inode_entry, list);
35 if (entry->inode->i_ino == ino)
36 return entry;
37 }
38 return NULL;
39}
40
41static int recover_dentry(struct page *ipage, struct inode *inode)
42{
Jaegeuk Kim9a55ed62013-05-20 10:23:40 +090043 void *kaddr = page_address(ipage);
44 struct f2fs_node *raw_node = (struct f2fs_node *)kaddr;
Jaegeuk Kimd624c962012-11-02 17:13:32 +090045 struct f2fs_inode *raw_inode = &(raw_node->i);
Jaegeuk Kim74d0b912013-05-15 16:40:02 +090046 nid_t pino = le32_to_cpu(raw_inode->i_pino);
Jaegeuk Kim6b8213d2013-05-28 09:19:22 +090047 struct f2fs_dir_entry *de;
Al Virob7f7a5e2013-01-25 16:15:43 -050048 struct qstr name;
Jaegeuk Kimd624c962012-11-02 17:13:32 +090049 struct page *page;
Jaegeuk Kim6b8213d2013-05-28 09:19:22 +090050 struct inode *dir, *einode;
Jaegeuk Kimd624c962012-11-02 17:13:32 +090051 int err = 0;
52
Jaegeuk Kim74d0b912013-05-15 16:40:02 +090053 dir = check_dirty_dir_inode(F2FS_SB(inode->i_sb), pino);
54 if (!dir) {
55 dir = f2fs_iget(inode->i_sb, pino);
56 if (IS_ERR(dir)) {
57 err = PTR_ERR(dir);
58 goto out;
59 }
60 set_inode_flag(F2FS_I(dir), FI_DELAY_IPUT);
Jaegeuk Kim5deb8262013-06-05 17:42:45 +090061 add_dirty_dir_inode(dir);
Jaegeuk Kimd624c962012-11-02 17:13:32 +090062 }
63
Al Virob7f7a5e2013-01-25 16:15:43 -050064 name.len = le32_to_cpu(raw_inode->i_namelen);
65 name.name = raw_inode->i_name;
Jaegeuk Kim6b8213d2013-05-28 09:19:22 +090066retry:
67 de = f2fs_find_entry(dir, &name, &page);
68 if (de && inode->i_ino == le32_to_cpu(de->ino)) {
Jaegeuk Kimd624c962012-11-02 17:13:32 +090069 kunmap(page);
70 f2fs_put_page(page, 0);
Jaegeuk Kim6b8213d2013-05-28 09:19:22 +090071 goto out;
Jaegeuk Kimd624c962012-11-02 17:13:32 +090072 }
Jaegeuk Kim6b8213d2013-05-28 09:19:22 +090073 if (de) {
74 einode = f2fs_iget(inode->i_sb, le32_to_cpu(de->ino));
75 if (IS_ERR(einode)) {
76 WARN_ON(1);
77 if (PTR_ERR(einode) == -ENOENT)
78 err = -EEXIST;
79 goto out;
80 }
81 f2fs_delete_entry(de, page, einode);
82 iput(einode);
83 goto retry;
84 }
85 err = __f2fs_add_link(dir, &name, inode);
Jaegeuk Kimd624c962012-11-02 17:13:32 +090086out:
Jaegeuk Kimf356fe02013-05-16 15:04:49 +090087 f2fs_msg(inode->i_sb, KERN_NOTICE, "recover_inode and its dentry: "
88 "ino = %x, name = %s, dir = %lx, err = %d",
Dan Carpenterf28c06f2013-05-23 13:02:13 +030089 ino_of_node(ipage), raw_inode->i_name,
90 IS_ERR(dir) ? 0 : dir->i_ino, err);
Jaegeuk Kimd624c962012-11-02 17:13:32 +090091 return err;
92}
93
94static int recover_inode(struct inode *inode, struct page *node_page)
95{
96 void *kaddr = page_address(node_page);
97 struct f2fs_node *raw_node = (struct f2fs_node *)kaddr;
98 struct f2fs_inode *raw_inode = &(raw_node->i);
99
Jaegeuk Kimf356fe02013-05-16 15:04:49 +0900100 if (!IS_INODE(node_page))
101 return 0;
102
Jaegeuk Kim25ca9232012-11-28 16:12:41 +0900103 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900104 i_size_write(inode, le64_to_cpu(raw_inode->i_size));
105 inode->i_atime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
106 inode->i_ctime.tv_sec = le64_to_cpu(raw_inode->i_ctime);
107 inode->i_mtime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
108 inode->i_atime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec);
109 inode->i_ctime.tv_nsec = le32_to_cpu(raw_inode->i_ctime_nsec);
110 inode->i_mtime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec);
111
Jaegeuk Kimf356fe02013-05-16 15:04:49 +0900112 if (is_dent_dnode(node_page))
113 return recover_dentry(node_page, inode);
114
115 f2fs_msg(inode->i_sb, KERN_NOTICE, "recover_inode: ino = %x, name = %s",
116 ino_of_node(node_page), raw_inode->i_name);
117 return 0;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900118}
119
120static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
121{
122 unsigned long long cp_ver = le64_to_cpu(sbi->ckpt->checkpoint_ver);
123 struct curseg_info *curseg;
124 struct page *page;
125 block_t blkaddr;
126 int err = 0;
127
128 /* get node pages in the current segment */
129 curseg = CURSEG_I(sbi, CURSEG_WARM_NODE);
130 blkaddr = START_BLOCK(sbi, curseg->segno) + curseg->next_blkoff;
131
132 /* read node page */
133 page = alloc_page(GFP_F2FS_ZERO);
134 if (IS_ERR(page))
135 return PTR_ERR(page);
136 lock_page(page);
137
138 while (1) {
139 struct fsync_inode_entry *entry;
140
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900141 err = f2fs_readpage(sbi, page, blkaddr, READ_SYNC);
142 if (err)
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900143 goto out;
144
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900145 lock_page(page);
146
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900147 if (cp_ver != cpver_of_node(page))
Jaegeuk Kimf356fe02013-05-16 15:04:49 +0900148 break;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900149
150 if (!is_fsync_dnode(page))
151 goto next;
152
153 entry = get_fsync_inode(head, ino_of_node(page));
154 if (entry) {
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900155 if (IS_INODE(page) && is_dent_dnode(page))
156 set_inode_flag(F2FS_I(entry->inode),
157 FI_INC_LINK);
158 } else {
159 if (IS_INODE(page) && is_dent_dnode(page)) {
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900160 err = recover_inode_page(sbi, page);
161 if (err)
Jaegeuk Kimf356fe02013-05-16 15:04:49 +0900162 break;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900163 }
164
165 /* add this fsync inode to the list */
166 entry = kmem_cache_alloc(fsync_entry_slab, GFP_NOFS);
167 if (!entry) {
168 err = -ENOMEM;
Jaegeuk Kimf356fe02013-05-16 15:04:49 +0900169 break;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900170 }
171
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900172 entry->inode = f2fs_iget(sbi->sb, ino_of_node(page));
173 if (IS_ERR(entry->inode)) {
174 err = PTR_ERR(entry->inode);
Namjae Jeonfd8bb652012-12-22 12:10:12 +0900175 kmem_cache_free(fsync_entry_slab, entry);
Jaegeuk Kimf356fe02013-05-16 15:04:49 +0900176 break;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900177 }
Namjae Jeonfd8bb652012-12-22 12:10:12 +0900178 list_add_tail(&entry->list, head);
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900179 }
Jaegeuk Kimaddbe452013-05-15 10:49:13 +0900180 entry->blkaddr = blkaddr;
181
Jaegeuk Kimf356fe02013-05-16 15:04:49 +0900182 err = recover_inode(entry->inode, page);
183 if (err && err != -ENOENT)
184 break;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900185next:
186 /* check next segment */
187 blkaddr = next_blkaddr_of_node(page);
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900188 }
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900189 unlock_page(page);
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900190out:
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900191 __free_pages(page, 0);
192 return err;
193}
194
Gu Zheng5ebefc52013-06-27 09:28:54 +0800195static void destroy_fsync_dnodes(struct list_head *head)
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900196{
Dan Carpenterd8b79b22013-01-20 18:02:58 +0300197 struct fsync_inode_entry *entry, *tmp;
198
199 list_for_each_entry_safe(entry, tmp, head, list) {
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900200 iput(entry->inode);
201 list_del(&entry->list);
202 kmem_cache_free(fsync_entry_slab, entry);
203 }
204}
205
Jaegeuk Kim39cf72c2013-05-22 08:20:01 +0900206static int check_index_in_prev_nodes(struct f2fs_sb_info *sbi,
Jaegeuk Kimb292dcab2013-05-22 08:02:02 +0900207 block_t blkaddr, struct dnode_of_data *dn)
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900208{
209 struct seg_entry *sentry;
210 unsigned int segno = GET_SEGNO(sbi, blkaddr);
211 unsigned short blkoff = GET_SEGOFF_FROM_SEG0(sbi, blkaddr) &
212 (sbi->blocks_per_seg - 1);
213 struct f2fs_summary sum;
Jaegeuk Kimb292dcab2013-05-22 08:02:02 +0900214 nid_t ino, nid;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900215 void *kaddr;
216 struct inode *inode;
217 struct page *node_page;
218 block_t bidx;
219 int i;
220
221 sentry = get_seg_entry(sbi, segno);
222 if (!f2fs_test_bit(blkoff, sentry->cur_valid_map))
Jaegeuk Kim39cf72c2013-05-22 08:20:01 +0900223 return 0;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900224
225 /* Get the previous summary */
226 for (i = CURSEG_WARM_DATA; i <= CURSEG_COLD_DATA; i++) {
227 struct curseg_info *curseg = CURSEG_I(sbi, i);
228 if (curseg->segno == segno) {
229 sum = curseg->sum_blk->entries[blkoff];
230 break;
231 }
232 }
233 if (i > CURSEG_COLD_DATA) {
234 struct page *sum_page = get_sum_page(sbi, segno);
235 struct f2fs_summary_block *sum_node;
236 kaddr = page_address(sum_page);
237 sum_node = (struct f2fs_summary_block *)kaddr;
238 sum = sum_node->entries[blkoff];
239 f2fs_put_page(sum_page, 1);
240 }
241
Jaegeuk Kimb292dcab2013-05-22 08:02:02 +0900242 /* Use the locked dnode page and inode */
243 nid = le32_to_cpu(sum.nid);
244 if (dn->inode->i_ino == nid) {
245 struct dnode_of_data tdn = *dn;
246 tdn.nid = nid;
247 tdn.node_page = dn->inode_page;
Jaegeuk Kim060dd672013-06-24 07:47:23 +0900248 tdn.ofs_in_node = le16_to_cpu(sum.ofs_in_node);
Jaegeuk Kimb292dcab2013-05-22 08:02:02 +0900249 truncate_data_blocks_range(&tdn, 1);
Jaegeuk Kim39cf72c2013-05-22 08:20:01 +0900250 return 0;
Jaegeuk Kimb292dcab2013-05-22 08:02:02 +0900251 } else if (dn->nid == nid) {
252 struct dnode_of_data tdn = *dn;
Jaegeuk Kim060dd672013-06-24 07:47:23 +0900253 tdn.ofs_in_node = le16_to_cpu(sum.ofs_in_node);
Jaegeuk Kimb292dcab2013-05-22 08:02:02 +0900254 truncate_data_blocks_range(&tdn, 1);
Jaegeuk Kim39cf72c2013-05-22 08:20:01 +0900255 return 0;
Jaegeuk Kimb292dcab2013-05-22 08:02:02 +0900256 }
257
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900258 /* Get the node page */
Jaegeuk Kimb292dcab2013-05-22 08:02:02 +0900259 node_page = get_node_page(sbi, nid);
Jaegeuk Kim39cf72c2013-05-22 08:20:01 +0900260 if (IS_ERR(node_page))
261 return PTR_ERR(node_page);
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900262 bidx = start_bidx_of_node(ofs_of_node(node_page)) +
Jaegeuk Kimb292dcab2013-05-22 08:02:02 +0900263 le16_to_cpu(sum.ofs_in_node);
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900264 ino = ino_of_node(node_page);
265 f2fs_put_page(node_page, 1);
266
267 /* Deallocate previous index in the node page */
Jaegeuk Kimd4686d562013-01-31 15:36:04 +0900268 inode = f2fs_iget(sbi->sb, ino);
Namjae Jeon06025f42012-12-22 12:09:43 +0900269 if (IS_ERR(inode))
Jaegeuk Kim39cf72c2013-05-22 08:20:01 +0900270 return PTR_ERR(inode);
Namjae Jeon06025f42012-12-22 12:09:43 +0900271
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900272 truncate_hole(inode, bidx, bidx + 1);
273 iput(inode);
Jaegeuk Kim39cf72c2013-05-22 08:20:01 +0900274 return 0;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900275}
276
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900277static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900278 struct page *page, block_t blkaddr)
279{
280 unsigned int start, end;
281 struct dnode_of_data dn;
282 struct f2fs_summary sum;
283 struct node_info ni;
Jaegeuk Kimf356fe02013-05-16 15:04:49 +0900284 int err = 0, recovered = 0;
Jaegeuk Kim39936832012-11-22 16:21:29 +0900285 int ilock;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900286
287 start = start_bidx_of_node(ofs_of_node(page));
288 if (IS_INODE(page))
289 end = start + ADDRS_PER_INODE;
290 else
291 end = start + ADDRS_PER_BLOCK;
292
Jaegeuk Kim39936832012-11-22 16:21:29 +0900293 ilock = mutex_lock_op(sbi);
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900294 set_new_dnode(&dn, inode, NULL, NULL, 0);
Jaegeuk Kim39936832012-11-22 16:21:29 +0900295
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900296 err = get_dnode_of_data(&dn, start, ALLOC_NODE);
Jaegeuk Kim39936832012-11-22 16:21:29 +0900297 if (err) {
298 mutex_unlock_op(sbi, ilock);
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900299 return err;
Jaegeuk Kim39936832012-11-22 16:21:29 +0900300 }
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900301
302 wait_on_page_writeback(dn.node_page);
303
304 get_node_info(sbi, dn.nid, &ni);
305 BUG_ON(ni.ino != ino_of_node(page));
306 BUG_ON(ofs_of_node(dn.node_page) != ofs_of_node(page));
307
308 for (; start < end; start++) {
309 block_t src, dest;
310
311 src = datablock_addr(dn.node_page, dn.ofs_in_node);
312 dest = datablock_addr(page, dn.ofs_in_node);
313
314 if (src != dest && dest != NEW_ADDR && dest != NULL_ADDR) {
315 if (src == NULL_ADDR) {
316 int err = reserve_new_block(&dn);
317 /* We should not get -ENOSPC */
318 BUG_ON(err);
319 }
320
321 /* Check the previous node page having this index */
Jaegeuk Kim39cf72c2013-05-22 08:20:01 +0900322 err = check_index_in_prev_nodes(sbi, dest, &dn);
323 if (err)
324 goto err;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900325
326 set_summary(&sum, dn.nid, dn.ofs_in_node, ni.version);
327
328 /* write dummy data page */
329 recover_data_page(sbi, NULL, &sum, src, dest);
330 update_extent_cache(dest, &dn);
Jaegeuk Kimf356fe02013-05-16 15:04:49 +0900331 recovered++;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900332 }
333 dn.ofs_in_node++;
334 }
335
336 /* write node page in place */
337 set_summary(&sum, dn.nid, 0, 0);
338 if (IS_INODE(dn.node_page))
339 sync_inode_page(&dn);
340
341 copy_node_footer(dn.node_page, page);
342 fill_node_footer(dn.node_page, dn.nid, ni.ino,
343 ofs_of_node(page), false);
344 set_page_dirty(dn.node_page);
345
346 recover_node_page(sbi, dn.node_page, &sum, &ni, blkaddr);
Jaegeuk Kim39cf72c2013-05-22 08:20:01 +0900347err:
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900348 f2fs_put_dnode(&dn);
Jaegeuk Kim39936832012-11-22 16:21:29 +0900349 mutex_unlock_op(sbi, ilock);
Jaegeuk Kimf356fe02013-05-16 15:04:49 +0900350
351 f2fs_msg(sbi->sb, KERN_NOTICE, "recover_data: ino = %lx, "
Jaegeuk Kim39cf72c2013-05-22 08:20:01 +0900352 "recovered_data = %d blocks, err = %d",
353 inode->i_ino, recovered, err);
354 return err;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900355}
356
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900357static int recover_data(struct f2fs_sb_info *sbi,
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900358 struct list_head *head, int type)
359{
360 unsigned long long cp_ver = le64_to_cpu(sbi->ckpt->checkpoint_ver);
361 struct curseg_info *curseg;
362 struct page *page;
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900363 int err = 0;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900364 block_t blkaddr;
365
366 /* get node pages in the current segment */
367 curseg = CURSEG_I(sbi, type);
368 blkaddr = NEXT_FREE_BLKADDR(sbi, curseg);
369
370 /* read node page */
371 page = alloc_page(GFP_NOFS | __GFP_ZERO);
372 if (IS_ERR(page))
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900373 return -ENOMEM;
374
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900375 lock_page(page);
376
377 while (1) {
378 struct fsync_inode_entry *entry;
379
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900380 err = f2fs_readpage(sbi, page, blkaddr, READ_SYNC);
381 if (err)
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900382 goto out;
383
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900384 lock_page(page);
385
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900386 if (cp_ver != cpver_of_node(page))
Jaegeuk Kim45856af2013-05-20 10:26:09 +0900387 break;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900388
389 entry = get_fsync_inode(head, ino_of_node(page));
390 if (!entry)
391 goto next;
392
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900393 err = do_recover_data(sbi, entry->inode, page, blkaddr);
394 if (err)
Jaegeuk Kim45856af2013-05-20 10:26:09 +0900395 break;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900396
397 if (entry->blkaddr == blkaddr) {
398 iput(entry->inode);
399 list_del(&entry->list);
400 kmem_cache_free(fsync_entry_slab, entry);
401 }
402next:
403 /* check next segment */
404 blkaddr = next_blkaddr_of_node(page);
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900405 }
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900406 unlock_page(page);
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900407out:
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900408 __free_pages(page, 0);
409
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900410 if (!err)
411 allocate_new_segments(sbi);
412 return err;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900413}
414
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900415int recover_fsync_data(struct f2fs_sb_info *sbi)
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900416{
417 struct list_head inode_list;
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900418 int err;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900419
420 fsync_entry_slab = f2fs_kmem_cache_create("f2fs_fsync_inode_entry",
421 sizeof(struct fsync_inode_entry), NULL);
422 if (unlikely(!fsync_entry_slab))
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900423 return -ENOMEM;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900424
425 INIT_LIST_HEAD(&inode_list);
426
427 /* step #1: find fsynced inode numbers */
Jaegeuk Kim8c26d7d2013-05-15 16:12:18 +0900428 sbi->por_doing = 1;
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900429 err = find_fsync_dnodes(sbi, &inode_list);
430 if (err)
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900431 goto out;
432
433 if (list_empty(&inode_list))
434 goto out;
435
436 /* step #2: recover data */
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900437 err = recover_data(sbi, &inode_list, CURSEG_WARM_NODE);
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900438 BUG_ON(!list_empty(&inode_list));
439out:
Gu Zheng5ebefc52013-06-27 09:28:54 +0800440 destroy_fsync_dnodes(&inode_list);
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900441 kmem_cache_destroy(fsync_entry_slab);
Jaegeuk Kim8c26d7d2013-05-15 16:12:18 +0900442 sbi->por_doing = 0;
Jaegeuk Kim2c2c1492013-05-20 14:48:49 +0900443 if (!err)
444 write_checkpoint(sbi, false);
Jaegeuk Kim6ead1142013-03-20 19:01:06 +0900445 return err;
Jaegeuk Kimd624c962012-11-02 17:13:32 +0900446}