diff mbox

Online resize issue with 3.13.5 & 3.15.6

Message ID 20140725081312.GO6397@azat
State Superseded, archived
Headers show

Commit Message

Azat Khuzhin July 25, 2014, 8:13 a.m. UTC
On Mon, Jul 21, 2014 at 09:03:22AM +0800, Brad Campbell wrote:
> On 20/07/14 19:26, Brad Campbell wrote:
> >G'day all,
> >
> >Machine was running 3.13.5. x86_64.
> >
> >I had a 12 device (2TB) RAID-6 formatted ext4. I added 2 drives to its
> >underlying md and restriped it (no issues). After the restripe I
> >attempted an online resize using ext2progs 1.42.5 (Debian stable). This
> >failed with a message about the size not fitting into 32 bits so I
> >compiled 1.42.11 and tried again.
> 
> 
> More info:
> I discovered the debug flags, so this is resize2fs -f 255 /dev/md0
> 
> last_start just keeps incrementing for as long as I care to leave it run.
> 
> fs has 4007207 inodes, 1957 groups required.
> fs requires 4374122900 data blocks.
> With 1957 group(s), we have 63820826 blocks available.
> Added 131540 extra group(s), blks_needed 4374122900, data_blocks 62023030,
> last_start 4356599580
> Added 131595 extra group(s), blks_needed 4374122900, data_blocks 73483100,
> last_start 5781212288
> Added 131246 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781244926
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781277564
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781310202
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781342840
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781375478
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781408116
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781440754
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781473392
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781506030
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781538668
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781571306
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781603944
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781636582
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781669220
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781701858
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781734496
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781767134
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781799772
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781832410
> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
> last_start 5781865048

blocks_per_group=32768 (u32)
extra_groups=131072 (u32)
b*e=4294967296 # overflow

Could you try attached patched? (I will add appropriate message letter)
It is totally untested and shouldn't break anything, *but* I strongly
recommend you to have a backup before running it.
You could also wait until somebody else review it.

Comments

Brad Campbell July 25, 2014, 11:44 a.m. UTC | #1
On 25/07/14 16:13, Azat Khuzhin wrote:
> On Mon, Jul 21, 2014 at 09:03:22AM +0800, Brad Campbell wrote:
>> On 20/07/14 19:26, Brad Campbell wrote:
>> Added 131072 extra group(s), blks_needed 4374122900, data_blocks 79184732,
>> last_start 5781865048
>
> blocks_per_group=32768 (u32)
> extra_groups=131072 (u32)
> b*e=4294967296 # overflow
>
> Could you try attached patched? (I will add appropriate message letter)
> It is totally untested and shouldn't break anything, *but* I strongly
> recommend you to have a backup before running it.
> You could also wait until somebody else review it.
>
> diff --git a/resize/resize2fs.c b/resize/resize2fs.c
> index a8af969..98ce10a 100644
> --- a/resize/resize2fs.c
> +++ b/resize/resize2fs.c
> @@ -2479,7 +2479,8 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
>                  extra_grps = ext2fs_div64_ceil(remainder,
>                                                 EXT2_BLOCKS_PER_GROUP(fs->super));
>
> -               data_blocks += extra_grps * EXT2_BLOCKS_PER_GROUP(fs->super);
> +               data_blocks += (unsigned long long)extra_grps *
> +                       EXT2_BLOCKS_PER_GROUP(fs->super);
>
>                  /* ok we have to account for the last group */
>                  overhead = calc_group_overhead(fs, groups-1, old_desc_blocks);
>
>

G'day Azat,

Appreciate you taking a look at this and I see where you are going with it.

While I have a backup of _all_ critical data on that array, I don't have 
20TB of spare space to back up the remainder so if you don't mind I'd 
like to wait for a review prior to letting it loose on the array.

Regards,
Brad
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o July 25, 2014, 2:07 p.m. UTC | #2
On Fri, Jul 25, 2014 at 07:44:07PM +0800, Brad Campbell wrote:
> 
> Appreciate you taking a look at this and I see where you are going with it.

This patch looks good to me.  If you could give it a try, I would
appreciate it.

This looks like the same bug which was reported in Ubuntu:

https://bugs.launchpad.net/ubuntu/+source/e2fsprogs/+bug/1321958

							- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Brad Campbell July 26, 2014, 3:31 a.m. UTC | #3
On 25/07/14 22:07, Theodore Ts'o wrote:
> On Fri, Jul 25, 2014 at 07:44:07PM +0800, Brad Campbell wrote:
>>
>> Appreciate you taking a look at this and I see where you are going with it.
>
> This patch looks good to me.  If you could give it a try, I would
> appreciate it.
>
> This looks like the same bug which was reported in Ubuntu:
>
> https://bugs.launchpad.net/ubuntu/+source/e2fsprogs/+bug/1321958


The patch would not apply automatically to 1.42.11 but was easy enough 
to apply by hand.

root@srv:~/src/e2fsprogs/e2fsprogs-1.42.11/resize# ./resize2fs -d 255 
/dev/md0
resize2fs 1.42.11 (09-Jul-2014)
fs has 4007207 inodes, 1957 groups required.
fs requires 4374122900 data blocks.
With 1957 group(s), we have 63820826 blocks available.
Added 131540 extra group(s), blks_needed 4374122900, data_blocks 
4356990326, last_start 4356599580
Added 523 extra group(s), blks_needed 4374122900, data_blocks 
4374059350, last_start 4373440788
Added 2 extra group(s), blks_needed 4374122900, data_blocks 4374124886, 
last_start 4373473426
Last group's overhead is 1430
Need 649474 data blocks in last group
Final size of last group is 650904
Estimated blocks needed: 4391437088
Extents safety margin: 2826959
Filesystem at /dev/md0 is mounted on /server; on-line resizing required
old_desc_blocks = 2768, new_desc_blocks = 2795
./resize2fs: Invalid argument While checking for on-line resizing support

[489412.650430] EXT4-fs (md0): resizing filesystem from 5804916736 to 
5860149888 blocks
[489412.700282] EXT4-fs warning (device md0): verify_reserved_gdb:713: 
reserved GDT 2769 missing grp 177147 (5804755665)
[489412.739676] EXT4-fs (md0): resized filesystem to 5860149888
[489413.215230] EXT4-fs warning (device md0): ext4_group_extend:1720: 
can't shrink FS - resize aborted


--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Brad Campbell July 26, 2014, 4:12 a.m. UTC | #4
On 26/07/14 11:31, Brad Campbell wrote:
> On 25/07/14 22:07, Theodore Ts'o wrote:
>> On Fri, Jul 25, 2014 at 07:44:07PM +0800, Brad Campbell wrote:
>>>
>>> Appreciate you taking a look at this and I see where you are going
>>> with it.
>>
>> This patch looks good to me.  If you could give it a try, I would
>> appreciate it.
>>
>> This looks like the same bug which was reported in Ubuntu:
>>
>> https://bugs.launchpad.net/ubuntu/+source/e2fsprogs/+bug/1321958
>
>
> The patch would not apply automatically to 1.42.11 but was easy enough
> to apply by hand.
>
> root@srv:~/src/e2fsprogs/e2fsprogs-1.42.11/resize# ./resize2fs -d 255
> /dev/md0
> resize2fs 1.42.11 (09-Jul-2014)
> fs has 4007207 inodes, 1957 groups required.
> fs requires 4374122900 data blocks.
> With 1957 group(s), we have 63820826 blocks available.
> Added 131540 extra group(s), blks_needed 4374122900, data_blocks
> 4356990326, last_start 4356599580
> Added 523 extra group(s), blks_needed 4374122900, data_blocks
> 4374059350, last_start 4373440788
> Added 2 extra group(s), blks_needed 4374122900, data_blocks 4374124886,
> last_start 4373473426
> Last group's overhead is 1430
> Need 649474 data blocks in last group
> Final size of last group is 650904
> Estimated blocks needed: 4391437088
> Extents safety margin: 2826959
> Filesystem at /dev/md0 is mounted on /server; on-line resizing required
> old_desc_blocks = 2768, new_desc_blocks = 2795
> ./resize2fs: Invalid argument While checking for on-line resizing support
>
> [489412.650430] EXT4-fs (md0): resizing filesystem from 5804916736 to
> 5860149888 blocks
> [489412.700282] EXT4-fs warning (device md0): verify_reserved_gdb:713:
> reserved GDT 2769 missing grp 177147 (5804755665)
> [489412.739676] EXT4-fs (md0): resized filesystem to 5860149888
> [489413.215230] EXT4-fs warning (device md0): ext4_group_extend:1720:
> can't shrink FS - resize aborted

Rebooted, did an fsck -f (was clean) and ran it again without the fs 
mounted.

root@srv:~/src/e2fsprogs/e2fsprogs-1.42.11/resize# ./resize2fs -d 255 
/dev/md0
resize2fs 1.42.11 (09-Jul-2014)
fs has 4007359 inodes, 1957 groups required.
fs requires 4655464570 data blocks.
With 1957 group(s), we have 63820826 blocks available.
Added 140126 extra group(s), blks_needed 4655464570, data_blocks 
4637219414, last_start 4636829448
Added 557 extra group(s), blks_needed 4655464570, data_blocks 
4655398390, last_start 4654584520
Added 3 extra group(s), blks_needed 4655464570, data_blocks 4655496694, 
last_start 4654617158
Last group's overhead is 1820
Need 847412 data blocks in last group
Final size of last group is 849232
Estimated blocks needed: 4674027936
Extents safety margin: 2261777
Resizing the filesystem on /dev/md0 to 5860149888 (4k) blocks.
read_bitmaps: Memory used: 132k/763980k (49k/84k), time: 113.93/ 1.26/ 4.45
read_bitmaps: I/O read: 648MB, write: 0MB, rate: 5.69MB/s
fix_uninit_block_bitmaps 1: Memory used: 132k/763980k (49k/84k), time: 
7.61/ 7.91/ 0.00
adjust_superblock: Memory used: 132k/18014398507538268k (52k/81k), time: 
  0.49/ 0.57/ 0.00
fix_uninit_block_bitmaps 2: Memory used: 132k/18014398507538268k 
(52k/81k), time:  8.10/ 8.17/ 0.00
blocks_to_move: Memory used: 132k/18014398508253624k (52k/81k), time: 
0.74/ 0.50/ 0.05
Number of free blocks: 1126335202/7242495991050, Needed: 0
block_mover: Memory used: 132k/18014398508254140k (57k/76k), time: 
192.51/192.28/ 0.00
block_mover: I/O read: 1MB, write: 0MB, rate: 0.01MB/s
inode_scan_and_fix: Memory used: 132k/18014398508254140k (57k/76k), 
time:  0.00/ 0.00/ 0.00
inode_ref_fix: Memory used: 132k/18014398508254140k (57k/76k), time: 
0.00/ 0.00/ 0.00
move_itables: Memory used: 132k/18014398508254140k (57k/76k), time: 
0.01/ 0.00/ 0.00
calculate_summary_stats: Memory used: 132k/18014398508254140k (57k/76k), 
time: 168.74/168.43/ 0.01
fix_resize_inode: Memory used: 132k/18014398508254140k (61k/72k), time: 
  0.00/ 0.00/ 0.00
fix_resize_inode: I/O read: 0MB, write: 3MB, rate: 1843.88MB/s
fix_sb_journal_backup: Memory used: 132k/18014398508254140k (61k/72k), 
time:  0.00/ 0.00/ 0.00
overall resize2fs: Memory used: 132k/18014398508254140k (61k/72k), time: 
492.61/379.13/ 4.52
overall resize2fs: I/O read: 648MB, write: 13MB, rate: 1.34MB/s
The filesystem on /dev/md0 is now 5860149888 blocks long.

So it would appear to have succeeded when run offline.

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Azat Khuzhin July 26, 2014, 7:04 a.m. UTC | #5
On Sat, Jul 26, 2014 at 12:12:11PM +0800, Brad Campbell wrote:
> On 26/07/14 11:31, Brad Campbell wrote:
> >On 25/07/14 22:07, Theodore Ts'o wrote:
> >>On Fri, Jul 25, 2014 at 07:44:07PM +0800, Brad Campbell wrote:
> >>>
> >>>Appreciate you taking a look at this and I see where you are going
> >>>with it.
> >>
> >>This patch looks good to me.  If you could give it a try, I would
> >>appreciate it.
> >>
> >>This looks like the same bug which was reported in Ubuntu:
> >>
> >>https://bugs.launchpad.net/ubuntu/+source/e2fsprogs/+bug/1321958
> >
> >
> >The patch would not apply automatically to 1.42.11 but was easy enough
> >to apply by hand.
> >
> >root@srv:~/src/e2fsprogs/e2fsprogs-1.42.11/resize# ./resize2fs -d 255
> >/dev/md0
> >resize2fs 1.42.11 (09-Jul-2014)
> >fs has 4007207 inodes, 1957 groups required.
> >fs requires 4374122900 data blocks.
> >With 1957 group(s), we have 63820826 blocks available.
> >Added 131540 extra group(s), blks_needed 4374122900, data_blocks
> >4356990326, last_start 4356599580
> >Added 523 extra group(s), blks_needed 4374122900, data_blocks
> >4374059350, last_start 4373440788
> >Added 2 extra group(s), blks_needed 4374122900, data_blocks 4374124886,
> >last_start 4373473426
> >Last group's overhead is 1430
> >Need 649474 data blocks in last group
> >Final size of last group is 650904
> >Estimated blocks needed: 4391437088
> >Extents safety margin: 2826959
> >Filesystem at /dev/md0 is mounted on /server; on-line resizing required
> >old_desc_blocks = 2768, new_desc_blocks = 2795
> >./resize2fs: Invalid argument While checking for on-line resizing support
> >
> >[489412.650430] EXT4-fs (md0): resizing filesystem from 5804916736 to
> >5860149888 blocks
> >[489412.700282] EXT4-fs warning (device md0): verify_reserved_gdb:713:
> >reserved GDT 2769 missing grp 177147 (5804755665)
> >[489412.739676] EXT4-fs (md0): resized filesystem to 5860149888
> >[489413.215230] EXT4-fs warning (device md0): ext4_group_extend:1720:
> >can't shrink FS - resize aborted

Online resizing needs support in kernel, so it is not strange that it
doesn't fixed with this patch.
I will take a look into online resizing code, but don't promise
anything.

> 
> Rebooted, did an fsck -f (was clean) and ran it again without the fs
> mounted.
> 
> root@srv:~/src/e2fsprogs/e2fsprogs-1.42.11/resize# ./resize2fs -d 255
> /dev/md0
> resize2fs 1.42.11 (09-Jul-2014)
> fs has 4007359 inodes, 1957 groups required.
> fs requires 4655464570 data blocks.
> With 1957 group(s), we have 63820826 blocks available.
> Added 140126 extra group(s), blks_needed 4655464570, data_blocks 4637219414,
> last_start 4636829448
> Added 557 extra group(s), blks_needed 4655464570, data_blocks 4655398390,
> last_start 4654584520
> Added 3 extra group(s), blks_needed 4655464570, data_blocks 4655496694,
> last_start 4654617158
> Last group's overhead is 1820
> Need 847412 data blocks in last group
> Final size of last group is 849232
> Estimated blocks needed: 4674027936
> Extents safety margin: 2261777
> Resizing the filesystem on /dev/md0 to 5860149888 (4k) blocks.
> read_bitmaps: Memory used: 132k/763980k (49k/84k), time: 113.93/ 1.26/ 4.45
> read_bitmaps: I/O read: 648MB, write: 0MB, rate: 5.69MB/s
> fix_uninit_block_bitmaps 1: Memory used: 132k/763980k (49k/84k), time: 7.61/
> 7.91/ 0.00
> adjust_superblock: Memory used: 132k/18014398507538268k (52k/81k), time:
> 0.49/ 0.57/ 0.00
> fix_uninit_block_bitmaps 2: Memory used: 132k/18014398507538268k (52k/81k),
> time:  8.10/ 8.17/ 0.00
> blocks_to_move: Memory used: 132k/18014398508253624k (52k/81k), time: 0.74/
> 0.50/ 0.05
> Number of free blocks: 1126335202/7242495991050, Needed: 0
> block_mover: Memory used: 132k/18014398508254140k (57k/76k), time:
> 192.51/192.28/ 0.00
> block_mover: I/O read: 1MB, write: 0MB, rate: 0.01MB/s
> inode_scan_and_fix: Memory used: 132k/18014398508254140k (57k/76k), time:
> 0.00/ 0.00/ 0.00
> inode_ref_fix: Memory used: 132k/18014398508254140k (57k/76k), time: 0.00/
> 0.00/ 0.00
> move_itables: Memory used: 132k/18014398508254140k (57k/76k), time: 0.01/
> 0.00/ 0.00
> calculate_summary_stats: Memory used: 132k/18014398508254140k (57k/76k),
> time: 168.74/168.43/ 0.01
> fix_resize_inode: Memory used: 132k/18014398508254140k (61k/72k), time:
> 0.00/ 0.00/ 0.00
> fix_resize_inode: I/O read: 0MB, write: 3MB, rate: 1843.88MB/s
> fix_sb_journal_backup: Memory used: 132k/18014398508254140k (61k/72k), time:
> 0.00/ 0.00/ 0.00
> overall resize2fs: Memory used: 132k/18014398508254140k (61k/72k), time:
> 492.61/379.13/ 4.52
> overall resize2fs: I/O read: 648MB, write: 13MB, rate: 1.34MB/s
> The filesystem on /dev/md0 is now 5860149888 blocks long.
> 
> So it would appear to have succeeded when run offline.

Brad, many thanks for testing, I will resend patch later.
(with your tested-by if you don't mind)

Thanks.
Azat.
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o July 26, 2014, 12:45 p.m. UTC | #6
OK, it looks like the e2fsprogs patch got you through the first
hurdle, but the failure is something that made no sense at first:

> [489412.650430] EXT4-fs (md0): resizing filesystem from 5804916736 to
> 5860149888 blocks
> [489412.700282] EXT4-fs warning (device md0): verify_reserved_gdb:713:
> reserved GDT 2769 missing grp 177147 (5804755665)

The code path which emitted the above warning something that should
ever be entered for file systems greater than 16TB.  But then I took a
look at the first message that you sent on this thread, and I think
see what's going wrong.  From your dumpe2fs -h output:

Filesystem features:      has_journal ext_attr resize_inode dir_index filetype
extent 64bit flex_bg sparse_super large_file huge_file uninit_bg dir_nlink
extra_isize
Block count:              5804916736
Reserved GDT blocks:      585

If the block count is greater than 2**32 (4294967296), resize_inode
must not be set, and reserved GDT blocks should be zero.  So this is
definitely not right.

I'm going to guess that this file system was originally a smaller size
(and probably smaller than 16T), and then was resized to 22TB,
probably using an earlier version of the kernel and/or e2fsprogs.  Is
my guess correct?  If so, do you remember the history of what size the
file system was, and in what steps it was resized, and what version of
the e2fsprogs and the kernel that was used at each stage, starting
from the original mke2fs and each successive resize?

I'm guessing what happened is that an earlier version of the kernel or
the e2fsprogs left the file system in an unexpected state.  It's
apparently one that e2fsck didn't complain about, but it definitely
wasn't normal.

In any case, the way I would suggest proceeding is the following.

1)  Unmount the file system

2)  Run "e2fsck -f" on the file system to make sure things look sane.

3) Run "debugfs -R 'stat <7>' /dev/md0" and "dumpe2fs -h /dev/md0" and
   send me the outputs just because I'm curious exactly what state the
   resize_inode --- which really shouldn't be there --- was actually in.

4)  Run "tune2fs -O ^resize_inode" on the file system

5) Run e2fsck -fy" on the file system.  The "errors" that fixed are
the result of clearing the resize_inode; don't be alarmed by them.

6) Remount the file system

7) Retry the resize2fs, making sure you are using your 3.15.6 kernel

That should hopefully allow things to work correctly.  In the future,
I will want to make the kernel and e2fsprogs more robust against this
sort of "should never happen" state, which is why I'm interested in
knowing the history of how the file system had been created and
resized in the past, and what the state was of the resize inode before
we blow it away.

Cheers,

							- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Azat Khuzhin July 26, 2014, 12:57 p.m. UTC | #7
On Sat, Jul 26, 2014 at 08:45:57AM -0400, Theodore Ts'o wrote:
> Filesystem features:      has_journal ext_attr resize_inode dir_index filetype
> extent 64bit flex_bg sparse_super large_file huge_file uninit_bg dir_nlink
> extra_isize
> Block count:              5804916736
> Reserved GDT blocks:      585
> 
> If the block count is greater than 2**32 (4294967296), resize_inode
> must not be set, and reserved GDT blocks should be zero.  So this is
> definitely not right.

I've just tried to reproduce this on 24T->48T raid0 array (resizing from
24T to 48T), without any success.
And that's why: I don't have resize_inode in filesystem features.
Thanks for pointing on this, Ted.

Cheers,
Azat.

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Brad Campbell July 26, 2014, 1:46 p.m. UTC | #8
On 26/07/14 20:45, Theodore Ts'o wrote:
> OK, it looks like the e2fsprogs patch got you through the first
> hurdle, but the failure is something that made no sense at first:
>
>> [489412.650430] EXT4-fs (md0): resizing filesystem from 5804916736 to
>> 5860149888 blocks
>> [489412.700282] EXT4-fs warning (device md0): verify_reserved_gdb:713:
>> reserved GDT 2769 missing grp 177147 (5804755665)
> The code path which emitted the above warning something that should
> ever be entered for file systems greater than 16TB.  But then I took a
> look at the first message that you sent on this thread, and I think
> see what's going wrong.  From your dumpe2fs -h output:
>
> Filesystem features:      has_journal ext_attr resize_inode dir_index filetype
> extent 64bit flex_bg sparse_super large_file huge_file uninit_bg dir_nlink
> extra_isize
> Block count:              5804916736
> Reserved GDT blocks:      585
>
> If the block count is greater than 2**32 (4294967296), resize_inode
> must not be set, and reserved GDT blocks should be zero.  So this is
> definitely not right.
>
> I'm going to guess that this file system was originally a smaller size
> (and probably smaller than 16T), and then was resized to 22TB,
> probably using an earlier version of the kernel and/or e2fsprogs.  Is
> my guess correct?  If so, do you remember the history of what size the
> file system was, and in what steps it was resized, and what version of
> the e2fsprogs and the kernel that was used at each stage, starting
> from the original mke2fs and each successive resize?
>
This was the first resize of this FS. Initially this array was about 
15T. About 12 months ago I attempted to resize it up to 19T and bumped 
up against the fact I had not created the initial filesystem with 64 bit 
support, so I cobbled together some storage and did a 
backup/create/restore. At that point I would probably have specified 
resize_inode manually as an option (as reading the man page it looked 
like a good idea as I always had plans to expand in future) to mke2fs 
along with 64bit. Fast forward 12 months and I've added 2 drives to the 
array and bumped up against this issue. So it was initially 4883458240 
blocks. It would have been created with e2fsprogs from Debian Stable (so 
1.42.5).

I can't test this to verify my memory however as I don't seem to be able 
to create a sparse file large enough to create a filesystem in. I appear 
to be bumping up against a 2T filesize limit.
Theodore Ts'o July 26, 2014, 1:56 p.m. UTC | #9
On Sat, Jul 26, 2014 at 09:46:20PM +0800, Brad Campbell wrote:
> This was the first resize of this FS. Initially this array was about 15T.
> About 12 months ago I attempted to resize it up to 19T and bumped up against
> the fact I had not created the initial filesystem with 64 bit support, so I
> cobbled together some storage and did a backup/create/restore. At that point
> I would probably have specified resize_inode manually as an option (as
> reading the man page it looked like a good idea as I always had plans to
> expand in future) to mke2fs along with 64bit. Fast forward 12 months and
> I've added 2 drives to the array and bumped up against this issue. So it was
> initially 4883458240 blocks. It would have been created with e2fsprogs from
> Debian Stable (so 1.42.5).

So mke2fs 1.42.11 does the right thing (although it really should just
tell you that there's no point using the resize_inode).

% mke2fs -Fq -t ext4 -O resize_inode,64bit /mnt/foo.img 19T
/mnt/foo.img contains a ext4 file system
	     created on Sat Jul 26 09:54:30 2014

% dumpe2fs -h /mnt/foo.img  | grep "Reserved GDT"
dumpe2fs 1.42.11 (09-Jul-2014)

% debugfs -R "stat <7>" /mnt/foo.img
debugfs 1.42.11 (09-Jul-2014)
Inode: 7   Type: bad type    Mode:  0000   Flags: 0x0
Generation: 0    Version: 0x00000000
User:     0   Group:     0   Size: 0
File ACL: 0    Directory ACL: 0
Links: 0   Blockcount: 0
Fragment:  Address: 0    Number: 0    Size: 0
ctime: 0x00000000 -- Wed Dec 31 19:00:00 1969
atime: 0x00000000 -- Wed Dec 31 19:00:00 1969
mtime: 0x00000000 -- Wed Dec 31 19:00:00 1969
Size of extra inode fields: 0
BLOCKS:

> I can't test this to verify my memory however as I don't seem to be able to
> create a sparse file large enough to create a filesystem in. I appear to be
> bumping up against a 2T filesize limit.

Yep, when I do this testing I create a loopback mounted (sparse) xfs
file system, so I can create the sparse files needed to do this sort
of testing.

My guess is that 1.42.5 is not doing the right thing, although I
haven't had a chance to test it yet.

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o July 29, 2014, 2:46 a.m. UTC | #10
On Sat, Jul 26, 2014 at 09:46:20PM +0800, Brad Campbell wrote:
> Fast forward 12 months and
> I've added 2 drives to the array and bumped up against this issue. So it was
> initially 4883458240 blocks. It would have been created with e2fsprogs from
> Debian Stable (so 1.42.5).

Confirmed; debian stable's mke2fs version 1.42.5 does the wrong thing
if you do:

   mke2fs -t ext4 -O 64bit,resize_inode /mnt/foo.img  19T

It creates a file system which is has a resize_inode which --- well,
is in a format that the kernel isn't capable of handling and which is
not something that was originally intended.  The interesting thing is
that resize2fs 1.42.11 is apparently able to handle resizing the above
file system created with mke2fs 1.42.5.

Mke2fs 1.42.12 will avoid creating a resize_inode for file systems >
16T, so this situation doesn't arise.

I need to take a closer look to see if there's some way I can teach
the kernel to be able to deal with this file system, but for now, you
can work around it by using tune2fs to remove the resize_inode, and
after running e2fsck and remounting the file system, the on-line
resize will work correctly.

Cheers,

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Brad Campbell July 29, 2014, 8 a.m. UTC | #11
On 29/07/14 10:46, Theodore Ts'o wrote:
> On Sat, Jul 26, 2014 at 09:46:20PM +0800, Brad Campbell wrote:
>> Fast forward 12 months and
>> I've added 2 drives to the array and bumped up against this issue. So it was
>> initially 4883458240 blocks. It would have been created with e2fsprogs from
>> Debian Stable (so 1.42.5).
>
> Confirmed; debian stable's mke2fs version 1.42.5 does the wrong thing
> if you do:
>
>     mke2fs -t ext4 -O 64bit,resize_inode /mnt/foo.img  19T
>
> It creates a file system which is has a resize_inode which --- well,
> is in a format that the kernel isn't capable of handling and which is
> not something that was originally intended.  The interesting thing is
> that resize2fs 1.42.11 is apparently able to handle resizing the above
> file system created with mke2fs 1.42.5.

And it did just fine once patched for the 32bit overflow. The off-line 
resize went without a hitch. Oddly enough the Kernel took it out to 
5641863168 blocks ok in the first online attempt.

> Mke2fs 1.42.12 will avoid creating a resize_inode for file systems >
> 16T, so this situation doesn't arise.
>
> I need to take a closer look to see if there's some way I can teach
> the kernel to be able to deal with this file system, but for now, you
> can work around it by using tune2fs to remove the resize_inode, and
> after running e2fsck and remounting the file system, the on-line
> resize will work correctly.

Would it not be easier just to put a test in resize2fs which says "I 
can't do that, please fix your filesystem first" ?

1.42.5 won't try (32 bit limit).
1.42.11 will spin (32 bit overflow)
So just make 1.42.12 abort with an error.

Is it worth having e2fsck check for mis-applied features and flags?
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index a8af969..98ce10a 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -2479,7 +2479,8 @@  blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
                extra_grps = ext2fs_div64_ceil(remainder,
                                               EXT2_BLOCKS_PER_GROUP(fs->super));
 
-               data_blocks += extra_grps * EXT2_BLOCKS_PER_GROUP(fs->super);
+               data_blocks += (unsigned long long)extra_grps *
+                       EXT2_BLOCKS_PER_GROUP(fs->super);
 
                /* ok we have to account for the last group */
                overhead = calc_group_overhead(fs, groups-1, old_desc_blocks);