Bug 1383629

Summary: Shrink the file system with the resize2fs causes core dump
Product: [Fedora] Fedora Reporter: lnie <lnie>
Component: e2fsprogsAssignee: Eric Sandeen <esandeen>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 25CC: esandeen, josef, jrefl5, kzak, lnie, oliver, vedran
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: e2fsprogs-1.43.3-1.fc25 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-12-04 02:29:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
command history
none
journal
none
/var/spool/abrt/ccpp-2016-10-11-17:37:55-2415 none

Description lnie 2016-10-11 09:51:21 UTC
Created attachment 1209089 [details]
command history

Description of problem:
shrinking the ext4 file system with resize2fs ,which works well in f24,failed

Version-Release number of selected component (if applicable):
e2fsprogs-1.43.1-2.fc25.x86_64

How reproducible:
always

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 lnie 2016-10-11 09:52:02 UTC
Created attachment 1209090 [details]
journal

Comment 2 Eric Sandeen 2016-10-11 14:06:09 UTC
Details, please.

Attach "dumpe2fs -h" of the device you're shrinking, so we know the original size, features, and geometry.

Tell us what commandline you used for resize2fs, i.e. how much you tried to shrink it.

Provide the coredump of the failed resize2fs.

Ideally, give us a compressed raw or qcow e2image of the filesystem for us to use as a reproducer.

Thanks,
-Eric

Comment 3 Eric Sandeen 2016-10-11 14:58:06 UTC
Sorry, I missed the command history attachment.  Next time please list that as "reproducer"  ;)

    1  fdisk /dev/sdb
    2  fdisk /dev/sdb
    3  pvcreate /dev/sdb1
    4  vgcreate testvg /dev/sdb1
    5  lvcreate -L 500M -n testlv testvg
    6  mkfs.ext4 /dev/testvg/testlv
    7  mount /dev/testvg/testlv /mnt
    8  cd /mnt
    9  vi test
   10  lvextend -L +500M /dev/testvg/testlv
   11  resize2fs /dev/testvg/testlv
   12  cd /
   13  umount /mnt
   14  resize2fs /dev/testvg/testlv 500M
   15  e2fsck -f /dev/testvg/testlv
   16  resize2fs /dev/testvg/testlv 500M

Comment 4 Eric Sandeen 2016-10-11 15:09:46 UTC
That said, the command history has a few missteps/mistakes and doesn't tell us enough... but this works in an e2fsprogs git tree checked out to 1.43.1:

#!/bin/bash

rm -f testfile
truncate --size=500M testfile
misc/mkfs.ext4 testfile
mkdir -p mnt
mount -o loop testfile mnt
echo foo > mnt/test
umount mnt
truncate --size=1000M testfile
e2fsck/e2fsck -f testfile
resize/resize2fs testfile


-----

mke2fs 1.43.1 (08-Jun-2016)
Discarding device blocks: done                            
Creating filesystem with 512000 1k blocks and 128016 inodes
Filesystem UUID: 899039ae-b64e-43f8-beac-aaa1145fc4bb
Superblock backups stored on blocks: 
	8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done 

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
e2fsck 1.43.1 (08-Jun-2016)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
testfile: 12/128016 files (0.0% non-contiguous), 26668/512000 blocks
resize2fs 1.43.1 (08-Jun-2016)
Resizing the filesystem on testfile to 1024000 (1k) blocks.
The filesystem on testfile is now 1024000 (1k) blocks long.


so please provide more info as requested in comment #2 after all.

Comment 5 Eric Sandeen 2016-10-11 16:08:45 UTC
This reproduces it.

#!/bin/bash

rm -f testfile
truncate --size=1000M testfile
misc/mkfs.ext4 testfile 500m
mkdir -p mnt
mount -o loop testfile mnt
echo foo > mnt/test
resize/resize2fs testfile
umount mnt
e2fsck/e2fsck -f testfile
resize/resize2fs testfile 500M

Comment 6 Eric Sandeen 2016-10-11 16:12:57 UTC
This was fixed in 1.43.2:

commit 3d6fc974831a360aee460e54c442538445f3017c
Author: Theodore Ts'o <tytso>
Date:   Wed Aug 10 15:49:35 2016 -0400

    resize2fs: fix crash when there is an ea block and no blocks to migrate
    
    This fixes a bug introduced in 1.43 by commit fb47b94fffc: "resize2fs:
    rewrite extent/dir/ea block checksums when migrating".  If there is an
    extended attribute block and there are no blocks that need to migrate,
    we will crash.
    
    The bug was caused by a botched De Morgan's transformation.
    
    Signed-off-by: Theodore Ts'o <tytso>

Comment 7 lnie 2016-10-12 05:25:02 UTC
Created attachment 1209459 [details]
/var/spool/abrt/ccpp-2016-10-11-17:37:55-2415

Comment 8 lnie 2016-10-12 05:27:34 UTC
[root@localhost /]# dumpe2fs -h /dev/testvg/testlv
dumpe2fs 1.43.1 (08-Jun-2016)
Filesystem volume name:   <none>
Last mounted on:          /mnt
Filesystem UUID:          fee6553c-998f-469a-a953-d63fd88e0ec1
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize
Filesystem flags:         signed_directory_hash
Default mount options:    user_xattr acl
Filesystem state:         clean with errors
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              254000
Block count:              1024000
Reserved block count:     45912
Free blocks:              981181
Free inodes:              253988
First block:              1
Block size:               1024
Fragment size:            1024
Group descriptor size:    64
Reserved GDT blocks:      252
Blocks per group:         8192
Fragments per group:      8192
Inodes per group:         2032
Inode blocks per group:   254
Flex block group size:    16
Filesystem created:       Tue Oct 11 17:32:54 2016
Last mount time:          Tue Oct 11 17:33:04 2016
Last write time:          Tue Oct 11 17:37:55 2016
Mount count:              0
Maximum mount count:      -1
Last checked:             Tue Oct 11 17:37:52 2016
Check interval:           0 (<none>)
Lifetime writes:          41 MB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               128
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      165dbd92-6936-41f0-8bf8-331f238867bb
Journal backup:           inode blocks
Journal features:         journal_incompat_revoke journal_64bit
Journal size:             8M
Journal length:           8192
Journal sequence:         0x00000006
Journal start:            0
"dump2" 50L, 1923C                                                                                                                                                11,1          Top

Comment 9 James Crawford 2016-11-30 20:20:18 UTC
This bug is also causing livecd-creator to fail on F25:

Nov 30 13:10:44 localhost kernel: resize2fs[31560]: segfault at 20 ip 000055e9435494fc sp 00007ffea4816440 error 4 in resize2fs[55e943544000+d000]


dumpe2fs -V
dumpe2fs 1.43.1 (08-Jun-2016)
        Using EXT2FS Library version 1.43.1

I can provide the core dump from a VBOX instance of Fedora 25 if needed.

Comment 10 Eric Sandeen 2016-11-30 20:31:49 UTC
Ok, I guess we need and update to e2fsprogs-1.43.3 in f25.

Could you grab https://kojipkgs.fedoraproject.org/packages/e2fsprogs/1.43.3/1.fc26/src/e2fsprogs-1.43.3-1.fc26.src.rpm, rebuild & install it, and retest?

-Eric

Comment 11 James Crawford 2016-12-01 01:21:19 UTC
I will do the test as soon as I get back in the office Friday No access to the box from outside.

Comment 12 James Crawford 2016-12-02 14:51:41 UTC
Eric,

Looks like that fixes the problem.

Did a rpmbuild --rebuild Followed by rpm -U on the VM.
The livecd-creator script I use ran to successful completion.

Comment 13 Eric Sandeen 2016-12-02 15:09:50 UTC
Great, thank you for the test.  I'll just push the new version to f25.

-Eric

Comment 14 Fedora Update System 2016-12-02 15:48:10 UTC
e2fsprogs-1.43.3-1.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2016-3de96f01e4

Comment 15 Fedora Update System 2016-12-03 04:37:39 UTC
e2fsprogs-1.43.3-1.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-3de96f01e4

Comment 16 Fedora Update System 2016-12-04 02:29:00 UTC
e2fsprogs-1.43.3-1.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.

Comment 17 Vedran Miletić 2016-12-13 15:03:25 UTC
*** Bug 1404300 has been marked as a duplicate of this bug. ***