f2fs: add need_dentry_mark
This patch introduces need_dentry_mark() to clean up and avoid redundant node locks. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Родитель
01f28610a1
Коммит
2dcf51ab2f
|
@ -1565,6 +1565,7 @@ struct dnode_of_data;
|
||||||
struct node_info;
|
struct node_info;
|
||||||
|
|
||||||
bool available_free_memory(struct f2fs_sb_info *, int);
|
bool available_free_memory(struct f2fs_sb_info *, int);
|
||||||
|
int need_dentry_mark(struct f2fs_sb_info *, nid_t);
|
||||||
bool is_checkpointed_node(struct f2fs_sb_info *, nid_t);
|
bool is_checkpointed_node(struct f2fs_sb_info *, nid_t);
|
||||||
bool need_inode_block_update(struct f2fs_sb_info *, nid_t);
|
bool need_inode_block_update(struct f2fs_sb_info *, nid_t);
|
||||||
void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *);
|
void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *);
|
||||||
|
|
|
@ -195,6 +195,23 @@ static unsigned int __gang_lookup_nat_set(struct f2fs_nm_info *nm_i,
|
||||||
start, nr);
|
start, nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int need_dentry_mark(struct f2fs_sb_info *sbi, nid_t nid)
|
||||||
|
{
|
||||||
|
struct f2fs_nm_info *nm_i = NM_I(sbi);
|
||||||
|
struct nat_entry *e;
|
||||||
|
bool need = false;
|
||||||
|
|
||||||
|
down_read(&nm_i->nat_tree_lock);
|
||||||
|
e = __lookup_nat_cache(nm_i, nid);
|
||||||
|
if (e) {
|
||||||
|
if (!get_nat_flag(e, IS_CHECKPOINTED) &&
|
||||||
|
!get_nat_flag(e, HAS_FSYNCED_INODE))
|
||||||
|
need = true;
|
||||||
|
}
|
||||||
|
up_read(&nm_i->nat_tree_lock);
|
||||||
|
return need;
|
||||||
|
}
|
||||||
|
|
||||||
bool is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid)
|
bool is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid)
|
||||||
{
|
{
|
||||||
struct f2fs_nm_info *nm_i = NM_I(sbi);
|
struct f2fs_nm_info *nm_i = NM_I(sbi);
|
||||||
|
@ -209,20 +226,6 @@ bool is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid)
|
||||||
return is_cp;
|
return is_cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool has_fsynced_inode(struct f2fs_sb_info *sbi, nid_t ino)
|
|
||||||
{
|
|
||||||
struct f2fs_nm_info *nm_i = NM_I(sbi);
|
|
||||||
struct nat_entry *e;
|
|
||||||
bool fsynced = false;
|
|
||||||
|
|
||||||
down_read(&nm_i->nat_tree_lock);
|
|
||||||
e = __lookup_nat_cache(nm_i, ino);
|
|
||||||
if (e && get_nat_flag(e, HAS_FSYNCED_INODE))
|
|
||||||
fsynced = true;
|
|
||||||
up_read(&nm_i->nat_tree_lock);
|
|
||||||
return fsynced;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool need_inode_block_update(struct f2fs_sb_info *sbi, nid_t ino)
|
bool need_inode_block_update(struct f2fs_sb_info *sbi, nid_t ino)
|
||||||
{
|
{
|
||||||
struct f2fs_nm_info *nm_i = NM_I(sbi);
|
struct f2fs_nm_info *nm_i = NM_I(sbi);
|
||||||
|
@ -1206,13 +1209,9 @@ continue_unlock:
|
||||||
/* called by fsync() */
|
/* called by fsync() */
|
||||||
if (ino && IS_DNODE(page)) {
|
if (ino && IS_DNODE(page)) {
|
||||||
set_fsync_mark(page, 1);
|
set_fsync_mark(page, 1);
|
||||||
if (IS_INODE(page)) {
|
if (IS_INODE(page))
|
||||||
if (!is_checkpointed_node(sbi, ino) &&
|
set_dentry_mark(page,
|
||||||
!has_fsynced_inode(sbi, ino))
|
need_dentry_mark(sbi, ino));
|
||||||
set_dentry_mark(page, 1);
|
|
||||||
else
|
|
||||||
set_dentry_mark(page, 0);
|
|
||||||
}
|
|
||||||
nwritten++;
|
nwritten++;
|
||||||
} else {
|
} else {
|
||||||
set_fsync_mark(page, 0);
|
set_fsync_mark(page, 0);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче