summaryrefslogtreecommitdiff
path: root/fs/f2fs/checkpoint.c
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2015-12-15 08:30:45 +0300
committerJaegeuk Kim <jaegeuk@kernel.org>2015-12-16 00:24:19 +0300
commit2710fd7e00b4f77dbe807efaf546bed00b62e65e (patch)
treefcd67808c9f7e25b369694015c059fb25a9b9d15 /fs/f2fs/checkpoint.c
parenta49324f127dec918f5a3b3f145d0bf2fb81f4588 (diff)
downloadlinux-2710fd7e00b4f77dbe807efaf546bed00b62e65e.tar.xz
f2fs: introduce dirty list node in inode info
Add a new dirt list node member in inode info for linking the inode to global dirty list in superblock, instead of old implementation which allocate slab cache memory as an entry to inode. It avoids memory pressure due to slab cache allocation, and also makes codes more clean. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/checkpoint.c')
-rw-r--r--fs/f2fs/checkpoint.c54
1 files changed, 17 insertions, 37 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index b839f5f3385c..1aca402cab9c 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -722,25 +722,23 @@ fail_no_cp:
return -EINVAL;
}
-static int __add_dirty_inode(struct inode *inode, struct inode_entry *new)
+static void __add_dirty_inode(struct inode *inode)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
+ struct f2fs_inode_info *fi = F2FS_I(inode);
- if (is_inode_flag_set(F2FS_I(inode), FI_DIRTY_DIR))
- return -EEXIST;
+ if (is_inode_flag_set(fi, FI_DIRTY_DIR))
+ return;
- set_inode_flag(F2FS_I(inode), FI_DIRTY_DIR);
- F2FS_I(inode)->dirty_dir = new;
- list_add_tail(&new->list, &sbi->dir_inode_list);
+ set_inode_flag(fi, FI_DIRTY_DIR);
+ list_add_tail(&fi->dirty_list, &sbi->dir_inode_list);
stat_inc_dirty_dir(sbi);
- return 0;
+ return;
}
void update_dirty_page(struct inode *inode, struct page *page)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
- struct inode_entry *new;
- int ret = 0;
if (!S_ISDIR(inode->i_mode) && !S_ISREG(inode->i_mode) &&
!S_ISLNK(inode->i_mode))
@@ -751,17 +749,11 @@ void update_dirty_page(struct inode *inode, struct page *page)
goto out;
}
- new = f2fs_kmem_cache_alloc(inode_entry_slab, GFP_NOFS);
- new->inode = inode;
- INIT_LIST_HEAD(&new->list);
-
spin_lock(&sbi->dir_inode_lock);
- ret = __add_dirty_inode(inode, new);
+ __add_dirty_inode(inode);
inode_inc_dirty_pages(inode);
spin_unlock(&sbi->dir_inode_lock);
- if (ret)
- kmem_cache_free(inode_entry_slab, new);
out:
SetPagePrivate(page);
f2fs_trace_pid(page);
@@ -770,25 +762,16 @@ out:
void add_dirty_dir_inode(struct inode *inode)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
- struct inode_entry *new =
- f2fs_kmem_cache_alloc(inode_entry_slab, GFP_NOFS);
- int ret = 0;
-
- new->inode = inode;
- INIT_LIST_HEAD(&new->list);
spin_lock(&sbi->dir_inode_lock);
- ret = __add_dirty_inode(inode, new);
+ __add_dirty_inode(inode);
spin_unlock(&sbi->dir_inode_lock);
-
- if (ret)
- kmem_cache_free(inode_entry_slab, new);
}
void remove_dirty_dir_inode(struct inode *inode)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
- struct inode_entry *entry;
+ struct f2fs_inode_info *fi = F2FS_I(inode);
if (!S_ISDIR(inode->i_mode))
return;
@@ -800,17 +783,14 @@ void remove_dirty_dir_inode(struct inode *inode)
return;
}
- 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);
+ list_del_init(&fi->dirty_list);
+ clear_inode_flag(fi, FI_DIRTY_DIR);
stat_dec_dirty_dir(sbi);
spin_unlock(&sbi->dir_inode_lock);
- kmem_cache_free(inode_entry_slab, entry);
/* 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);
+ if (is_inode_flag_set(fi, FI_DELAY_IPUT)) {
+ clear_inode_flag(fi, FI_DELAY_IPUT);
iput(inode);
}
}
@@ -818,8 +798,8 @@ void remove_dirty_dir_inode(struct inode *inode)
void sync_dirty_dir_inodes(struct f2fs_sb_info *sbi)
{
struct list_head *head;
- struct inode_entry *entry;
struct inode *inode;
+ struct f2fs_inode_info *fi;
retry:
if (unlikely(f2fs_cp_error(sbi)))
return;
@@ -831,8 +811,8 @@ retry:
spin_unlock(&sbi->dir_inode_lock);
return;
}
- entry = list_entry(head->next, struct inode_entry, list);
- inode = igrab(entry->inode);
+ fi = list_entry(head->next, struct f2fs_inode_info, dirty_list);
+ inode = igrab(&fi->vfs_inode);
spin_unlock(&sbi->dir_inode_lock);
if (inode) {
filemap_fdatawrite(inode->i_mapping);