Skip to content

Commit

Permalink
f2fs: push some variables to debug part
Browse files Browse the repository at this point in the history
Some, counters are needed only for the statistical information
while debugging.
So, those can be controlled using CONFIG_F2FS_STAT_FS,
pushing the usage for few variables under this flag.

Signed-off-by: Namjae Jeon <[email protected]>
Signed-off-by: Amit Sahrawat <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
namjaejeon authored and Jaegeuk Kim committed May 28, 2013
1 parent a9841c4 commit 35b09d8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions fs/f2fs/checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,9 @@ void set_dirty_dir_page(struct inode *inode, struct page *page)
}
}
list_add_tail(&new->list, head);
#ifdef CONFIG_F2FS_STAT_FS
sbi->n_dirty_dirs++;
#endif

BUG_ON(!S_ISDIR(inode->i_mode));
out:
Expand Down Expand Up @@ -508,7 +510,9 @@ void remove_dirty_dir_inode(struct inode *inode)
if (entry->inode == inode) {
list_del(&entry->list);
kmem_cache_free(inode_entry_slab, entry);
#ifdef CONFIG_F2FS_STAT_FS
sbi->n_dirty_dirs--;
#endif
break;
}
}
Expand Down
6 changes: 6 additions & 0 deletions fs/f2fs/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ static int check_extent_cache(struct inode *inode, pgoff_t pgofs,
struct buffer_head *bh_result)
{
struct f2fs_inode_info *fi = F2FS_I(inode);
#ifdef CONFIG_F2FS_STAT_FS
struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
#endif
pgoff_t start_fofs, end_fofs;
block_t start_blkaddr;

Expand All @@ -78,7 +80,9 @@ static int check_extent_cache(struct inode *inode, pgoff_t pgofs,
return 0;
}

#ifdef CONFIG_F2FS_STAT_FS
sbi->total_hit_ext++;
#endif
start_fofs = fi->ext.fofs;
end_fofs = fi->ext.fofs + fi->ext.len - 1;
start_blkaddr = fi->ext.blk_addr;
Expand All @@ -96,7 +100,9 @@ static int check_extent_cache(struct inode *inode, pgoff_t pgofs,
else
bh_result->b_size = UINT_MAX;

#ifdef CONFIG_F2FS_STAT_FS
sbi->read_hit_ext++;
#endif
read_unlock(&fi->ext.ext_lock);
return 1;
}
Expand Down
6 changes: 4 additions & 2 deletions fs/f2fs/f2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ struct f2fs_sb_info {
/* for directory inode management */
struct list_head dir_inode_list; /* dir inode list */
spinlock_t dir_inode_lock; /* for dir inode list lock */
unsigned int n_dirty_dirs; /* # of dir inodes */

/* basic file system units */
unsigned int log_sectors_per_block; /* log2 sectors per block */
Expand Down Expand Up @@ -409,12 +408,15 @@ struct f2fs_sb_info {
* for stat information.
* one is for the LFS mode, and the other is for the SSR mode.
*/
#ifdef CONFIG_F2FS_STAT_FS
struct f2fs_stat_info *stat_info; /* FS status information */
unsigned int segment_count[2]; /* # of allocated segments */
unsigned int block_count[2]; /* # of allocated blocks */
unsigned int last_victim[2]; /* last victim segment # */
int total_hit_ext, read_hit_ext; /* extent cache hit ratio */
int bg_gc; /* background gc calls */
unsigned int n_dirty_dirs; /* # of dir inodes */
#endif
unsigned int last_victim[2]; /* last victim segment # */
spinlock_t stat_lock; /* lock for stat operations */
};

Expand Down
2 changes: 2 additions & 0 deletions fs/f2fs/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ static int gc_thread_func(void *data)
else
wait_ms = increase_sleep_time(wait_ms);

#ifdef CONFIG_F2FS_STAT_FS
sbi->bg_gc++;
#endif

/* if return value is not zero, no victim was selected */
if (f2fs_gc(sbi))
Expand Down
5 changes: 5 additions & 0 deletions fs/f2fs/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,10 @@ static void allocate_segment_by_default(struct f2fs_sb_info *sbi,
else
new_curseg(sbi, type, false);
out:
#ifdef CONFIG_F2FS_STAT_FS
sbi->segment_count[curseg->alloc_type]++;
#endif
return;
}

void allocate_new_segments(struct f2fs_sb_info *sbi)
Expand Down Expand Up @@ -846,7 +849,9 @@ static void do_write_page(struct f2fs_sb_info *sbi, struct page *page,

mutex_lock(&sit_i->sentry_lock);
__refresh_next_blkoff(sbi, curseg);
#ifdef CONFIG_F2FS_STAT_FS
sbi->block_count[curseg->alloc_type]++;
#endif

/*
* SIT information should be updated before segment allocation,
Expand Down

0 comments on commit 35b09d8

Please sign in to comment.