diff options
author | Chao Yu <chao2.yu@samsung.com> | 2014-12-08 06:08:20 -0500 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2014-12-08 13:54:59 -0500 |
commit | 03e14d522eb1fdf9c0ce37085cb56749342a842c (patch) | |
tree | 38c93ae568af7ce3ec44812db861faa0d4393158 /fs/f2fs | |
parent | 51455b19384d26afac4f214fab2ad0a4f1964e30 (diff) |
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>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/debug.c | 7 | ||||
-rw-r--r-- | fs/f2fs/f2fs.h | 12 |
2 files changed, 11 insertions, 8 deletions
diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c index 4e2e39c0ba69..91e8f699ab30 100644 --- a/fs/f2fs/debug.c +++ b/fs/f2fs/debug.c | |||
@@ -46,8 +46,8 @@ static void update_general_status(struct f2fs_sb_info *sbi) | |||
46 | si->valid_count = valid_user_blocks(sbi); | 46 | si->valid_count = valid_user_blocks(sbi); |
47 | si->valid_node_count = valid_node_count(sbi); | 47 | si->valid_node_count = valid_node_count(sbi); |
48 | si->valid_inode_count = valid_inode_count(sbi); | 48 | si->valid_inode_count = valid_inode_count(sbi); |
49 | si->inline_inode = sbi->inline_inode; | 49 | si->inline_inode = atomic_read(&sbi->inline_inode); |
50 | si->inline_dir = sbi->inline_dir; | 50 | si->inline_dir = atomic_read(&sbi->inline_dir); |
51 | si->utilization = utilization(sbi); | 51 | si->utilization = utilization(sbi); |
52 | 52 | ||
53 | si->free_segs = free_segments(sbi); | 53 | si->free_segs = free_segments(sbi); |
@@ -329,6 +329,9 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi) | |||
329 | si->sbi = sbi; | 329 | si->sbi = sbi; |
330 | sbi->stat_info = si; | 330 | sbi->stat_info = si; |
331 | 331 | ||
332 | atomic_set(&sbi->inline_inode, 0); | ||
333 | atomic_set(&sbi->inline_dir, 0); | ||
334 | |||
332 | mutex_lock(&f2fs_stat_mutex); | 335 | mutex_lock(&f2fs_stat_mutex); |
333 | list_add_tail(&si->stat_list, &f2fs_stat_list); | 336 | list_add_tail(&si->stat_list, &f2fs_stat_list); |
334 | mutex_unlock(&f2fs_stat_mutex); | 337 | mutex_unlock(&f2fs_stat_mutex); |
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index f60b817a7f0d..2695d78d57dd 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -590,8 +590,8 @@ struct f2fs_sb_info { | |||
590 | unsigned int segment_count[2]; /* # of allocated segments */ | 590 | unsigned int segment_count[2]; /* # of allocated segments */ |
591 | unsigned int block_count[2]; /* # of allocated blocks */ | 591 | unsigned int block_count[2]; /* # of allocated blocks */ |
592 | int total_hit_ext, read_hit_ext; /* extent cache hit ratio */ | 592 | int total_hit_ext, read_hit_ext; /* extent cache hit ratio */ |
593 | int inline_inode; /* # of inline_data inodes */ | 593 | atomic_t inline_inode; /* # of inline_data inodes */ |
594 | int inline_dir; /* # of inline_dentry inodes */ | 594 | atomic_t inline_dir; /* # of inline_dentry inodes */ |
595 | int bg_gc; /* background gc calls */ | 595 | int bg_gc; /* background gc calls */ |
596 | unsigned int n_dirty_dirs; /* # of dir inodes */ | 596 | unsigned int n_dirty_dirs; /* # of dir inodes */ |
597 | #endif | 597 | #endif |
@@ -1532,22 +1532,22 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi) | |||
1532 | #define stat_inc_inline_inode(inode) \ | 1532 | #define stat_inc_inline_inode(inode) \ |
1533 | do { \ | 1533 | do { \ |
1534 | if (f2fs_has_inline_data(inode)) \ | 1534 | if (f2fs_has_inline_data(inode)) \ |
1535 | ((F2FS_I_SB(inode))->inline_inode++); \ | 1535 | (atomic_inc(&F2FS_I_SB(inode)->inline_inode)); \ |
1536 | } while (0) | 1536 | } while (0) |
1537 | #define stat_dec_inline_inode(inode) \ | 1537 | #define stat_dec_inline_inode(inode) \ |
1538 | do { \ | 1538 | do { \ |
1539 | if (f2fs_has_inline_data(inode)) \ | 1539 | if (f2fs_has_inline_data(inode)) \ |
1540 | ((F2FS_I_SB(inode))->inline_inode--); \ | 1540 | (atomic_dec(&F2FS_I_SB(inode)->inline_inode)); \ |
1541 | } while (0) | 1541 | } while (0) |
1542 | #define stat_inc_inline_dir(inode) \ | 1542 | #define stat_inc_inline_dir(inode) \ |
1543 | do { \ | 1543 | do { \ |
1544 | if (f2fs_has_inline_dentry(inode)) \ | 1544 | if (f2fs_has_inline_dentry(inode)) \ |
1545 | ((F2FS_I_SB(inode))->inline_dir++); \ | 1545 | (atomic_inc(&F2FS_I_SB(inode)->inline_dir)); \ |
1546 | } while (0) | 1546 | } while (0) |
1547 | #define stat_dec_inline_dir(inode) \ | 1547 | #define stat_dec_inline_dir(inode) \ |
1548 | do { \ | 1548 | do { \ |
1549 | if (f2fs_has_inline_dentry(inode)) \ | 1549 | if (f2fs_has_inline_dentry(inode)) \ |
1550 | ((F2FS_I_SB(inode))->inline_dir--); \ | 1550 | (atomic_dec(&F2FS_I_SB(inode)->inline_dir)); \ |
1551 | } while (0) | 1551 | } while (0) |
1552 | #define stat_inc_seg_type(sbi, curseg) \ | 1552 | #define stat_inc_seg_type(sbi, curseg) \ |
1553 | ((sbi)->segment_count[(curseg)->alloc_type]++) | 1553 | ((sbi)->segment_count[(curseg)->alloc_type]++) |