diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-12-17 15:37:24 -0800 |
---|---|---|
committer | Greg Wallace <greg@gregtwallace.com> | 2016-01-19 22:02:21 -0500 |
commit | f00f43e3bf835aa56c51ed4b111a4750c9b912c9 (patch) | |
tree | ec85d917e4097d4a2d30724f4f15ca9c92df3b18 | |
parent | 030ee52400a0efda7994727cabdd4ece91fcae95 (diff) | |
download | android_external_f2fs-tools-f00f43e3bf835aa56c51ed4b111a4750c9b912c9.tar.gz android_external_f2fs-tools-f00f43e3bf835aa56c51ed4b111a4750c9b912c9.tar.bz2 android_external_f2fs-tools-f00f43e3bf835aa56c51ed4b111a4750c9b912c9.zip |
defrag.f2fs: enhance allocation speed
This patch improves the allocation speed.
Change-Id: I524e5f12e1c2937997374316462a84a159b2e1d8
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fsck/f2fs.h | 2 | ||||
-rw-r--r-- | fsck/mount.c | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/fsck/f2fs.h b/fsck/f2fs.h index ad9b13b..651b62d 100644 --- a/fsck/f2fs.h +++ b/fsck/f2fs.h @@ -297,7 +297,7 @@ static inline block_t __end_block_addr(struct f2fs_sb_info *sbi) #define GET_R2L_SEGNO(sbi, segno) (segno + FREE_I_START_SEGNO(sbi)) #define START_BLOCK(sbi, segno) (SM_I(sbi)->main_blkaddr + \ - (segno << sbi->log_blocks_per_seg)) + ((segno) << sbi->log_blocks_per_seg)) static inline struct curseg_info *CURSEG_I(struct f2fs_sb_info *sbi, int type) { diff --git a/fsck/mount.c b/fsck/mount.c index 4b38df8..79611e5 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -1401,9 +1401,11 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type) se = get_seg_entry(sbi, segno); if (se->valid_blocks == sbi->blocks_per_seg || - IS_CUR_SEGNO(sbi, segno, type)) - goto next; - + IS_CUR_SEGNO(sbi, segno, type)) { + *to = left ? START_BLOCK(sbi, segno) - 1: + START_BLOCK(sbi, segno + 1); + continue; + } if (se->valid_blocks == 0 && !(segno % sbi->segs_per_sec)) { struct seg_entry *se2; int i; @@ -1420,7 +1422,7 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type) if (se->type == type && !f2fs_test_bit(offset, (const char *)se->cur_valid_map)) return 0; -next: + *to = left ? *to - 1: *to + 1; } return -1; |