forked from Minki/linux
f2fs: remove costly dirty_dir_inode operations
This patch removes list opeations in handling dirty dir inodes. Previously, F2FS traverses whole the list of dirty dir inodes to check whether there is an existing inode or not, resulting in heavy CPU overheads. So this patch removes such the traverse operations by adding FI_DIRTY_DIR to indicate the inode lies on the list or not. Through this simple flag, we can remove redundant operations gracefully. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
This commit is contained in:
parent
15c6e3aae6
commit
ed57c27f73
@ -552,14 +552,13 @@ fail_no_cp:
|
||||
static int __add_dirty_inode(struct inode *inode, struct dir_inode_entry *new)
|
||||
{
|
||||
struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
|
||||
struct list_head *head = &sbi->dir_inode_list;
|
||||
struct dir_inode_entry *entry;
|
||||
|
||||
list_for_each_entry(entry, head, list)
|
||||
if (unlikely(entry->inode == inode))
|
||||
return -EEXIST;
|
||||
if (is_inode_flag_set(F2FS_I(inode), FI_DIRTY_DIR))
|
||||
return -EEXIST;
|
||||
|
||||
list_add_tail(&new->list, head);
|
||||
set_inode_flag(F2FS_I(inode), FI_DIRTY_DIR);
|
||||
F2FS_I(inode)->dirty_dir = new;
|
||||
list_add_tail(&new->list, &sbi->dir_inode_list);
|
||||
stat_inc_dirty_dir(sbi);
|
||||
return 0;
|
||||
}
|
||||
@ -608,31 +607,26 @@ void add_dirty_dir_inode(struct inode *inode)
|
||||
void remove_dirty_dir_inode(struct inode *inode)
|
||||
{
|
||||
struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
|
||||
struct list_head *head;
|
||||
struct dir_inode_entry *entry;
|
||||
|
||||
if (!S_ISDIR(inode->i_mode))
|
||||
return;
|
||||
|
||||
spin_lock(&sbi->dir_inode_lock);
|
||||
if (get_dirty_dents(inode)) {
|
||||
if (get_dirty_dents(inode) ||
|
||||
!is_inode_flag_set(F2FS_I(inode), FI_DIRTY_DIR)) {
|
||||
spin_unlock(&sbi->dir_inode_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
head = &sbi->dir_inode_list;
|
||||
list_for_each_entry(entry, head, list) {
|
||||
if (entry->inode == inode) {
|
||||
list_del(&entry->list);
|
||||
stat_dec_dirty_dir(sbi);
|
||||
spin_unlock(&sbi->dir_inode_lock);
|
||||
kmem_cache_free(inode_entry_slab, entry);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
entry = F2FS_I(inode)->dirty_dir;
|
||||
list_del(&entry->list);
|
||||
F2FS_I(inode)->dirty_dir = NULL;
|
||||
clear_inode_flag(F2FS_I(inode), FI_DIRTY_DIR);
|
||||
stat_dec_dirty_dir(sbi);
|
||||
spin_unlock(&sbi->dir_inode_lock);
|
||||
kmem_cache_free(inode_entry_slab, entry);
|
||||
|
||||
done:
|
||||
/* Only from the recovery routine */
|
||||
if (is_inode_flag_set(F2FS_I(inode), FI_DELAY_IPUT)) {
|
||||
clear_inode_flag(F2FS_I(inode), FI_DELAY_IPUT);
|
||||
@ -640,26 +634,6 @@ done:
|
||||
}
|
||||
}
|
||||
|
||||
struct inode *check_dirty_dir_inode(struct f2fs_sb_info *sbi, nid_t ino)
|
||||
{
|
||||
|
||||
struct list_head *head;
|
||||
struct inode *inode = NULL;
|
||||
struct dir_inode_entry *entry;
|
||||
|
||||
spin_lock(&sbi->dir_inode_lock);
|
||||
|
||||
head = &sbi->dir_inode_list;
|
||||
list_for_each_entry(entry, head, list) {
|
||||
if (entry->inode->i_ino == ino) {
|
||||
inode = entry->inode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
spin_unlock(&sbi->dir_inode_lock);
|
||||
return inode;
|
||||
}
|
||||
|
||||
void sync_dirty_dir_inodes(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
struct list_head *head;
|
||||
|
@ -218,6 +218,7 @@ struct f2fs_inode_info {
|
||||
nid_t i_xattr_nid; /* node id that contains xattrs */
|
||||
unsigned long long xattr_ver; /* cp version of xattr modification */
|
||||
struct extent_info ext; /* in-memory extent cache entry */
|
||||
struct dir_inode_entry *dirty_dir; /* the pointer of dirty dir */
|
||||
};
|
||||
|
||||
static inline void get_extent_info(struct extent_info *ext,
|
||||
@ -958,6 +959,7 @@ static inline int f2fs_clear_bit(unsigned int nr, char *addr)
|
||||
enum {
|
||||
FI_NEW_INODE, /* indicate newly allocated inode */
|
||||
FI_DIRTY_INODE, /* indicate inode is dirty or not */
|
||||
FI_DIRTY_DIR, /* indicate directory has dirty pages */
|
||||
FI_INC_LINK, /* need to increment i_nlink */
|
||||
FI_ACL_MODE, /* indicate acl mode */
|
||||
FI_NO_ALLOC, /* should not allocate any blocks */
|
||||
@ -1222,7 +1224,6 @@ int get_valid_checkpoint(struct f2fs_sb_info *);
|
||||
void set_dirty_dir_page(struct inode *, struct page *);
|
||||
void add_dirty_dir_inode(struct inode *);
|
||||
void remove_dirty_dir_inode(struct inode *);
|
||||
struct inode *check_dirty_dir_inode(struct f2fs_sb_info *, nid_t);
|
||||
void sync_dirty_dir_inodes(struct f2fs_sb_info *);
|
||||
void write_checkpoint(struct f2fs_sb_info *, bool);
|
||||
void init_orphan_info(struct f2fs_sb_info *);
|
||||
|
@ -46,15 +46,17 @@ static int recover_dentry(struct page *ipage, struct inode *inode)
|
||||
struct inode *dir, *einode;
|
||||
int err = 0;
|
||||
|
||||
dir = check_dirty_dir_inode(F2FS_SB(inode->i_sb), pino);
|
||||
if (!dir) {
|
||||
dir = f2fs_iget(inode->i_sb, pino);
|
||||
if (IS_ERR(dir)) {
|
||||
err = PTR_ERR(dir);
|
||||
goto out;
|
||||
}
|
||||
set_inode_flag(F2FS_I(dir), FI_DELAY_IPUT);
|
||||
dir = f2fs_iget(inode->i_sb, pino);
|
||||
if (IS_ERR(dir)) {
|
||||
err = PTR_ERR(dir);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (is_inode_flag_set(F2FS_I(dir), FI_DIRTY_DIR)) {
|
||||
iput(dir);
|
||||
} else {
|
||||
add_dirty_dir_inode(dir);
|
||||
set_inode_flag(F2FS_I(dir), FI_DELAY_IPUT);
|
||||
}
|
||||
|
||||
name.len = le32_to_cpu(raw_inode->i_namelen);
|
||||
|
Loading…
Reference in New Issue
Block a user