Commit 9df27d98 authored by Gu Zheng's avatar Gu Zheng Committed by Jaegeuk Kim

f2fs: add help function META_MAPPING

Introduce help function META_MAPPING() to get the cache meta blocks'
address space.
Signed-off-by: default avatarGu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
parent e8dae604
...@@ -30,7 +30,7 @@ static struct kmem_cache *inode_entry_slab; ...@@ -30,7 +30,7 @@ static struct kmem_cache *inode_entry_slab;
*/ */
struct page *grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index) struct page *grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
{ {
struct address_space *mapping = sbi->meta_inode->i_mapping; struct address_space *mapping = META_MAPPING(sbi);
struct page *page = NULL; struct page *page = NULL;
repeat: repeat:
page = grab_cache_page(mapping, index); page = grab_cache_page(mapping, index);
...@@ -50,7 +50,7 @@ struct page *grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index) ...@@ -50,7 +50,7 @@ struct page *grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
*/ */
struct page *get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index) struct page *get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
{ {
struct address_space *mapping = sbi->meta_inode->i_mapping; struct address_space *mapping = META_MAPPING(sbi);
struct page *page; struct page *page;
repeat: repeat:
page = grab_cache_page(mapping, index); page = grab_cache_page(mapping, index);
...@@ -128,7 +128,7 @@ static int f2fs_write_meta_pages(struct address_space *mapping, ...@@ -128,7 +128,7 @@ static int f2fs_write_meta_pages(struct address_space *mapping,
long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type, long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
long nr_to_write) long nr_to_write)
{ {
struct address_space *mapping = sbi->meta_inode->i_mapping; struct address_space *mapping = META_MAPPING(sbi);
pgoff_t index = 0, end = LONG_MAX; pgoff_t index = 0, end = LONG_MAX;
struct pagevec pvec; struct pagevec pvec;
long nwritten = 0; long nwritten = 0;
...@@ -771,7 +771,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount) ...@@ -771,7 +771,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
wait_on_all_pages_writeback(sbi); wait_on_all_pages_writeback(sbi);
filemap_fdatawait_range(sbi->node_inode->i_mapping, 0, LONG_MAX); filemap_fdatawait_range(sbi->node_inode->i_mapping, 0, LONG_MAX);
filemap_fdatawait_range(sbi->meta_inode->i_mapping, 0, LONG_MAX); filemap_fdatawait_range(META_MAPPING(sbi), 0, LONG_MAX);
/* update user_block_counts */ /* update user_block_counts */
sbi->last_valid_block_count = sbi->total_valid_block_count; sbi->last_valid_block_count = sbi->total_valid_block_count;
......
...@@ -53,7 +53,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) ...@@ -53,7 +53,7 @@ static void update_general_status(struct f2fs_sb_info *sbi)
si->prefree_count = prefree_segments(sbi); si->prefree_count = prefree_segments(sbi);
si->dirty_count = dirty_segments(sbi); si->dirty_count = dirty_segments(sbi);
si->node_pages = sbi->node_inode->i_mapping->nrpages; si->node_pages = sbi->node_inode->i_mapping->nrpages;
si->meta_pages = sbi->meta_inode->i_mapping->nrpages; si->meta_pages = META_MAPPING(sbi)->nrpages;
si->nats = NM_I(sbi)->nat_cnt; si->nats = NM_I(sbi)->nat_cnt;
si->sits = SIT_I(sbi)->dirty_sentries; si->sits = SIT_I(sbi)->dirty_sentries;
si->fnids = NM_I(sbi)->fcnt; si->fnids = NM_I(sbi)->fcnt;
...@@ -168,7 +168,7 @@ static void update_mem_info(struct f2fs_sb_info *sbi) ...@@ -168,7 +168,7 @@ static void update_mem_info(struct f2fs_sb_info *sbi)
si->cache_mem += NM_I(sbi)->nat_cnt; si->cache_mem += NM_I(sbi)->nat_cnt;
npages = sbi->node_inode->i_mapping->nrpages; npages = sbi->node_inode->i_mapping->nrpages;
si->cache_mem += npages << PAGE_CACHE_SHIFT; si->cache_mem += npages << PAGE_CACHE_SHIFT;
npages = sbi->meta_inode->i_mapping->nrpages; npages = META_MAPPING(sbi)->nrpages;
si->cache_mem += npages << PAGE_CACHE_SHIFT; si->cache_mem += npages << PAGE_CACHE_SHIFT;
si->cache_mem += sbi->n_orphans * sizeof(struct orphan_inode_entry); si->cache_mem += sbi->n_orphans * sizeof(struct orphan_inode_entry);
si->cache_mem += sbi->n_dirty_dirs * sizeof(struct dir_inode_entry); si->cache_mem += sbi->n_dirty_dirs * sizeof(struct dir_inode_entry);
......
...@@ -533,6 +533,11 @@ static inline struct dirty_seglist_info *DIRTY_I(struct f2fs_sb_info *sbi) ...@@ -533,6 +533,11 @@ static inline struct dirty_seglist_info *DIRTY_I(struct f2fs_sb_info *sbi)
return (struct dirty_seglist_info *)(SM_I(sbi)->dirty_info); return (struct dirty_seglist_info *)(SM_I(sbi)->dirty_info);
} }
static inline struct address_space *META_MAPPING(struct f2fs_sb_info *sbi)
{
return sbi->meta_inode->i_mapping;
}
static inline void F2FS_SET_SB_DIRT(struct f2fs_sb_info *sbi) static inline void F2FS_SET_SB_DIRT(struct f2fs_sb_info *sbi)
{ {
sbi->s_dirty = 1; sbi->s_dirty = 1;
......
...@@ -87,7 +87,7 @@ static struct page *get_next_nat_page(struct f2fs_sb_info *sbi, nid_t nid) ...@@ -87,7 +87,7 @@ static struct page *get_next_nat_page(struct f2fs_sb_info *sbi, nid_t nid)
*/ */
static void ra_nat_pages(struct f2fs_sb_info *sbi, int nid) static void ra_nat_pages(struct f2fs_sb_info *sbi, int nid)
{ {
struct address_space *mapping = sbi->meta_inode->i_mapping; struct address_space *mapping = META_MAPPING(sbi);
struct f2fs_nm_info *nm_i = NM_I(sbi); struct f2fs_nm_info *nm_i = NM_I(sbi);
struct page *page; struct page *page;
pgoff_t index; pgoff_t index;
......
...@@ -1585,7 +1585,7 @@ static int build_curseg(struct f2fs_sb_info *sbi) ...@@ -1585,7 +1585,7 @@ static int build_curseg(struct f2fs_sb_info *sbi)
static int ra_sit_pages(struct f2fs_sb_info *sbi, int start, int nrpages) static int ra_sit_pages(struct f2fs_sb_info *sbi, int start, int nrpages)
{ {
struct address_space *mapping = sbi->meta_inode->i_mapping; struct address_space *mapping = META_MAPPING(sbi);
struct page *page; struct page *page;
block_t blk_addr, prev_blk_addr = 0; block_t blk_addr, prev_blk_addr = 0;
int sit_blk_cnt = SIT_BLK_CNT(sbi); int sit_blk_cnt = SIT_BLK_CNT(sbi);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment