[PATCH] resizefs: fix if ext4 already >16TB resize will fail issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When make >16TB ext4, mkfs.ext4 will add EXT4_FEATURE_INCOMPAT_64BIT feature.
But when resize, it didn't enable EXT2_FLAG_64BITS flag.
This will cause some size calculated wrong.
So this patch enable EXT2_FLAG_64BITS flag base on
EXT4_FEATURE_INCOMPAT_64BIT feature, and fix some size overflow code.
This patch let >16TB ext4 can offline resize successfully.

Thanks.

diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index a0269c7..0b34b3e 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -181,6 +181,9 @@ errcode_t ext2fs_open2(const char *name, const
char *io_options,
    }
    retval = io_channel_read_blk(fs->io, superblock, -SUPERBLOCK_SIZE,
                     fs->super);
+   if (EXT4_FEATURE_INCOMPAT_64BIT & fs->super->s_feature_incompat) {
+       fs->flags |= EXT2_FLAG_64BITS;
+   }
    if (retval)
        goto cleanup;
    if (fs->orig_super)
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index 064c4c4..b451c1d 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -198,8 +198,8 @@ static void fix_uninit_block_bitmaps(ext2_filsys fs)
        if (!(ext2fs_bg_flags_test(fs, g, EXT2_BG_BLOCK_UNINIT)))
            continue;

-       blk = (g * fs->super->s_blocks_per_group) +
-           fs->super->s_first_data_block;
+       blk = ((blk64_t)g * (blk64_t)fs->super->s_blocks_per_group) +
+           (blk64_t)fs->super->s_first_data_block;

        ext2fs_super_and_bgd_loc2(fs, g, &super_blk,
                      &old_desc_blk, &new_desc_blk, 0);
@@ -294,7 +294,7 @@ errcode_t adjust_fs_info(ext2_filsys fs, ext2_filsys old_fs,
    blk64_t     overhead = 0;
    blk64_t     rem;
    blk64_t     blk, group_block;
-   ext2_ino_t  real_end;
+   __u64       real_end;
    blk64_t     adj, old_numblocks, numblocks, adjblocks;
    unsigned long   i, j, old_desc_blocks, max_group;
    unsigned int    meta_bg, meta_bg_size;
@@ -381,9 +381,9 @@ retry:
                        fs->inode_map);
    if (retval) goto errout;

-   real_end = ((EXT2_BLOCKS_PER_GROUP(fs->super)
-            * fs->group_desc_count)) - 1 +
-                fs->super->s_first_data_block;
+   real_end = ((__u64)(EXT2_BLOCKS_PER_GROUP(fs->super)
+            * (__u64)fs->group_desc_count)) - 1ULL +
+                (__u64)fs->super->s_first_data_block;
    retval = ext2fs_resize_block_bitmap2(ext2fs_blocks_count(fs->super)-1,
                        real_end, fs->block_map);
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux