[Bug 270632] [ext2fs] files <4096 bytes are corrupted on ext4 filesystems

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 07 Apr 2023 17:31:41 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270632

--- Comment #2 from Fedor Uporov <fsu@FreeBSD.org> ---
Hi, Rajeev.

Thanks a lot for bug report and detailed reproducer.

The problem is, that I did not managed to reproduce the issue locally. I've
tried VMWare and qemu VMs, but failed in both cases (see below).

Could you please provide the dmesg description of your USB thumb drive.

Also, it would be great if you will be able to reproduce it on main kernel and
check the same reproducer on ufs.

=== VMWare player FreeBSD guest:
root@fb:~ # mdconfig -s 1G
md0
root@fb:~ # mkfs.ext4 /dev/md0
mke2fs 1.47.0 (5-Feb-2023)
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: 6431b66c-ddaa-466c-abbe-add74f0465d4
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376

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

root@fb:~ # mount -t ext2fs /dev/md0 /mnt
root@fb:~ # echo 'hello world' >/mnt/a.txt
root@fb:~ # ed -s /mnt/a.txt <<\EoF
> 1s/./&/
> wq
> EoF
root@fb:~ # cat /mnt/a.txt
hello world
root@fb:~ # umount /mnt
root@fb:~ # mount -r -t ext2fs /dev/da0p1 /mnt
mount: /dev/da0p1: Invalid fstype: Invalid argument
root@fb:~ # mount -r -t ext2fs /dev/md0 /mnt
root@fb:~ # hexdump -C /mnt/a.txt
00000000  68 65 6c 6c 6f 20 77 6f  72 6c 64 0a              |hello world.|
0000000c
root@fb:~ # cat /mnt/a.txt
hello world


=== Flash drive, connected to VMWare player FreeBSD guest:
ugen1.2: <Samsung Flash Drive FIT> at usbus1
umass0 on uhub1
umass0: <Samsung Flash Drive FIT, class 0/0, rev 3.10/11.00, addr 2> on usbus1
umass0:  SCSI over Bulk-Only; quirks = 0x4000
umass0:3:0: Attached to scbus3
da1 at umass-sim0 bus 0 scbus3 target 0 lun 0
da1: <Samsung Flash Drive FIT 1100> Removable Direct Access SPC-4 SCSI device
da1: Serial Number 0321821010021934
da1: 40.000MB/s transfers
da1: 122376MB (250626566 512 byte sectors)
da1: quirks=0x2<NO_6_BYTE>
root@fb:~ # ls /dev | grep da
da0
da0s1
da0s1a
da0s1b
da1
da1p1
da1p2
root@fb:~ # mount -t ext2fs /dev/da1p1 /mnt
root@fb:~ # echo 'hello world' >/mnt/a.txt
root@fb:~ # ed -s /mnt/a.txt <<\EoF
> 1s/./&/
> wq
> EoF
root@fb:~ # cat /mnt/a.txt
hello world
root@fb:~ # umount /mnt
root@fb:~ # mount -r -t ext2fs /dev/da1p1 /mnt
root@fb:~ # hexdump -C /mnt/a.txt
00000000  68 65 6c 6c 6f 20 77 6f  72 6c 64 0a              |hello world.|
0000000c
root@fb:~ # umount /mnt


=== qemu emulated usb drive:
root@fb:~ # mke2fs -L thumbdrive -t ext4 /dev/da0
mke2fs 1.47.0 (5-Feb-2023)
Creating filesystem with 1048576 4k blocks and 262144 inodes
Filesystem UUID: 203eaac3-f303-42e7-976c-6e12138e2b1f
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736

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

root@fb:~ # mount -t ext2fs /dev/da0p1 /mnt
mount: /dev/da0p1: Invalid fstype: Invalid argument
root@fb:~ # mount -t ext2fs /dev/da0 /mnt
root@fb:~ # echo 'hello world' >/mnt/a.txt
root@fb:~ # ed -s /mnt/a.txt <<\EoF
> 1s/./&/
> wq
> EoF
root@fb:~ # cat /mnt/a.txt
hello world
root@fb:~ # umount /mnt
root@fb:~ # mount -r -t ext2fs /dev/da0 /mnt
root@fb:~ # hexdump -C /mnt/a.txt
00000000  68 65 6c 6c 6f 20 77 6f  72 6c 64 0a              |hello world.|
0000000c

For all cases:
root@fb:~ # uname -a
FreeBSD fb 14.0-CURRENT FreeBSD 14.0-CURRENT #0 main-n261872-1fb7d2cf999e: Thu
Mar 30 10:18:47 UTC 2023    
root@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64

-- 
You are receiving this mail because:
You are the assignee for the bug.