Bug 1568835

Summary: Creating fixed number of blocks ext4 fs against a special block device fails
Product: Red Hat Enterprise Linux 7 Reporter: Boyang Xue <bxue>
Component: e2fsprogsAssignee: Lukáš Czerner <lczerner>
Status: CLOSED NOTABUG QA Contact: Boyang Xue <bxue>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.5   
Target Milestone: rc   
Target Release: 7.6   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-18 11:29:58 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:

Description Boyang Xue 2018-04-18 10:12:25 UTC
Description of problem:
Creating fixed nuber of block ext4 fs against a special block device
fails. The special block device is the result of a bunch of random
operations(including mkfs, wipefs, resize2fs), and it has been dump
out to http://download.devel.redhat.com/qa/rhts/lookaside/mkfs_ext4_fail.img.gz

steps to reproduce:

wget http://download.devel.redhat.com/qa/rhts/lookaside/mkfs_ext4_fail.img.gz
gzip -d -c mkfs_ext4_fail.img.gz | dd of=/dev/vda7 bs=64K # /dev/vda7 > 10.5GB

# Create ext4 fs with fixed number of blocks
[root@vm ~]# mkfs.ext4 -F -b 1024 /dev/vda7 $((1073741824/2/2))
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
16777216 inodes, 268435456 blocks
13421772 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=301989888
32768 block groups
8192 blocks per group, 8192 fragments per group
512 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409, 663553,
        1024001, 1990657, 2809857, 5120001, 5971969, 17915905, 19668993,
        25600001, 53747713, 128000001, 137682945, 161243137

Allocating group tables: done
mkfs.ext4: Invalid argument while zeroing block 268435392 at end of filesystem
Writing inode tables: done
Creating journal (32768 blocks): mkfs.ext4: Invalid argument
        while trying to create journal

# Create ext4 fs on the whole device
[root@vm ~]# mkfs.ext4 -F /dev/vda7
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
689520 inodes, 2756604 blocks
137830 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2151677952
85 block groups
32768 blocks per group, 32768 fragments per group
8112 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

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

The failed operation ( mkfs.ext4 -F -b 1024 /dev/vda7
$((1073741824/2/2)) ) can be successfully run on F28
(e2fsprogs-1.43.8-1.fc28.x86_64).

Version-Release number of selected component (if applicable):
e2fsprogs-1.42.9-11.el7.x86_64 (RHEL-7.5 GA distro)

How reproducible:
Always

Steps to Reproduce:
Refer to "Description of problem" above

Actual results:
Test fails.

Expected results:
Test runs passed.

Additional info:
N/A

Comment 1 Lukáš Czerner 2018-04-18 11:29:58 UTC
Hi Boyang,

this has nothing to do with the file system image. This happens because you've specified a bigger file system size than is the size of the device itself.

mkfs.ext4 -F -b 1024 /dev/vda7 $((1073741824/2/2))

Normally mke2fs is going to warn you about that:

mkfs.ext4 /dev/vdb1 1T
mke2fs 1.42.9 (28-Dec-2013)
mkfs.ext4: Filesystem larger than apparent device size.
Proceed anyway? (y,n) 

However you've forced the operation using '-F' so:

 mkfs.ext4 -F /dev/vdb1 1T
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
67108864 inodes, 268435456 blocks
13421772 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2415919104
8192 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000, 214990848

Allocating group tables: done                            
mkfs.ext4: Invalid argument while zeroing block 268435440 at end of filesystem
Writing inode tables: done                            
Creating journal (32768 blocks): mkfs.ext4: Invalid argument 
        while trying to create journal

This is not a bug.


Note that we do not really make any decisions in mke2fs based on what we read from the device, other than using blkid library to check for existing signatures. So unless it's a valid signature on a valid offset, no data on the device itself will influence anytihng mke2fs does. Not sure what you're trying to test with you special block device.