f2fs: use atomic for counting inode with inline_{dir,inode} flag

As inline_{dir,inode} stat is increased/decreased concurrently by multi threads,
so the value is not so accurate, let's use atomic type for counting accurately.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Chao Yu 2014-12-08 19:08:20 +08:00 коммит произвёл Jaegeuk Kim
Родитель 51455b1938
Коммит 03e14d522e
2 изменённых файлов: 11 добавлений и 8 удалений

Просмотреть файл

@ -46,8 +46,8 @@ static void update_general_status(struct f2fs_sb_info *sbi)
si->valid_count = valid_user_blocks(sbi); si->valid_count = valid_user_blocks(sbi);
si->valid_node_count = valid_node_count(sbi); si->valid_node_count = valid_node_count(sbi);
si->valid_inode_count = valid_inode_count(sbi); si->valid_inode_count = valid_inode_count(sbi);
si->inline_inode = sbi->inline_inode; si->inline_inode = atomic_read(&sbi->inline_inode);
si->inline_dir = sbi->inline_dir; si->inline_dir = atomic_read(&sbi->inline_dir);
si->utilization = utilization(sbi); si->utilization = utilization(sbi);
si->free_segs = free_segments(sbi); si->free_segs = free_segments(sbi);
@ -329,6 +329,9 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)
si->sbi = sbi; si->sbi = sbi;
sbi->stat_info = si; sbi->stat_info = si;
atomic_set(&sbi->inline_inode, 0);
atomic_set(&sbi->inline_dir, 0);
mutex_lock(&f2fs_stat_mutex); mutex_lock(&f2fs_stat_mutex);
list_add_tail(&si->stat_list, &f2fs_stat_list); list_add_tail(&si->stat_list, &f2fs_stat_list);
mutex_unlock(&f2fs_stat_mutex); mutex_unlock(&f2fs_stat_mutex);

Просмотреть файл

@ -590,8 +590,8 @@ struct f2fs_sb_info {
unsigned int segment_count[2]; /* # of allocated segments */ unsigned int segment_count[2]; /* # of allocated segments */
unsigned int block_count[2]; /* # of allocated blocks */ unsigned int block_count[2]; /* # of allocated blocks */
int total_hit_ext, read_hit_ext; /* extent cache hit ratio */ int total_hit_ext, read_hit_ext; /* extent cache hit ratio */
int inline_inode; /* # of inline_data inodes */ atomic_t inline_inode; /* # of inline_data inodes */
int inline_dir; /* # of inline_dentry inodes */ atomic_t inline_dir; /* # of inline_dentry inodes */
int bg_gc; /* background gc calls */ int bg_gc; /* background gc calls */
unsigned int n_dirty_dirs; /* # of dir inodes */ unsigned int n_dirty_dirs; /* # of dir inodes */
#endif #endif
@ -1532,22 +1532,22 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)
#define stat_inc_inline_inode(inode) \ #define stat_inc_inline_inode(inode) \
do { \ do { \
if (f2fs_has_inline_data(inode)) \ if (f2fs_has_inline_data(inode)) \
((F2FS_I_SB(inode))->inline_inode++); \ (atomic_inc(&F2FS_I_SB(inode)->inline_inode)); \
} while (0) } while (0)
#define stat_dec_inline_inode(inode) \ #define stat_dec_inline_inode(inode) \
do { \ do { \
if (f2fs_has_inline_data(inode)) \ if (f2fs_has_inline_data(inode)) \
((F2FS_I_SB(inode))->inline_inode--); \ (atomic_dec(&F2FS_I_SB(inode)->inline_inode)); \
} while (0) } while (0)
#define stat_inc_inline_dir(inode) \ #define stat_inc_inline_dir(inode) \
do { \ do { \
if (f2fs_has_inline_dentry(inode)) \ if (f2fs_has_inline_dentry(inode)) \
((F2FS_I_SB(inode))->inline_dir++); \ (atomic_inc(&F2FS_I_SB(inode)->inline_dir)); \
} while (0) } while (0)
#define stat_dec_inline_dir(inode) \ #define stat_dec_inline_dir(inode) \
do { \ do { \
if (f2fs_has_inline_dentry(inode)) \ if (f2fs_has_inline_dentry(inode)) \
((F2FS_I_SB(inode))->inline_dir--); \ (atomic_dec(&F2FS_I_SB(inode)->inline_dir)); \
} while (0) } while (0)
#define stat_inc_seg_type(sbi, curseg) \ #define stat_inc_seg_type(sbi, curseg) \
((sbi)->segment_count[(curseg)->alloc_type]++) ((sbi)->segment_count[(curseg)->alloc_type]++)