提交 9486ba44 编写于 作者: J Jaegeuk Kim

f2fs: introduce f2fs_dentry_kunmap to clean up

This patch introduces f2fs_dentry_kunmap to clean up dirty codes.
Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
上级 c9ee0085
...@@ -271,8 +271,7 @@ ino_t f2fs_inode_by_name(struct inode *dir, struct qstr *qstr) ...@@ -271,8 +271,7 @@ ino_t f2fs_inode_by_name(struct inode *dir, struct qstr *qstr)
de = f2fs_find_entry(dir, qstr, &page); de = f2fs_find_entry(dir, qstr, &page);
if (de) { if (de) {
res = le32_to_cpu(de->ino); res = le32_to_cpu(de->ino);
if (!f2fs_has_inline_dentry(dir)) f2fs_dentry_kunmap(dir, page);
kunmap(page);
f2fs_put_page(page, 0); f2fs_put_page(page, 0);
} }
......
...@@ -1229,6 +1229,12 @@ static inline void *inline_dentry_addr(struct page *page) ...@@ -1229,6 +1229,12 @@ static inline void *inline_dentry_addr(struct page *page)
return (void *)&(ri->i_addr[1]); return (void *)&(ri->i_addr[1]);
} }
static inline void f2fs_dentry_kunmap(struct inode *dir, struct page *page)
{
if (!f2fs_has_inline_dentry(dir))
kunmap(page);
}
static inline int f2fs_readonly(struct super_block *sb) static inline int f2fs_readonly(struct super_block *sb)
{ {
return sb->s_flags & MS_RDONLY; return sb->s_flags & MS_RDONLY;
......
...@@ -200,8 +200,7 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -200,8 +200,7 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,
de = f2fs_find_entry(dir, &dentry->d_name, &page); de = f2fs_find_entry(dir, &dentry->d_name, &page);
if (de) { if (de) {
nid_t ino = le32_to_cpu(de->ino); nid_t ino = le32_to_cpu(de->ino);
if (!f2fs_has_inline_dentry(dir)) f2fs_dentry_kunmap(dir, page);
kunmap(page);
f2fs_put_page(page, 0); f2fs_put_page(page, 0);
inode = f2fs_iget(dir->i_sb, ino); inode = f2fs_iget(dir->i_sb, ino);
...@@ -231,8 +230,7 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -231,8 +230,7 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
err = acquire_orphan_inode(sbi); err = acquire_orphan_inode(sbi);
if (err) { if (err) {
f2fs_unlock_op(sbi); f2fs_unlock_op(sbi);
if (!f2fs_has_inline_dentry(dir)) f2fs_dentry_kunmap(dir, page);
kunmap(page);
f2fs_put_page(page, 0); f2fs_put_page(page, 0);
goto fail; goto fail;
} }
...@@ -469,8 +467,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -469,8 +467,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
old_dir_page, new_dir); old_dir_page, new_dir);
update_inode_page(old_inode); update_inode_page(old_inode);
} else { } else {
if (!f2fs_has_inline_dentry(old_inode)) f2fs_dentry_kunmap(old_inode, old_dir_page);
kunmap(old_dir_page);
f2fs_put_page(old_dir_page, 0); f2fs_put_page(old_dir_page, 0);
} }
drop_nlink(old_dir); drop_nlink(old_dir);
...@@ -486,18 +483,15 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -486,18 +483,15 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
put_out_dir: put_out_dir:
f2fs_unlock_op(sbi); f2fs_unlock_op(sbi);
if (!f2fs_has_inline_dentry(new_dir)) f2fs_dentry_kunmap(new_dir, new_page);
kunmap(new_page);
f2fs_put_page(new_page, 0); f2fs_put_page(new_page, 0);
out_dir: out_dir:
if (old_dir_entry) { if (old_dir_entry) {
if (!f2fs_has_inline_dentry(old_inode)) f2fs_dentry_kunmap(old_inode, old_dir_page);
kunmap(old_dir_page);
f2fs_put_page(old_dir_page, 0); f2fs_put_page(old_dir_page, 0);
} }
out_old: out_old:
if (!f2fs_has_inline_dentry(old_dir)) f2fs_dentry_kunmap(old_dir, old_page);
kunmap(old_page);
f2fs_put_page(old_page, 0); f2fs_put_page(old_page, 0);
out: out:
return err; return err;
...@@ -632,23 +626,19 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -632,23 +626,19 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
f2fs_unlock_op(sbi); f2fs_unlock_op(sbi);
out_new_dir: out_new_dir:
if (new_dir_entry) { if (new_dir_entry) {
if (!f2fs_has_inline_dentry(new_inode)) f2fs_dentry_kunmap(new_inode, new_dir_page);
kunmap(new_dir_page);
f2fs_put_page(new_dir_page, 0); f2fs_put_page(new_dir_page, 0);
} }
out_old_dir: out_old_dir:
if (old_dir_entry) { if (old_dir_entry) {
if (!f2fs_has_inline_dentry(old_inode)) f2fs_dentry_kunmap(old_inode, old_dir_page);
kunmap(old_dir_page);
f2fs_put_page(old_dir_page, 0); f2fs_put_page(old_dir_page, 0);
} }
out_new: out_new:
if (!f2fs_has_inline_dentry(new_dir)) f2fs_dentry_kunmap(new_dir, new_page);
kunmap(new_page);
f2fs_put_page(new_page, 0); f2fs_put_page(new_page, 0);
out_old: out_old:
if (!f2fs_has_inline_dentry(old_dir)) f2fs_dentry_kunmap(old_dir, old_page);
kunmap(old_page);
f2fs_put_page(old_page, 0); f2fs_put_page(old_page, 0);
out: out:
return err; return err;
......
...@@ -129,8 +129,7 @@ static int recover_dentry(struct inode *inode, struct page *ipage) ...@@ -129,8 +129,7 @@ static int recover_dentry(struct inode *inode, struct page *ipage)
goto out; goto out;
out_unmap_put: out_unmap_put:
if (!f2fs_has_inline_dentry(dir)) f2fs_dentry_kunmap(dir, page);
kunmap(page);
f2fs_put_page(page, 0); f2fs_put_page(page, 0);
out_err: out_err:
iput(dir); iput(dir);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册