summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/node.c
diff options
context:
space:
mode:
authorHaicheng Li <haicheng.li@linux.intel.com>2013-05-06 17:15:41 +0200
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2013-05-08 12:54:20 +0200
commit95630cbadc3588abff24a4b1989b72c943b27512 (patch)
tree9655200dfab3fb8efa94dfb84c1ff7fb9b451e64 /fs/f2fs/node.c
parentf2fs: recover when journal contains deleted files (diff)
downloadlinux-95630cbadc3588abff24a4b1989b72c943b27512.tar.xz
linux-95630cbadc3588abff24a4b1989b72c943b27512.zip
f2fs: bugfix for alloc_nid_failed()
Directly drop the free_nid cache when nm_i->fcnt > 2 * MAX_FREE_NIDS Since there is NOT nmi->free_nid_list_lock spinlock protection between a sequential calling of alloc_nid() and alloc_nid_failed(), some other threads may already add new free_nid to the free_nid_list during this period. We need to make sure nmi->fcnt is never > 2 * MAX_FREE_NIDS. Signed-off-by: Haicheng Li <haicheng.li@linux.intel.com> [Jaegeuk Kim: fit the coding style] Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to '')
-rw-r--r--fs/f2fs/node.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 7209d637f942..d682f34ee0f8 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1439,8 +1439,12 @@ void alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid)
spin_lock(&nm_i->free_nid_list_lock);
i = __lookup_free_nid_list(nid, &nm_i->free_nid_list);
BUG_ON(!i || i->state != NID_ALLOC);
- i->state = NID_NEW;
- nm_i->fcnt++;
+ if (nm_i->fcnt > 2 * MAX_FREE_NIDS) {
+ __del_from_free_nid_list(i);
+ } else {
+ i->state = NID_NEW;
+ nm_i->fcnt++;
+ }
spin_unlock(&nm_i->free_nid_list_lock);
}