f2fs: use sbi->blocks_per_seg to avoid unnecessary calculation
authorChao Yu <chao2.yu@samsung.com>
Tue, 1 Dec 2015 03:56:52 +0000 (11:56 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 4 Dec 2015 20:07:57 +0000 (12:07 -0800)
Use sbi->blocks_per_seg directly to avoid unnecessary calculation when using
1 << sbi->log_blocks_per_seg.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/debug.c
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/gc.c
fs/f2fs/node.h

index b0966f3b1c9a8126938b65d5f4cfb97976d47b03..8ce2fe3f65ab54d0a1d0b37acac30fe0163aefc2 100644 (file)
@@ -105,7 +105,7 @@ static void update_sit_info(struct f2fs_sb_info *sbi)
 
        bimodal = 0;
        total_vblocks = 0;
-       blks_per_sec = sbi->segs_per_sec * (1 << sbi->log_blocks_per_seg);
+       blks_per_sec = sbi->segs_per_sec * sbi->blocks_per_seg;
        hblks_per_sec = blks_per_sec / 2;
        for (segno = 0; segno < MAIN_SEGS(sbi); segno += sbi->segs_per_sec) {
                vblocks = get_valid_blocks(sbi, segno, sbi->segs_per_sec);
index 0831db2f4b3ae8d0b634b0dfbe83ea0da840b622..0052ae8bea3f673f2b23a8df6402ce532352bddb 100644 (file)
@@ -1099,8 +1099,7 @@ static inline int get_dirty_pages(struct inode *inode)
 
 static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type)
 {
-       unsigned int pages_per_sec = sbi->segs_per_sec *
-                                       (1 << sbi->log_blocks_per_seg);
+       unsigned int pages_per_sec = sbi->segs_per_sec * sbi->blocks_per_seg;
        return ((get_pages(sbi, block_type) + pages_per_sec - 1)
                        >> sbi->log_blocks_per_seg) / sbi->segs_per_sec;
 }
index 3f1026caf80772e3dd0caf3f48e537f2a754ee8d..96e4e048a8a1aa6c31bdbff54a4e2e237f2f1d0b 100644 (file)
@@ -1654,10 +1654,9 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
        struct f2fs_map_blocks map;
        struct extent_info ei;
        pgoff_t pg_start, pg_end;
-       unsigned int blk_per_seg = 1 << sbi->log_blocks_per_seg;
+       unsigned int blk_per_seg = sbi->blocks_per_seg;
        unsigned int total = 0, sec_num;
-       unsigned int pages_per_sec = sbi->segs_per_sec *
-                                       (1 << sbi->log_blocks_per_seg);
+       unsigned int pages_per_sec = sbi->segs_per_sec * blk_per_seg;
        block_t blk_end = 0;
        bool fragmented = false;
        int err;
index fedbf67a0842780b53862dcb3855db246e12d347..ce350c44b5cf484a52a7b50d825a1f6f401f9e3d 100644 (file)
@@ -173,9 +173,9 @@ static unsigned int get_max_cost(struct f2fs_sb_info *sbi,
 {
        /* SSR allocates in a segment unit */
        if (p->alloc_mode == SSR)
-               return 1 << sbi->log_blocks_per_seg;
+               return sbi->blocks_per_seg;
        if (p->gc_mode == GC_GREEDY)
-               return (1 << sbi->log_blocks_per_seg) * p->ofs_unit;
+               return sbi->blocks_per_seg * p->ofs_unit;
        else if (p->gc_mode == GC_CB)
                return UINT_MAX;
        else /* No other gc_mode */
index e4fffd2d98c4b99f88a64e447395fe3f907d6dbc..2de759a7746f5261339e26f66bf5afef0d5d3d7a 100644 (file)
@@ -183,7 +183,7 @@ static inline pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start)
 
        block_addr = (pgoff_t)(nm_i->nat_blkaddr +
                (seg_off << sbi->log_blocks_per_seg << 1) +
-               (block_off & ((1 << sbi->log_blocks_per_seg) - 1)));
+               (block_off & (sbi->blocks_per_seg - 1)));
 
        if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
                block_addr += sbi->blocks_per_seg;