f2fs: clean up with F2FS_BLK_ALIGN
authorChao Yu <yuchao0@huawei.com>
Tue, 20 Mar 2018 15:08:29 +0000 (23:08 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sun, 8 Apr 2018 11:14:35 +0000 (04:14 -0700)
Clean up F2FS_BYTES_TO_BLK(x + F2FS_BLKSIZE - 1) with F2FS_BLK_ALIGN(x).

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c
fs/f2fs/node.c

index 13fee9252e1b6aa18d5f938d9624ee6c82be0654..e41ea6649dcb9b7aa1ff5fde14ac34335f4cf35a 100644 (file)
@@ -572,7 +572,6 @@ truncate_out:
 int truncate_blocks(struct inode *inode, u64 from, bool lock)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
-       unsigned int blocksize = inode->i_sb->s_blocksize;
        struct dnode_of_data dn;
        pgoff_t free_from;
        int count = 0, err = 0;
@@ -581,7 +580,7 @@ int truncate_blocks(struct inode *inode, u64 from, bool lock)
 
        trace_f2fs_truncate_blocks_enter(inode, from);
 
-       free_from = (pgoff_t)F2FS_BYTES_TO_BLK(from + blocksize - 1);
+       free_from = (pgoff_t)F2FS_BLK_ALIGN(from);
 
        if (free_from >= sbi->max_file_blocks)
                goto free_partial;
index 91e31f7f7a4b471fc2cc0478c3d59257eb5770b3..9bdefe4a5cd9e799a120e8ff8297cc4933b7c3ff 100644 (file)
@@ -2600,8 +2600,7 @@ static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)
        if (!enabled_nat_bits(sbi, NULL))
                return 0;
 
-       nm_i->nat_bits_blocks = F2FS_BYTES_TO_BLK((nat_bits_bytes << 1) + 8 +
-                                               F2FS_BLKSIZE - 1);
+       nm_i->nat_bits_blocks = F2FS_BLK_ALIGN((nat_bits_bytes << 1) + 8);
        nm_i->nat_bits = f2fs_kzalloc(sbi,
                        nm_i->nat_bits_blocks << F2FS_BLKSIZE_BITS, GFP_KERNEL);
        if (!nm_i->nat_bits)