mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
fffc2a00fc
commit
f978f5a061
|
@ -417,7 +417,6 @@ struct f2fs_sb_info {
|
||||||
struct mutex node_write; /* locking node writes */
|
struct mutex node_write; /* locking node writes */
|
||||||
struct mutex writepages; /* mutex for writepages() */
|
struct mutex writepages; /* mutex for writepages() */
|
||||||
bool por_doing; /* recovery is doing or not */
|
bool por_doing; /* recovery is doing or not */
|
||||||
bool on_build_free_nids; /* build_free_nids is doing */
|
|
||||||
wait_queue_head_t cp_wait;
|
wait_queue_head_t cp_wait;
|
||||||
|
|
||||||
/* for orphan inode management */
|
/* for orphan inode management */
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include "segment.h"
|
#include "segment.h"
|
||||||
#include <trace/events/f2fs.h>
|
#include <trace/events/f2fs.h>
|
||||||
|
|
||||||
|
#define on_build_free_nids(nmi) mutex_is_locked(&nm_i->build_lock)
|
||||||
|
|
||||||
static struct kmem_cache *nat_entry_slab;
|
static struct kmem_cache *nat_entry_slab;
|
||||||
static struct kmem_cache *free_nid_slab;
|
static struct kmem_cache *free_nid_slab;
|
||||||
|
|
||||||
|
@ -1422,7 +1424,7 @@ bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
|
||||||
spin_lock(&nm_i->free_nid_list_lock);
|
spin_lock(&nm_i->free_nid_list_lock);
|
||||||
|
|
||||||
/* We should not use stale free nids created by build_free_nids */
|
/* We should not use stale free nids created by build_free_nids */
|
||||||
if (nm_i->fcnt && !sbi->on_build_free_nids) {
|
if (nm_i->fcnt && !on_build_free_nids(nm_i)) {
|
||||||
f2fs_bug_on(list_empty(&nm_i->free_nid_list));
|
f2fs_bug_on(list_empty(&nm_i->free_nid_list));
|
||||||
list_for_each(this, &nm_i->free_nid_list) {
|
list_for_each(this, &nm_i->free_nid_list) {
|
||||||
i = list_entry(this, struct free_nid, list);
|
i = list_entry(this, struct free_nid, list);
|
||||||
|
@ -1441,9 +1443,7 @@ bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
|
||||||
|
|
||||||
/* Let's scan nat pages and its caches to get free nids */
|
/* Let's scan nat pages and its caches to get free nids */
|
||||||
mutex_lock(&nm_i->build_lock);
|
mutex_lock(&nm_i->build_lock);
|
||||||
sbi->on_build_free_nids = true;
|
|
||||||
build_free_nids(sbi);
|
build_free_nids(sbi);
|
||||||
sbi->on_build_free_nids = false;
|
|
||||||
mutex_unlock(&nm_i->build_lock);
|
mutex_unlock(&nm_i->build_lock);
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue