diff options
author | Gu Zheng <guz.fnst@cn.fujitsu.com> | 2014-01-10 14:09:08 +0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2014-01-14 13:12:04 +0400 |
commit | c1ef37257229dc8903615eaf1d1abaa5da3f0686 (patch) | |
tree | 127294a636e8f928371f1ee253c26b21034d76c4 | |
parent | 4531929e3922f2cdd34208d7dc1404ac06e6ced5 (diff) | |
download | linux-c1ef37257229dc8903615eaf1d1abaa5da3f0686.tar.xz |
f2fs: move alloc new orphan node out of lock protection region
Move alloc new orphan node out of lock protection region.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
-rw-r--r-- | fs/f2fs/checkpoint.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index fdc5a12c0edd..681782c715fb 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -219,26 +219,29 @@ void add_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino) struct list_head *head, *this; struct orphan_inode_entry *new = NULL, *orphan = NULL; + new = f2fs_kmem_cache_alloc(orphan_entry_slab, GFP_ATOMIC); + new->ino = ino; + mutex_lock(&sbi->orphan_inode_mutex); head = &sbi->orphan_inode_list; list_for_each(this, head) { orphan = list_entry(this, struct orphan_inode_entry, list); - if (orphan->ino == ino) - goto out; + if (orphan->ino == ino) { + mutex_unlock(&sbi->orphan_inode_mutex); + kmem_cache_free(orphan_entry_slab, new); + return; + } + if (orphan->ino > ino) break; orphan = NULL; } - new = f2fs_kmem_cache_alloc(orphan_entry_slab, GFP_ATOMIC); - new->ino = ino; - /* add new_oentry into list which is sorted by inode number */ if (orphan) list_add(&new->list, this->prev); else list_add_tail(&new->list, head); -out: mutex_unlock(&sbi->orphan_inode_mutex); } |