Skip to content

Commit e05e25e

Browse files
Jaegeuk KimHashcode
authored andcommitted
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>
1 parent 13c2bea commit e05e25e

3 files changed

Lines changed: 6 additions & 42 deletions

File tree

fs/f2fs/debug.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,13 @@ static void update_sit_info(struct f2fs_sb_info *sbi)
8686
{
8787
struct f2fs_stat_info *si = F2FS_STAT(sbi);
8888
unsigned int blks_per_sec, hblks_per_sec, total_vblocks, bimodal, dist;
89-
struct sit_info *sit_i = SIT_I(sbi);
9089
unsigned int segno, vblocks;
9190
int ndirty = 0;
9291

9392
bimodal = 0;
9493
total_vblocks = 0;
9594
blks_per_sec = sbi->segs_per_sec * (1 << sbi->log_blocks_per_seg);
9695
hblks_per_sec = blks_per_sec / 2;
97-
mutex_lock(&sit_i->sentry_lock);
9896
for (segno = 0; segno < TOTAL_SEGS(sbi); segno += sbi->segs_per_sec) {
9997
vblocks = get_valid_blocks(sbi, segno, sbi->segs_per_sec);
10098
dist = abs(vblocks - hblks_per_sec);
@@ -105,7 +103,6 @@ static void update_sit_info(struct f2fs_sb_info *sbi)
105103
ndirty++;
106104
}
107105
}
108-
mutex_unlock(&sit_i->sentry_lock);
109106
dist = TOTAL_SECS(sbi) * hblks_per_sec * hblks_per_sec / 100;
110107
si->bimodal = bimodal / dist;
111108
if (si->dirty_count)

fs/f2fs/f2fs.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,7 @@ static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type)
704704

705705
static inline block_t valid_user_blocks(struct f2fs_sb_info *sbi)
706706
{
707-
block_t ret;
708-
spin_lock(&sbi->stat_lock);
709-
ret = sbi->total_valid_block_count;
710-
spin_unlock(&sbi->stat_lock);
711-
return ret;
707+
return sbi->total_valid_block_count;
712708
}
713709

714710
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,
804800

805801
static inline unsigned int valid_node_count(struct f2fs_sb_info *sbi)
806802
{
807-
unsigned int ret;
808-
spin_lock(&sbi->stat_lock);
809-
ret = sbi->total_valid_node_count;
810-
spin_unlock(&sbi->stat_lock);
811-
return ret;
803+
return sbi->total_valid_node_count;
812804
}
813805

814806
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)
829821

830822
static inline unsigned int valid_inode_count(struct f2fs_sb_info *sbi)
831823
{
832-
unsigned int ret;
833-
spin_lock(&sbi->stat_lock);
834-
ret = sbi->total_valid_inode_count;
835-
spin_unlock(&sbi->stat_lock);
836-
return ret;
824+
return sbi->total_valid_inode_count;
837825
}
838826

839827
static inline void f2fs_put_page(struct page *page, int unlock)

fs/f2fs/segment.h

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -380,26 +380,12 @@ static inline void get_sit_bitmap(struct f2fs_sb_info *sbi,
380380

381381
static inline block_t written_block_count(struct f2fs_sb_info *sbi)
382382
{
383-
struct sit_info *sit_i = SIT_I(sbi);
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;
383+
return SIT_I(sbi)->written_valid_blocks;
391384
}
392385

393386
static inline unsigned int free_segments(struct f2fs_sb_info *sbi)
394387
{
395-
struct free_segmap_info *free_i = FREE_I(sbi);
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;
388+
return FREE_I(sbi)->free_segments;
403389
}
404390

405391
static inline int reserved_segments(struct f2fs_sb_info *sbi)
@@ -409,14 +395,7 @@ static inline int reserved_segments(struct f2fs_sb_info *sbi)
409395

410396
static inline unsigned int free_sections(struct f2fs_sb_info *sbi)
411397
{
412-
struct free_segmap_info *free_i = FREE_I(sbi);
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;
398+
return FREE_I(sbi)->free_sections;
420399
}
421400

422401
static inline unsigned int prefree_segments(struct f2fs_sb_info *sbi)

0 commit comments

Comments
 (0)