f2fs: introduce SEGS_TO_BLKS/BLKS_TO_SEGS for cleanup
[linux-2.6-microblaze.git] / fs / f2fs / gc.c
index c60b747..96ba358 100644 (file)
@@ -301,7 +301,7 @@ static unsigned int get_max_cost(struct f2fs_sb_info *sbi,
 
        /* LFS */
        if (p->gc_mode == GC_GREEDY)
-               return 2 * BLKS_PER_SEG(sbi) * p->ofs_unit;
+               return SEGS_TO_BLKS(sbi, 2 * p->ofs_unit);
        else if (p->gc_mode == GC_CB)
                return UINT_MAX;
        else if (p->gc_mode == GC_AT)
@@ -348,7 +348,7 @@ static unsigned int get_cb_cost(struct f2fs_sb_info *sbi, unsigned int segno)
        mtime = div_u64(mtime, usable_segs_per_sec);
        vblocks = div_u64(vblocks, usable_segs_per_sec);
 
-       u = (vblocks * 100) >> sbi->log_blocks_per_seg;
+       u = BLKS_TO_SEGS(sbi, vblocks * 100);
 
        /* Handle if the system time has changed by the user */
        if (mtime < sit_i->min_mtime)
@@ -2081,7 +2081,7 @@ static void update_sb_metadata(struct f2fs_sb_info *sbi, int secs)
        raw_sb->segment_count = cpu_to_le32(segment_count + segs);
        raw_sb->segment_count_main = cpu_to_le32(segment_count_main + segs);
        raw_sb->block_count = cpu_to_le64(block_count +
-                       (long long)(segs << sbi->log_blocks_per_seg));
+                       (long long)SEGS_TO_BLKS(sbi, segs));
        if (f2fs_is_multi_device(sbi)) {
                int last_dev = sbi->s_ndevs - 1;
                int dev_segs =
@@ -2097,7 +2097,7 @@ static void update_sb_metadata(struct f2fs_sb_info *sbi, int secs)
 static void update_fs_metadata(struct f2fs_sb_info *sbi, int secs)
 {
        int segs = secs * SEGS_PER_SEC(sbi);
-       long long blks = (long long)segs << sbi->log_blocks_per_seg;
+       long long blks = SEGS_TO_BLKS(sbi, segs);
        long long user_block_count =
                                le64_to_cpu(F2FS_CKPT(sbi)->user_block_count);
 
@@ -2139,7 +2139,7 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)
                int last_dev = sbi->s_ndevs - 1;
                __u64 last_segs = FDEV(last_dev).total_segments;
 
-               if (block_count + (last_segs << sbi->log_blocks_per_seg) <=
+               if (block_count + SEGS_TO_BLKS(sbi, last_segs) <=
                                                                old_block_count)
                        return -EINVAL;
        }