aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2014-11-21 19:36:28 -0500
committerJaegeuk Kim <jaegeuk@kernel.org>2014-11-24 00:51:53 -0500
commit9486ba442b00a6b227bfe0d66b0f4dbcd1a2ee91 (patch)
tree0f308e43c33144b4535562897e9b370ce624d506 /fs/f2fs
parentc9ee00857c9630fba14ebe368d06dc3ac2489b84 (diff)
f2fs: introduce f2fs_dentry_kunmap to clean up
This patch introduces f2fs_dentry_kunmap to clean up dirty codes. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/dir.c3
-rw-r--r--fs/f2fs/f2fs.h6
-rw-r--r--fs/f2fs/namei.c30
-rw-r--r--fs/f2fs/recovery.c3
4 files changed, 18 insertions, 24 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 5a49995a666e..b1a7d5737cd0 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -271,8 +271,7 @@ ino_t f2fs_inode_by_name(struct inode *dir, struct qstr *qstr)
271 de = f2fs_find_entry(dir, qstr, &page); 271 de = f2fs_find_entry(dir, qstr, &page);
272 if (de) { 272 if (de) {
273 res = le32_to_cpu(de->ino); 273 res = le32_to_cpu(de->ino);
274 if (!f2fs_has_inline_dentry(dir)) 274 f2fs_dentry_kunmap(dir, page);
275 kunmap(page);
276 f2fs_put_page(page, 0); 275 f2fs_put_page(page, 0);
277 } 276 }
278 277
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 418c8524a164..d04281319dbe 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1229,6 +1229,12 @@ static inline void *inline_dentry_addr(struct page *page)
1229 return (void *)&(ri->i_addr[1]); 1229 return (void *)&(ri->i_addr[1]);
1230} 1230}
1231 1231
1232static inline void f2fs_dentry_kunmap(struct inode *dir, struct page *page)
1233{
1234 if (!f2fs_has_inline_dentry(dir))
1235 kunmap(page);
1236}
1237
1232static inline int f2fs_readonly(struct super_block *sb) 1238static inline int f2fs_readonly(struct super_block *sb)
1233{ 1239{
1234 return sb->s_flags & MS_RDONLY; 1240 return sb->s_flags & MS_RDONLY;
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 2bee559a690f..547a2deeb1ac 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -200,8 +200,7 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,
200 de = f2fs_find_entry(dir, &dentry->d_name, &page); 200 de = f2fs_find_entry(dir, &dentry->d_name, &page);
201 if (de) { 201 if (de) {
202 nid_t ino = le32_to_cpu(de->ino); 202 nid_t ino = le32_to_cpu(de->ino);
203 if (!f2fs_has_inline_dentry(dir)) 203 f2fs_dentry_kunmap(dir, page);
204 kunmap(page);
205 f2fs_put_page(page, 0); 204 f2fs_put_page(page, 0);
206 205
207 inode = f2fs_iget(dir->i_sb, ino); 206 inode = f2fs_iget(dir->i_sb, ino);
@@ -231,8 +230,7 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
231 err = acquire_orphan_inode(sbi); 230 err = acquire_orphan_inode(sbi);
232 if (err) { 231 if (err) {
233 f2fs_unlock_op(sbi); 232 f2fs_unlock_op(sbi);
234 if (!f2fs_has_inline_dentry(dir)) 233 f2fs_dentry_kunmap(dir, page);
235 kunmap(page);
236 f2fs_put_page(page, 0); 234 f2fs_put_page(page, 0);
237 goto fail; 235 goto fail;
238 } 236 }
@@ -469,8 +467,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
469 old_dir_page, new_dir); 467 old_dir_page, new_dir);
470 update_inode_page(old_inode); 468 update_inode_page(old_inode);
471 } else { 469 } else {
472 if (!f2fs_has_inline_dentry(old_inode)) 470 f2fs_dentry_kunmap(old_inode, old_dir_page);
473 kunmap(old_dir_page);
474 f2fs_put_page(old_dir_page, 0); 471 f2fs_put_page(old_dir_page, 0);
475 } 472 }
476 drop_nlink(old_dir); 473 drop_nlink(old_dir);
@@ -486,18 +483,15 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
486 483
487put_out_dir: 484put_out_dir:
488 f2fs_unlock_op(sbi); 485 f2fs_unlock_op(sbi);
489 if (!f2fs_has_inline_dentry(new_dir)) 486 f2fs_dentry_kunmap(new_dir, new_page);
490 kunmap(new_page);
491 f2fs_put_page(new_page, 0); 487 f2fs_put_page(new_page, 0);
492out_dir: 488out_dir:
493 if (old_dir_entry) { 489 if (old_dir_entry) {
494 if (!f2fs_has_inline_dentry(old_inode)) 490 f2fs_dentry_kunmap(old_inode, old_dir_page);
495 kunmap(old_dir_page);
496 f2fs_put_page(old_dir_page, 0); 491 f2fs_put_page(old_dir_page, 0);
497 } 492 }
498out_old: 493out_old:
499 if (!f2fs_has_inline_dentry(old_dir)) 494 f2fs_dentry_kunmap(old_dir, old_page);
500 kunmap(old_page);
501 f2fs_put_page(old_page, 0); 495 f2fs_put_page(old_page, 0);
502out: 496out:
503 return err; 497 return err;
@@ -632,23 +626,19 @@ out_unlock:
632 f2fs_unlock_op(sbi); 626 f2fs_unlock_op(sbi);
633out_new_dir: 627out_new_dir:
634 if (new_dir_entry) { 628 if (new_dir_entry) {
635 if (!f2fs_has_inline_dentry(new_inode)) 629 f2fs_dentry_kunmap(new_inode, new_dir_page);
636 kunmap(new_dir_page);
637 f2fs_put_page(new_dir_page, 0); 630 f2fs_put_page(new_dir_page, 0);
638 } 631 }
639out_old_dir: 632out_old_dir:
640 if (old_dir_entry) { 633 if (old_dir_entry) {
641 if (!f2fs_has_inline_dentry(old_inode)) 634 f2fs_dentry_kunmap(old_inode, old_dir_page);
642 kunmap(old_dir_page);
643 f2fs_put_page(old_dir_page, 0); 635 f2fs_put_page(old_dir_page, 0);
644 } 636 }
645out_new: 637out_new:
646 if (!f2fs_has_inline_dentry(new_dir)) 638 f2fs_dentry_kunmap(new_dir, new_page);
647 kunmap(new_page);
648 f2fs_put_page(new_page, 0); 639 f2fs_put_page(new_page, 0);
649out_old: 640out_old:
650 if (!f2fs_has_inline_dentry(old_dir)) 641 f2fs_dentry_kunmap(old_dir, old_page);
651 kunmap(old_page);
652 f2fs_put_page(old_page, 0); 642 f2fs_put_page(old_page, 0);
653out: 643out:
654 return err; 644 return err;
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 4b180bbc3a21..9a93a6e29b05 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -129,8 +129,7 @@ retry:
129 goto out; 129 goto out;
130 130
131out_unmap_put: 131out_unmap_put:
132 if (!f2fs_has_inline_dentry(dir)) 132 f2fs_dentry_kunmap(dir, page);
133 kunmap(page);
134 f2fs_put_page(page, 0); 133 f2fs_put_page(page, 0);
135out_err: 134out_err:
136 iput(dir); 135 iput(dir);