2013-05-20 03:17:21

by Jaegeuk Kim

[permalink] [raw]
Subject: [PATCH 1/2] f2fs: remove unnecessary kmap/kunmap operations

The allocated page used by the recovery is not on HIGHMEM, so that we don't
need to use kmap/kunmap.

Signed-off-by: Jaegeuk Kim <[email protected]>
---
fs/f2fs/recovery.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 774efdb..5fcdd08 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -40,11 +40,11 @@ static struct fsync_inode_entry *get_fsync_inode(struct list_head *head,

static int recover_dentry(struct page *ipage, struct inode *inode)
{
- struct f2fs_node *raw_node = (struct f2fs_node *)kmap(ipage);
+ void *kaddr = page_address(ipage);
+ struct f2fs_node *raw_node = (struct f2fs_node *)kaddr;
struct f2fs_inode *raw_inode = &(raw_node->i);
nid_t pino = le32_to_cpu(raw_inode->i_pino);
struct qstr name;
- struct f2fs_dir_entry *de;
struct page *page;
struct inode *dir;
int err = 0;
@@ -62,8 +62,7 @@ static int recover_dentry(struct page *ipage, struct inode *inode)
name.len = le32_to_cpu(raw_inode->i_namelen);
name.name = raw_inode->i_name;

- de = f2fs_find_entry(dir, &name, &page);
- if (de) {
+ if (f2fs_find_entry(dir, &name, &page)) {
kunmap(page);
f2fs_put_page(page, 0);
} else {
@@ -73,7 +72,6 @@ out:
f2fs_msg(inode->i_sb, KERN_NOTICE, "recover_inode and its dentry: "
"ino = %x, name = %s, dir = %lx, err = %d",
ino_of_node(ipage), raw_inode->i_name, dir->i_ino, err);
- kunmap(ipage);
return err;
}

--
1.8.1.3.566.gaa39828


2013-05-20 03:17:24

by Jaegeuk Kim

[permalink] [raw]
Subject: [PATCH 2/2] f2fs: fix to unlock page before exit

If we got an error after lock_page, we should unlock it before exit.

Signed-off-by: Jaegeuk Kim <[email protected]>
---
fs/f2fs/recovery.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 5fcdd08..edb89a3 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -343,7 +343,7 @@ static int recover_data(struct f2fs_sb_info *sbi,
lock_page(page);

if (cp_ver != cpver_of_node(page))
- goto unlock_out;
+ break;

entry = get_fsync_inode(head, ino_of_node(page));
if (!entry)
@@ -351,7 +351,7 @@ static int recover_data(struct f2fs_sb_info *sbi,

err = do_recover_data(sbi, entry->inode, page, blkaddr);
if (err)
- goto out;
+ break;

if (entry->blkaddr == blkaddr) {
iput(entry->inode);
@@ -362,7 +362,6 @@ next:
/* check next segment */
blkaddr = next_blkaddr_of_node(page);
}
-unlock_out:
unlock_page(page);
out:
__free_pages(page, 0);
--
1.8.1.3.566.gaa39828