diff options
author | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2014-02-23 23:00:13 -0500 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2014-02-24 02:00:41 -0500 |
commit | 8b8343fa9d503894ece57acbe46cb36883646685 (patch) | |
tree | a8650f40e45644e91aad8298038aee3c024a80d8 /fs/f2fs | |
parent | 8a7ed66aaf8ee56b0a6beee4d02e10af5a9e38b2 (diff) |
f2fs: implement a lock-free stat_show
The stat_show is just to show the current status of f2fs.
So, we can remove all the there-in locks.
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/debug.c | 3 | ||||
-rw-r--r-- | fs/f2fs/f2fs.h | 18 | ||||
-rw-r--r-- | fs/f2fs/segment.h | 27 |
3 files changed, 6 insertions, 42 deletions
diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c index 46a12e46179a..b7111c44a918 100644 --- a/fs/f2fs/debug.c +++ b/fs/f2fs/debug.c | |||
@@ -86,7 +86,6 @@ static void update_sit_info(struct f2fs_sb_info *sbi) | |||
86 | { | 86 | { |
87 | struct f2fs_stat_info *si = F2FS_STAT(sbi); | 87 | struct f2fs_stat_info *si = F2FS_STAT(sbi); |
88 | unsigned int blks_per_sec, hblks_per_sec, total_vblocks, bimodal, dist; | 88 | unsigned int blks_per_sec, hblks_per_sec, total_vblocks, bimodal, dist; |
89 | struct sit_info *sit_i = SIT_I(sbi); | ||
90 | unsigned int segno, vblocks; | 89 | unsigned int segno, vblocks; |
91 | int ndirty = 0; | 90 | int ndirty = 0; |
92 | 91 | ||
@@ -94,7 +93,6 @@ static void update_sit_info(struct f2fs_sb_info *sbi) | |||
94 | total_vblocks = 0; | 93 | total_vblocks = 0; |
95 | blks_per_sec = sbi->segs_per_sec * (1 << sbi->log_blocks_per_seg); | 94 | blks_per_sec = sbi->segs_per_sec * (1 << sbi->log_blocks_per_seg); |
96 | hblks_per_sec = blks_per_sec / 2; | 95 | hblks_per_sec = blks_per_sec / 2; |
97 | mutex_lock(&sit_i->sentry_lock); | ||
98 | for (segno = 0; segno < TOTAL_SEGS(sbi); segno += sbi->segs_per_sec) { | 96 | for (segno = 0; segno < TOTAL_SEGS(sbi); segno += sbi->segs_per_sec) { |
99 | vblocks = get_valid_blocks(sbi, segno, sbi->segs_per_sec); | 97 | vblocks = get_valid_blocks(sbi, segno, sbi->segs_per_sec); |
100 | dist = abs(vblocks - hblks_per_sec); | 98 | dist = abs(vblocks - hblks_per_sec); |
@@ -105,7 +103,6 @@ static void update_sit_info(struct f2fs_sb_info *sbi) | |||
105 | ndirty++; | 103 | ndirty++; |
106 | } | 104 | } |
107 | } | 105 | } |
108 | mutex_unlock(&sit_i->sentry_lock); | ||
109 | dist = TOTAL_SECS(sbi) * hblks_per_sec * hblks_per_sec / 100; | 106 | dist = TOTAL_SECS(sbi) * hblks_per_sec * hblks_per_sec / 100; |
110 | si->bimodal = bimodal / dist; | 107 | si->bimodal = bimodal / dist; |
111 | if (si->dirty_count) | 108 | if (si->dirty_count) |
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 11fd8bec670b..4beedccc28a0 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -704,11 +704,7 @@ static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type) | |||
704 | 704 | ||
705 | static inline block_t valid_user_blocks(struct f2fs_sb_info *sbi) | 705 | static inline block_t valid_user_blocks(struct f2fs_sb_info *sbi) |
706 | { | 706 | { |
707 | block_t ret; | 707 | return sbi->total_valid_block_count; |
708 | spin_lock(&sbi->stat_lock); | ||
709 | ret = sbi->total_valid_block_count; | ||
710 | spin_unlock(&sbi->stat_lock); | ||
711 | return ret; | ||
712 | } | 708 | } |
713 | 709 | ||
714 | static inline unsigned long __bitmap_size(struct f2fs_sb_info *sbi, int flag) | 710 | static inline unsigned long __bitmap_size(struct f2fs_sb_info *sbi, int flag) |
@@ -804,11 +800,7 @@ static inline void dec_valid_node_count(struct f2fs_sb_info *sbi, | |||
804 | 800 | ||
805 | static inline unsigned int valid_node_count(struct f2fs_sb_info *sbi) | 801 | static inline unsigned int valid_node_count(struct f2fs_sb_info *sbi) |
806 | { | 802 | { |
807 | unsigned int ret; | 803 | return sbi->total_valid_node_count; |
808 | spin_lock(&sbi->stat_lock); | ||
809 | ret = sbi->total_valid_node_count; | ||
810 | spin_unlock(&sbi->stat_lock); | ||
811 | return ret; | ||
812 | } | 804 | } |
813 | 805 | ||
814 | static inline void inc_valid_inode_count(struct f2fs_sb_info *sbi) | 806 | static inline void inc_valid_inode_count(struct f2fs_sb_info *sbi) |
@@ -829,11 +821,7 @@ static inline void dec_valid_inode_count(struct f2fs_sb_info *sbi) | |||
829 | 821 | ||
830 | static inline unsigned int valid_inode_count(struct f2fs_sb_info *sbi) | 822 | static inline unsigned int valid_inode_count(struct f2fs_sb_info *sbi) |
831 | { | 823 | { |
832 | unsigned int ret; | 824 | return sbi->total_valid_inode_count; |
833 | spin_lock(&sbi->stat_lock); | ||
834 | ret = sbi->total_valid_inode_count; | ||
835 | spin_unlock(&sbi->stat_lock); | ||
836 | return ret; | ||
837 | } | 825 | } |
838 | 826 | ||
839 | static inline void f2fs_put_page(struct page *page, int unlock) | 827 | static inline void f2fs_put_page(struct page *page, int unlock) |
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index 4024546b6361..c3d5e3689ffc 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h | |||
@@ -380,26 +380,12 @@ static inline void get_sit_bitmap(struct f2fs_sb_info *sbi, | |||
380 | 380 | ||
381 | static inline block_t written_block_count(struct f2fs_sb_info *sbi) | 381 | static inline block_t written_block_count(struct f2fs_sb_info *sbi) |
382 | { | 382 | { |
383 | struct sit_info *sit_i = SIT_I(sbi); | 383 | return SIT_I(sbi)->written_valid_blocks; |
384 | block_t vblocks; | ||
385 | |||
386 | mutex_lock(&sit_i->sentry_lock); | ||
387 | vblocks = sit_i->written_valid_blocks; | ||
388 | mutex_unlock(&sit_i->sentry_lock); | ||
389 | |||
390 | return vblocks; | ||
391 | } | 384 | } |
392 | 385 | ||
393 | static inline unsigned int free_segments(struct f2fs_sb_info *sbi) | 386 | static inline unsigned int free_segments(struct f2fs_sb_info *sbi) |
394 | { | 387 | { |
395 | struct free_segmap_info *free_i = FREE_I(sbi); | 388 | return FREE_I(sbi)->free_segments; |
396 | unsigned int free_segs; | ||
397 | |||
398 | read_lock(&free_i->segmap_lock); | ||
399 | free_segs = free_i->free_segments; | ||
400 | read_unlock(&free_i->segmap_lock); | ||
401 | |||
402 | return free_segs; | ||
403 | } | 389 | } |
404 | 390 | ||
405 | static inline int reserved_segments(struct f2fs_sb_info *sbi) | 391 | static inline int reserved_segments(struct f2fs_sb_info *sbi) |
@@ -409,14 +395,7 @@ static inline int reserved_segments(struct f2fs_sb_info *sbi) | |||
409 | 395 | ||
410 | static inline unsigned int free_sections(struct f2fs_sb_info *sbi) | 396 | static inline unsigned int free_sections(struct f2fs_sb_info *sbi) |
411 | { | 397 | { |
412 | struct free_segmap_info *free_i = FREE_I(sbi); | 398 | return FREE_I(sbi)->free_sections; |
413 | unsigned int free_secs; | ||
414 | |||
415 | read_lock(&free_i->segmap_lock); | ||
416 | free_secs = free_i->free_sections; | ||
417 | read_unlock(&free_i->segmap_lock); | ||
418 | |||
419 | return free_secs; | ||
420 | } | 399 | } |
421 | 400 | ||
422 | static inline unsigned int prefree_segments(struct f2fs_sb_info *sbi) | 401 | static inline unsigned int prefree_segments(struct f2fs_sb_info *sbi) |