Skip to content

Commit 60e4952

Browse files
Gu ZhengHashcode
authored andcommitted
f2fs: introduce help macro on_build_free_nids()
Introduce help macro on_build_free_nids() which just uses build_lock to judge whether the building free nid is going, so that we can remove the on_build_free_nids field from f2fs_sb_info. Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com> [Jaegeuk Kim: remove an unnecessary white line removal] Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
1 parent 3678630 commit 60e4952

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

fs/f2fs/f2fs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ struct f2fs_sb_info {
417417
struct mutex node_write; /* locking node writes */
418418
struct mutex writepages; /* mutex for writepages() */
419419
bool por_doing; /* recovery is doing or not */
420-
bool on_build_free_nids; /* build_free_nids is doing */
421420
wait_queue_head_t cp_wait;
422421

423422
/* for orphan inode management */

fs/f2fs/node.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "segment.h"
2222
#include <trace/events/f2fs.h>
2323

24+
#define on_build_free_nids(nmi) mutex_is_locked(&nm_i->build_lock)
25+
2426
static struct kmem_cache *nat_entry_slab;
2527
static struct kmem_cache *free_nid_slab;
2628

@@ -1421,7 +1423,7 @@ bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
14211423
spin_lock(&nm_i->free_nid_list_lock);
14221424

14231425
/* We should not use stale free nids created by build_free_nids */
1424-
if (nm_i->fcnt && !sbi->on_build_free_nids) {
1426+
if (nm_i->fcnt && !on_build_free_nids(nm_i)) {
14251427
f2fs_bug_on(list_empty(&nm_i->free_nid_list));
14261428
list_for_each(this, &nm_i->free_nid_list) {
14271429
i = list_entry(this, struct free_nid, list);
@@ -1440,9 +1442,7 @@ bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
14401442

14411443
/* Let's scan nat pages and its caches to get free nids */
14421444
mutex_lock(&nm_i->build_lock);
1443-
sbi->on_build_free_nids = true;
14441445
build_free_nids(sbi);
1445-
sbi->on_build_free_nids = false;
14461446
mutex_unlock(&nm_i->build_lock);
14471447
goto retry;
14481448
}

0 commit comments

Comments
 (0)