diff options
author | Namjae Jeon <namjae.jeon@samsung.com> | 2013-02-02 09:52:59 -0500 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-02-11 17:15:02 -0500 |
commit | 5ac206cf4f9aad871aa1f1dd653a3404092db56c (patch) | |
tree | f9d487406816b58c5e3b1b52a376d459245be803 /fs/f2fs | |
parent | 25718423ea6f7118f9c173adff0fac52414571b8 (diff) |
f2fs: make an accessor to get sections for particular block type
Introduce accessor to get the sections based upon the block type
(node,dents...) and modify the functions : should_do_checkpoint,
has_not_enough_free_secs to use this accessor function to get
the node sections and dent sections.
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/f2fs.h | 8 | ||||
-rw-r--r-- | fs/f2fs/gc.h | 8 | ||||
-rw-r--r-- | fs/f2fs/segment.h | 9 |
3 files changed, 12 insertions, 13 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 5022a7d7f7ca..87840bccaf21 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -573,6 +573,14 @@ static inline int get_pages(struct f2fs_sb_info *sbi, int count_type) | |||
573 | return atomic_read(&sbi->nr_pages[count_type]); | 573 | return atomic_read(&sbi->nr_pages[count_type]); |
574 | } | 574 | } |
575 | 575 | ||
576 | static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type) | ||
577 | { | ||
578 | unsigned int pages_per_sec = sbi->segs_per_sec * | ||
579 | (1 << sbi->log_blocks_per_seg); | ||
580 | return ((get_pages(sbi, block_type) + pages_per_sec - 1) | ||
581 | >> sbi->log_blocks_per_seg) / sbi->segs_per_sec; | ||
582 | } | ||
583 | |||
576 | static inline block_t valid_user_blocks(struct f2fs_sb_info *sbi) | 584 | static inline block_t valid_user_blocks(struct f2fs_sb_info *sbi) |
577 | { | 585 | { |
578 | block_t ret; | 586 | block_t ret; |
diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h index 3abdf83b5c16..c407a75a7daa 100644 --- a/fs/f2fs/gc.h +++ b/fs/f2fs/gc.h | |||
@@ -106,11 +106,7 @@ static inline int is_idle(struct f2fs_sb_info *sbi) | |||
106 | 106 | ||
107 | static inline bool should_do_checkpoint(struct f2fs_sb_info *sbi) | 107 | static inline bool should_do_checkpoint(struct f2fs_sb_info *sbi) |
108 | { | 108 | { |
109 | unsigned int pages_per_sec = sbi->segs_per_sec * | 109 | int node_secs = get_blocktype_secs(sbi, F2FS_DIRTY_NODES); |
110 | (1 << sbi->log_blocks_per_seg); | 110 | int dent_secs = get_blocktype_secs(sbi, F2FS_DIRTY_DENTS); |
111 | int node_secs = ((get_pages(sbi, F2FS_DIRTY_NODES) + pages_per_sec - 1) | ||
112 | >> sbi->log_blocks_per_seg) / sbi->segs_per_sec; | ||
113 | int dent_secs = ((get_pages(sbi, F2FS_DIRTY_DENTS) + pages_per_sec - 1) | ||
114 | >> sbi->log_blocks_per_seg) / sbi->segs_per_sec; | ||
115 | return free_sections(sbi) <= (node_secs + 2 * dent_secs + 2); | 111 | return free_sections(sbi) <= (node_secs + 2 * dent_secs + 2); |
116 | } | 112 | } |
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index 66a288a52fd3..a9417b94d6bc 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h | |||
@@ -459,13 +459,8 @@ static inline int get_ssr_segment(struct f2fs_sb_info *sbi, int type) | |||
459 | 459 | ||
460 | static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi) | 460 | static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi) |
461 | { | 461 | { |
462 | unsigned int pages_per_sec = (1 << sbi->log_blocks_per_seg) * | 462 | int node_secs = get_blocktype_secs(sbi, F2FS_DIRTY_NODES); |
463 | sbi->segs_per_sec; | 463 | int dent_secs = get_blocktype_secs(sbi, F2FS_DIRTY_DENTS); |
464 | int node_secs = ((get_pages(sbi, F2FS_DIRTY_NODES) + pages_per_sec - 1) | ||
465 | >> sbi->log_blocks_per_seg) / sbi->segs_per_sec; | ||
466 | int dent_secs = ((get_pages(sbi, F2FS_DIRTY_DENTS) + pages_per_sec - 1) | ||
467 | >> sbi->log_blocks_per_seg) / sbi->segs_per_sec; | ||
468 | |||
469 | if (sbi->por_doing) | 464 | if (sbi->por_doing) |
470 | return false; | 465 | return false; |
471 | 466 | ||