Commit c52e1b10 authored by Jaegeuk Kim's avatar Jaegeuk Kim

f2fs: remove redundant operation during roll-forward recovery

If same data is updated multiple times, we don't need to redo whole the
operations.
Let's just update the lastest one.
Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 19c9c466
...@@ -137,7 +137,9 @@ struct discard_entry { ...@@ -137,7 +137,9 @@ struct discard_entry {
struct fsync_inode_entry { struct fsync_inode_entry {
struct list_head list; /* list head */ struct list_head list; /* list head */
struct inode *inode; /* vfs inode pointer */ struct inode *inode; /* vfs inode pointer */
block_t blkaddr; /* block address locating the last inode */ block_t blkaddr; /* block address locating the last fsync */
block_t last_dentry; /* block address locating the last dentry */
block_t last_inode; /* block address locating the last inode */
}; };
#define nats_in_cursum(sum) (le16_to_cpu(sum->n_nats)) #define nats_in_cursum(sum) (le16_to_cpu(sum->n_nats))
......
...@@ -67,7 +67,7 @@ static struct fsync_inode_entry *get_fsync_inode(struct list_head *head, ...@@ -67,7 +67,7 @@ static struct fsync_inode_entry *get_fsync_inode(struct list_head *head,
return NULL; return NULL;
} }
static int recover_dentry(struct page *ipage, struct inode *inode) static int recover_dentry(struct inode *inode, struct page *ipage)
{ {
struct f2fs_inode *raw_inode = F2FS_INODE(ipage); struct f2fs_inode *raw_inode = F2FS_INODE(ipage);
nid_t pino = le32_to_cpu(raw_inode->i_pino); nid_t pino = le32_to_cpu(raw_inode->i_pino);
...@@ -141,7 +141,7 @@ static int recover_dentry(struct page *ipage, struct inode *inode) ...@@ -141,7 +141,7 @@ static int recover_dentry(struct page *ipage, struct inode *inode)
return err; return err;
} }
static void __recover_inode(struct inode *inode, struct page *page) static void recover_inode(struct inode *inode, struct page *page)
{ {
struct f2fs_inode *raw = F2FS_INODE(page); struct f2fs_inode *raw = F2FS_INODE(page);
...@@ -153,21 +153,9 @@ static void __recover_inode(struct inode *inode, struct page *page) ...@@ -153,21 +153,9 @@ static void __recover_inode(struct inode *inode, struct page *page)
inode->i_atime.tv_nsec = le32_to_cpu(raw->i_mtime_nsec); inode->i_atime.tv_nsec = le32_to_cpu(raw->i_mtime_nsec);
inode->i_ctime.tv_nsec = le32_to_cpu(raw->i_ctime_nsec); inode->i_ctime.tv_nsec = le32_to_cpu(raw->i_ctime_nsec);
inode->i_mtime.tv_nsec = le32_to_cpu(raw->i_mtime_nsec); inode->i_mtime.tv_nsec = le32_to_cpu(raw->i_mtime_nsec);
}
static int recover_inode(struct inode *inode, struct page *node_page)
{
if (!IS_INODE(node_page))
return 0;
__recover_inode(inode, node_page);
if (is_dent_dnode(node_page))
return recover_dentry(node_page, inode);
f2fs_msg(inode->i_sb, KERN_NOTICE, "recover_inode: ino = %x, name = %s", f2fs_msg(inode->i_sb, KERN_NOTICE, "recover_inode: ino = %x, name = %s",
ino_of_node(node_page), F2FS_INODE(node_page)->i_name); ino_of_node(page), F2FS_INODE(page)->i_name);
return 0;
} }
static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head) static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
...@@ -210,12 +198,11 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head) ...@@ -210,12 +198,11 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
} }
/* add this fsync inode to the list */ /* add this fsync inode to the list */
entry = kmem_cache_alloc(fsync_entry_slab, GFP_NOFS); entry = kmem_cache_alloc(fsync_entry_slab, GFP_F2FS_ZERO);
if (!entry) { if (!entry) {
err = -ENOMEM; err = -ENOMEM;
break; break;
} }
/* /*
* 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.
...@@ -232,9 +219,11 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head) ...@@ -232,9 +219,11 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
} }
entry->blkaddr = blkaddr; entry->blkaddr = blkaddr;
err = recover_inode(entry->inode, page); if (IS_INODE(page)) {
if (err && err != -ENOENT) entry->last_inode = blkaddr;
break; if (is_dent_dnode(page))
entry->last_dentry = blkaddr;
}
next: next:
/* check next segment */ /* check next segment */
blkaddr = next_blkaddr_of_node(page); blkaddr = next_blkaddr_of_node(page);
...@@ -462,11 +451,17 @@ static int recover_data(struct f2fs_sb_info *sbi, ...@@ -462,11 +451,17 @@ static int recover_data(struct f2fs_sb_info *sbi,
/* /*
* inode(x) | CP | inode(x) | dnode(F) * inode(x) | CP | inode(x) | dnode(F)
* In this case, we can lose the latest inode(x). * In this case, we can lose the latest inode(x).
* So, call __recover_inode for the inode update. * So, call recover_inode for the inode update.
*/ */
if (IS_INODE(page)) if (entry->last_inode == blkaddr)
__recover_inode(entry->inode, page); recover_inode(entry->inode, page);
if (entry->last_dentry == blkaddr) {
err = recover_dentry(entry->inode, page);
if (err) {
f2fs_put_page(page, 1);
break;
}
}
err = do_recover_data(sbi, entry->inode, page, blkaddr); err = do_recover_data(sbi, entry->inode, page, blkaddr);
if (err) { if (err) {
f2fs_put_page(page, 1); f2fs_put_page(page, 1);
......
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