Whamcloud - gitweb
mke2fs: Use ext2fs_div_ceil to simplify write_inode_tables()
authorTheodore Ts'o <tytso@mit.edu>
Mon, 20 Dec 2010 15:42:57 +0000 (10:42 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 20 Dec 2010 15:42:57 +0000 (10:42 -0500)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/mke2fs.c

index 9c632ff..9010f53 100644 (file)
@@ -305,7 +305,7 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag, int itable_zeroed)
        errcode_t       retval;
        blk64_t         blk;
        dgrp_t          i;
-       int             num, ipb;
+       int             num;
        struct ext2fs_numeric_progress_struct progress;
 
        ext2fs_numeric_progress_init(fs, &progress,
@@ -318,14 +318,11 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag, int itable_zeroed)
                blk = ext2fs_inode_table_loc(fs, i);
                num = fs->inode_blocks_per_group;
 
-               if (lazy_flag) {
-                       ipb = fs->blocksize / EXT2_INODE_SIZE(fs->super);
-                       num = ((((fs->super->s_inodes_per_group -
-                                 ext2fs_bg_itable_unused(fs, i)) *
-                                EXT2_INODE_SIZE(fs->super)) +
-                               EXT2_BLOCK_SIZE(fs->super) - 1) /
-                              EXT2_BLOCK_SIZE(fs->super));
-               }
+               if (lazy_flag)
+                       num = ext2fs_div_ceil((fs->super->s_inodes_per_group -
+                                              ext2fs_bg_itable_unused(fs, i)) *
+                                             EXT2_INODE_SIZE(fs->super),
+                                             EXT2_BLOCK_SIZE(fs->super));
                if (!lazy_flag || itable_zeroed) {
                        /* The kernel doesn't need to zero the itable blocks */
                        ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_ZEROED);