Summary: | ext2fs can not mount disks with 4K native sector size | ||||||
---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | bolvan <k> | ||||
Component: | kern | Assignee: | Fedor Uporov <fsu> | ||||
Status: | Open --- | ||||||
Severity: | Affects Some People | CC: | fs, fsu, fuz, grahamperrin | ||||
Priority: | --- | Keywords: | needs-qa | ||||
Version: | 13.2-STABLE | ||||||
Hardware: | amd64 | ||||||
OS: | Any | ||||||
Attachments: |
|
Description
bolvan
2023-04-27 20:31:22 UTC
Could you please, provide dmesg output, when you do mount and get error. If nothing will be seen in dmesg, could you please run dtrace with next command: % dtrace -n 'ext2fs::vfsops:* { printf("%s",stringof(arg0)); }' and try mount again. dmesg is empty dtrace -n 'ext2fs::vfsops:* { printf("%s",stringof(arg0)); }' did not output anything except dtrace: description 'ext2fs::vfsops:* ' matched 3 probes Ok, there is some number of EINVAL returns from mount path, which are not logged. Do you have ability to rebuild ext2fs kernel module? I will provide diff with some number of printfs, and instructions, how to rebuild it and load from /usr/src. OK, I'll try ext2fs also has trouble with file systems larger than 2 TiB. Could this be related? Actually it's easy to reproduce in qemu qemu-img.exe create -f raw test.raw 1G qemu-img.exe create -f raw test2.raw 1G qemu-system-x86_64.exe -drive format=qcow2,file=f.qcow2 -drive format=raw,file=test.raw,id=D24,if=none -device nvme,drive=D24,serial=1234,physical_block_size=4096,logical_block_size=4096 -drive format=raw,file=test2.raw,id=D25,if=none -device nvme,drive=D25,serial=1235,physical_block_size=512,logical_block_size=512 -m 4096 f.qcow2 contains freebsd test.raw has 4096 sector size test2.raw has 512 sector size mke2fs on both nvd0 and nvd1 mount first fails mount second succeeds Created attachment 241856 [details]
Add more printfs to mount path
Hope, I am understand correctly, where EINVAL come from, but need to be sure, that qemu and hw nvme issues are identical. Could you please download the attached file. And do next steps: % md5sum ./ext2_vfsops.c 1f7a613c27331abf391cb4ab6b99f434 ./ext2_vfsops.c % cp /usr/src/sys/fs/ext2fs/ext2_vfsops.c cp /usr/src/sys/fs/ext2fs/ext2_vfsops.c_bkp % cp ./ext2_vfsops.c /usr/src/sys/fs/ext2fs/ % cd /usr/src/sys/modules/ext2fs % make clean ; make % find / -name ext2fs.ko # The ext2fs.ko in the /usr/obj directory should be right module % kldload /usr/obj/path/to/ext2fs.ko Try to mount nvme drive and do dmesg, if everything is right, you should see "==== ext2_mount(+)" Please send me everything below this line (In reply to Fedor Uporov from comment #8) ext2_mountfs():SBSIZE:1024:4096,err=EINVAL ==== ext2_mountfs(): err=22 Ok, it is what I expected. Now I have clean issue definition. I do not have tests to verify disks with 4k sectors, it is time to add it. Thank you for participation and fast replies. It need some time to fix it. (In reply to Robert Clausecker from comment #5) If the drive have 4k sectors size, should be. If not, could you please provide more detailed description. (In reply to Robert Clausecker from comment #5) I tested this in qemu. qcow2 format allows to create drives large then available disk space I found no problem mounting 2.8T ext2 fs on a 512 sector size disk Triage: fs@ no longer the assignee, is now a cc recipient. (In reply to Fedor Uporov from comment #11) If you have a disk of more than 2 TiB and do IO on it, the kernel randomly crashes. The disk needs to be somewhat full for the problem to trigger. I think it only happens when files are accessed that are allocated beyond the 2 TiB mark. A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=50be18cc77b25891306f64192bf6f75e55d8903c commit 50be18cc77b25891306f64192bf6f75e55d8903c Author: Fedor Uporov <fsu@FreeBSD.org> AuthorDate: 2023-05-08 16:14:02 +0000 Commit: Fedor Uporov <fsu@FreeBSD.org> CommitDate: 2023-05-21 05:17:47 +0000 ext2fs: Add large sectorsize disks support The ext2fs does not support disks with sectorsize more 512 bytes. The main issue is in reading/writing superblock, which is not aligned with 4k value. Reimplement the superblock reading logic to make it indifferent to disk logical sector size. The logical sector size more then page size is not supported, like it is doing on Linux side. PR: 271105 Reported by: k(at)vodka.home.kg Reviewed by: pfg MFC after: 2 week Differential Revision: https://reviews.freebsd.org/D40047 sys/fs/ext2fs/ext2_vfsops.c | 48 ++++++++++++++++++++++++--------------------- sys/fs/ext2fs/fs.h | 6 ++++-- 2 files changed, 30 insertions(+), 24 deletions(-) |