f2fs: add info of appended or updated data writes

This patch introduces a inode number list in which represents inodes having
appended data writes or updated data writes after last checkpoint.
This will be used at fsync to determine whether the recovery information
should be written or not.

Reviewed-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Jaegeuk Kim 2014-07-25 07:40:59 -07:00
parent 39efac41fb
commit fff04f90c1
5 changed files with 53 additions and 0 deletions

View File

@ -326,6 +326,44 @@ static void __remove_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type)
spin_unlock(&sbi->ino_lock[type]); spin_unlock(&sbi->ino_lock[type]);
} }
void add_dirty_inode(struct f2fs_sb_info *sbi, nid_t ino, int type)
{
/* add new dirty ino entry into list */
__add_ino_entry(sbi, ino, type);
}
void remove_dirty_inode(struct f2fs_sb_info *sbi, nid_t ino, int type)
{
/* remove dirty ino entry from list */
__remove_ino_entry(sbi, ino, type);
}
/* mode should be APPEND_INO or UPDATE_INO */
bool exist_written_data(struct f2fs_sb_info *sbi, nid_t ino, int mode)
{
struct ino_entry *e;
spin_lock(&sbi->ino_lock[mode]);
e = radix_tree_lookup(&sbi->ino_root[mode], ino);
spin_unlock(&sbi->ino_lock[mode]);
return e ? true : false;
}
static void release_dirty_inode(struct f2fs_sb_info *sbi)
{
struct ino_entry *e, *tmp;
int i;
for (i = APPEND_INO; i <= UPDATE_INO; i++) {
spin_lock(&sbi->ino_lock[i]);
list_for_each_entry_safe(e, tmp, &sbi->ino_list[i], list) {
list_del(&e->list);
radix_tree_delete(&sbi->ino_root[i], e->ino);
kmem_cache_free(ino_entry_slab, e);
}
spin_unlock(&sbi->ino_lock[i]);
}
}
int acquire_orphan_inode(struct f2fs_sb_info *sbi) int acquire_orphan_inode(struct f2fs_sb_info *sbi)
{ {
int err = 0; int err = 0;
@ -897,6 +935,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
if (unlikely(!is_set_ckpt_flags(ckpt, CP_ERROR_FLAG))) { if (unlikely(!is_set_ckpt_flags(ckpt, CP_ERROR_FLAG))) {
clear_prefree_segments(sbi); clear_prefree_segments(sbi);
release_dirty_inode(sbi);
F2FS_RESET_SB_DIRT(sbi); F2FS_RESET_SB_DIRT(sbi);
} }
} }

View File

@ -789,9 +789,11 @@ int do_write_data_page(struct page *page, struct f2fs_io_info *fio)
!is_cold_data(page) && !is_cold_data(page) &&
need_inplace_update(inode))) { need_inplace_update(inode))) {
rewrite_data_page(page, old_blkaddr, fio); rewrite_data_page(page, old_blkaddr, fio);
set_inode_flag(F2FS_I(inode), FI_UPDATE_WRITE);
} else { } else {
write_data_page(page, &dn, &new_blkaddr, fio); write_data_page(page, &dn, &new_blkaddr, fio);
update_extent_cache(new_blkaddr, &dn); update_extent_cache(new_blkaddr, &dn);
set_inode_flag(F2FS_I(inode), FI_APPEND_WRITE);
} }
out_writepage: out_writepage:
f2fs_put_dnode(&dn); f2fs_put_dnode(&dn);

View File

@ -103,6 +103,8 @@ enum {
/* for the list of ino */ /* for the list of ino */
enum { enum {
ORPHAN_INO, /* for orphan ino list */ ORPHAN_INO, /* for orphan ino list */
APPEND_INO, /* for append ino list */
UPDATE_INO, /* for update ino list */
MAX_INO_ENTRY, /* max. list */ MAX_INO_ENTRY, /* max. list */
}; };
@ -994,6 +996,8 @@ enum {
FI_NO_EXTENT, /* not to use the extent cache */ FI_NO_EXTENT, /* not to use the extent cache */
FI_INLINE_XATTR, /* used for inline xattr */ FI_INLINE_XATTR, /* used for inline xattr */
FI_INLINE_DATA, /* used for inline data*/ FI_INLINE_DATA, /* used for inline data*/
FI_APPEND_WRITE, /* inode has appended data */
FI_UPDATE_WRITE, /* inode has in-place-update data */
}; };
static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag) static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag)
@ -1252,6 +1256,9 @@ struct page *grab_meta_page(struct f2fs_sb_info *, pgoff_t);
struct page *get_meta_page(struct f2fs_sb_info *, pgoff_t); struct page *get_meta_page(struct f2fs_sb_info *, pgoff_t);
int ra_meta_pages(struct f2fs_sb_info *, int, int, int); int ra_meta_pages(struct f2fs_sb_info *, int, int, int);
long sync_meta_pages(struct f2fs_sb_info *, enum page_type, long); long sync_meta_pages(struct f2fs_sb_info *, enum page_type, long);
void add_dirty_inode(struct f2fs_sb_info *, nid_t, int type);
void remove_dirty_inode(struct f2fs_sb_info *, nid_t, int type);
bool exist_written_data(struct f2fs_sb_info *, nid_t, int);
int acquire_orphan_inode(struct f2fs_sb_info *); int acquire_orphan_inode(struct f2fs_sb_info *);
void release_orphan_inode(struct f2fs_sb_info *); void release_orphan_inode(struct f2fs_sb_info *);
void add_orphan_inode(struct f2fs_sb_info *, nid_t); void add_orphan_inode(struct f2fs_sb_info *, nid_t);

View File

@ -172,6 +172,7 @@ int f2fs_write_inline_data(struct inode *inode,
stat_inc_inline_inode(inode); stat_inc_inline_inode(inode);
} }
set_inode_flag(F2FS_I(inode), FI_APPEND_WRITE);
sync_inode_page(&dn); sync_inode_page(&dn);
f2fs_put_dnode(&dn); f2fs_put_dnode(&dn);

View File

@ -296,6 +296,10 @@ void f2fs_evict_inode(struct inode *inode)
sb_end_intwrite(inode->i_sb); sb_end_intwrite(inode->i_sb);
no_delete: no_delete:
invalidate_mapping_pages(NODE_MAPPING(sbi), inode->i_ino, inode->i_ino); invalidate_mapping_pages(NODE_MAPPING(sbi), inode->i_ino, inode->i_ino);
if (is_inode_flag_set(F2FS_I(inode), FI_APPEND_WRITE))
add_dirty_inode(sbi, inode->i_ino, APPEND_INO);
if (is_inode_flag_set(F2FS_I(inode), FI_UPDATE_WRITE))
add_dirty_inode(sbi, inode->i_ino, UPDATE_INO);
out_clear: out_clear:
clear_inode(inode); clear_inode(inode);
} }