Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault during btrfs fi usage #959

Open
KES777 opened this issue Feb 16, 2025 · 11 comments
Open

Segmentation fault during btrfs fi usage #959

KES777 opened this issue Feb 16, 2025 · 11 comments

Comments

@KES777
Copy link

KES777 commented Feb 16, 2025

Here is list of command I did (I want to seed new device with existing btrfs). The instruction I followed is https://btrfs.readthedocs.io/en/latest/Seeding-device.html

root@work:/media/kes/WORK-DATA/docker_images# df -h
Filesystem      Size  Used Avail Use% Mounted on
...
/dev/sdd2       1,3T  5,8M  1,3T   1% /media/kes/ST-WORKDATA-COPY
/dev/sdc1       932G   21G  885G   3% /media/kes/WORK-DATA

root@work:/media/kes# umount WORK-DATA/

root@work:/media/kes# btrfstune -S 1 /dev/sdc1

root@work:/media/kes# mount /dev/sdc1 /media/kes/WORK-DATA
mount: /media/kes/WORK-DATA: WARNING: source write-protected, mounted read-only.

root@work:/media/kes# btrfs device add /dev/sdd2 /media/kes/WORK-DATA
ERROR: /dev/sdd2 appears to contain an existing filesystem (btrfs)
ERROR: use the -f option to force overwrite of /dev/sdd2

root@work:/media/kes# btrfs device add -f /dev/sdd2 /media/kes/WORK-DATA
ERROR: /dev/sdd2 is mounted

root@work:/media/kes# umount ST-WORKDATA-COPY/
root@work:/media/kes# df -h
Filesystem      Size  Used Avail Use% Mounted on
...
/dev/sdc1       932G   21G  711G   3% /media/kes/WORK-DATA

root@work:/media/kes# btrfs device add -f /dev/sdd2 /media/kes/WORK-DATA
Performing full device TRIM /dev/sdd2 (1.24TiB) ...

root@work:/media/kes# umount WORK-DATA/
root@work:/media/kes# mount /dev/sdc1 /media/kes/WORK-DATA
mount: /media/kes/WORK-DATA: WARNING: source write-protected, mounted read-only.
root@work:/media/kes# umount WORK-DATA/

root@work:/media/kes# mount /dev/sdd2 /media/kes/WORK-DATA
mount: /media/kes/WORK-DATA: mount(2) system call failed: No such file or directory.
       dmesg(1) may have more information after failed mount system call.

root@work:/media/kes# df -h
Filesystem      Size  Used Avail Use% Mounted on

As you can see none sdd2 and sdc1 are mounted


root@work:/media/kes# mount /dev/sdd2 /media/kes/WORK-DATA
mount: /media/kes/WORK-DATA: mount(2) system call failed: No such file or directory.
       dmesg(1) may have more information after failed mount system call.

This failed. Probably no all data were copied yet.

root@work:/media/kes# mount /dev/sdc1 /media/kes/WORK-DATA
mount: /media/kes/WORK-DATA: WARNING: source write-protected, mounted read-only.

root@work:/media/kes# btrfs device stats /media/kes/WORK-DATA
[/dev/sdc1].write_io_errs    0
[/dev/sdc1].read_io_errs     0
[/dev/sdc1].flush_io_errs    0
[/dev/sdc1].corruption_errs  0
[/dev/sdc1].generation_errs  0


root@work:/media/kes# btrfs fi df /media/kes/WORK-DATA
Data, single: total=189.00GiB, used=14.57GiB
System, DUP: total=8.00MiB, used=48.00KiB
Metadata, DUP: total=16.00GiB, used=2.91GiB
GlobalReserve, single: total=118.55MiB, used=0.00B

root@work:/media/kes# btrfs fi usage /media/kes/WORK-DATA
Overall:
    Device size:		 931.51GiB
    Device allocated:		 221.02GiB
    Device unallocated:		 710.50GiB
    Device missing:		     0.00B
    Device slack:		     0.00B
    Used:			  20.40GiB
    Free (estimated):		 884.92GiB	(min: 529.67GiB)
    Free (statfs, df):		 710.50GiB
    Data ratio:			      1.00
    Metadata ratio:		      2.00
    Global reserve:		 118.55MiB	(used: 0.00B)
    Multiple profiles:		        no

Data,single: Size:189.00GiB, Used:14.57GiB (7.71%)
   /dev/sdc1	 189.00GiB

Metadata,DUP: Size:16.00GiB, Used:2.91GiB (18.21%)
   /dev/sdc1	  32.00GiB

System,DUP: Size:8.00MiB, Used:48.00KiB (0.59%)
   /dev/sdc1	  16.00MiB

Unallocated:
   /dev/sdc1	 710.50GiB


root@work:/media/kes# btrfs fi usage /media/kes/WORK-DATA -T
Overall:
    Device size:		 931.51GiB
    Device allocated:		 221.02GiB
    Device unallocated:		 710.50GiB
    Device missing:		     0.00B
    Device slack:		     0.00B
    Used:			  20.40GiB
    Free (estimated):		 884.92GiB	(min: 529.67GiB)
    Free (statfs, df):		 710.50GiB
    Data ratio:			      1.00
    Metadata ratio:		      2.00
    Global reserve:		 118.55MiB	(used: 0.00B)
    Multiple profiles:		        no

             Data      Metadata System                              
Id Path      single    DUP      DUP      Unallocated Total     Slack
-- --------- --------- -------- -------- ----------- --------- -----
 1 /dev/sdc1 189.00GiB 32.00GiB 16.00MiB   710.50GiB 931.51GiB     -
-- --------- --------- -------- -------- ----------- --------- -----
   Total     189.00GiB 16.00GiB  8.00MiB   710.50GiB 931.51GiB 0.00B
   Used       14.57GiB  2.91GiB 48.00KiB                            


root@work:/media/kes# btrfs device add -f /dev/sdd2 /media/kes/WORK-DATA
Performing full device TRIM /dev/sdd2 (1.24TiB) ...

root@work:/media/kes# btrfs fi usage /media/kes/WORK-DATA -T
Segmentation fault

Here is the latest messages from dmesg when segfault happened

[ 3488.880865] BTRFS info (device sdc1): last unmount of filesystem e390e7b1-d688-4ab4-a7e8-aaac0383bce6
[ 3525.654418] BTRFS: device label WORK-DATA devid 1 transid 294102 /dev/sdc1 scanned by (udev-worker) (24134)
[ 3546.789256] BTRFS: device label WORK-DATA devid 1 transid 294102 /dev/sdc1 scanned by mount (24250)
[ 3546.792694] BTRFS info (device sdc1): first mount of filesystem e390e7b1-d688-4ab4-a7e8-aaac0383bce6
[ 3546.792717] BTRFS info (device sdc1): using crc32c (crc32c-intel) checksum algorithm
[ 3546.792722] BTRFS info (device sdc1): disk space caching is enabled
[ 3709.315141] BTRFS info (device sdd2): last unmount of filesystem d2baeea5-cdfe-44c9-8a99-092817bc88e9
[ 3718.999621] BTRFS info (device sdc1): relocating block group 540390981632 flags system|dup
[ 3719.364214] BTRFS info (device sdc1): relocating block group 22020096 flags system|dup
[ 3719.861071] BTRFS info (device sdc1): disk added /dev/sdd2
[ 3731.758083] i915 0000:00:02.0: Using 39-bit DMA addresses
[ 3800.566032] BTRFS info (device sdc1): last unmount of filesystem 20535765-5b6d-4245-b635-391f70d374f0
[ 3813.661722] BTRFS warning: device /dev/sdc1 maj:min changed from 0:0 to 8:33
[ 3813.662284] BTRFS: device label WORK-DATA devid 1 transid 294102 /dev/sdc1 scanned by mount (26489)
[ 3813.662896] BTRFS info (device sdc1): first mount of filesystem e390e7b1-d688-4ab4-a7e8-aaac0383bce6
[ 3813.662925] BTRFS info (device sdc1): using crc32c (crc32c-intel) checksum algorithm
[ 3813.662934] BTRFS info (device sdc1): disk space caching is enabled
[ 3825.019412] BTRFS info (device sdc1): last unmount of filesystem e390e7b1-d688-4ab4-a7e8-aaac0383bce6
[ 3836.801256] BTRFS: device label WORK-DATA devid 2 transid 294111 /dev/sdd2 scanned by mount (26621)
[ 3836.801923] BTRFS info (device sdd2): first mount of filesystem 20535765-5b6d-4245-b635-391f70d374f0
[ 3836.801957] BTRFS info (device sdd2): using crc32c (crc32c-intel) checksum algorithm
[ 3836.801968] BTRFS info (device sdd2): disk space caching is enabled
[ 3836.803610] BTRFS error (device sdd2): failed to read chunk tree: -2
[ 3836.804043] BTRFS error (device sdd2): open_ctree failed
[ 3880.116644] BTRFS: device label WORK-DATA devid 2 transid 294111 /dev/sdd2 scanned by mount (26854)
[ 3880.118836] BTRFS info (device sdd2): first mount of filesystem 20535765-5b6d-4245-b635-391f70d374f0
[ 3880.118870] BTRFS info (device sdd2): using crc32c (crc32c-intel) checksum algorithm
[ 3880.118882] BTRFS info (device sdd2): disk space caching is enabled
[ 3880.120109] BTRFS error (device sdd2): failed to read chunk tree: -2
[ 3880.120491] BTRFS error (device sdd2): open_ctree failed
[ 3898.206976] BTRFS: device label WORK-DATA devid 1 transid 294102 /dev/sdc1 scanned by mount (26962)
[ 3898.207405] BTRFS: device label WORK-DATA devid 1 transid 294102 /dev/sdc1 scanned by mount (26962)
[ 3898.208074] BTRFS info (device sdc1): first mount of filesystem e390e7b1-d688-4ab4-a7e8-aaac0383bce6
[ 3898.208104] BTRFS info (device sdc1): using crc32c (crc32c-intel) checksum algorithm
[ 3898.208113] BTRFS info (device sdc1): disk space caching is enabled
[ 3986.273917] BTRFS info (device sdc1): relocating block group 540390981632 flags system|dup
[ 3986.649350] BTRFS info (device sdc1): relocating block group 22020096 flags system|dup
[ 3987.123900] BTRFS info (device sdc1): disk added /dev/sdd2
[ 3993.686990] btrfs[27481]: segfault at 7ffcc9557010 ip 00005eed6ab3031a sp 00007ffcc9554ef0 error 4 in btrfs[5eed6aabf000+91000] likely on CPU 6 (core 3, socket 0)
[ 3993.687021] Code: ff ff 49 8b 06 48 89 85 98 ef ff ff 4c 89 e8 48 c1 e0 05 48 89 85 90 ef ff ff 48 8b 85 90 ef ff ff 48 39 c3 0f 84 58 ff ff ff <4d> 8b 54 1e 30 41 8b 77 08 31 c0 39 f0 72 6c be 20 00 00 00 bf 01

If I unmount/mount, and run usage subcommand again I see Segmentation fault.

[ 3880.118870] BTRFS info (device sdd2): using crc32c (crc32c-intel) checksum algorithm
[ 3880.118882] BTRFS info (device sdd2): disk space caching is enabled
[ 3880.120109] BTRFS error (device sdd2): failed to read chunk tree: -2
[ 3880.120491] BTRFS error (device sdd2): open_ctree failed
[ 3898.206976] BTRFS: device label WORK-DATA devid 1 transid 294102 /dev/sdc1 scanned by mount (26962)
[ 3898.207405] BTRFS: device label WORK-DATA devid 1 transid 294102 /dev/sdc1 scanned by mount (26962)
[ 3898.208074] BTRFS info (device sdc1): first mount of filesystem e390e7b1-d688-4ab4-a7e8-aaac0383bce6
[ 3898.208104] BTRFS info (device sdc1): using crc32c (crc32c-intel) checksum algorithm
[ 3898.208113] BTRFS info (device sdc1): disk space caching is enabled
[ 3986.273917] BTRFS info (device sdc1): relocating block group 540390981632 flags system|dup
[ 3986.649350] BTRFS info (device sdc1): relocating block group 22020096 flags system|dup
[ 3987.123900] BTRFS info (device sdc1): disk added /dev/sdd2
[ 3993.686990] btrfs[27481]: segfault at 7ffcc9557010 ip 00005eed6ab3031a sp 00007ffcc9554ef0 error 4 in btrfs[5eed6aabf000+91000] likely on CPU 6 (core 3, socket 0)
[ 3993.687021] Code: ff ff 49 8b 06 48 89 85 98 ef ff ff 4c 89 e8 48 c1 e0 05 48 89 85 90 ef ff ff 48 8b 85 90 ef ff ff 48 39 c3 0f 84 58 ff ff ff <4d> 8b 54 1e 30 41 8b 77 08 31 c0 39 f0 72 6c be 20 00 00 00 bf 01
[ 4395.516104] btrfs[29596]: segfault at 7ffe7f793000 ip 00005f3c7826531a sp 00007ffe7f78f760 error 4 in btrfs[5f3c781f4000+91000] likely on CPU 3 (core 1, socket 0)
[ 4395.516138] Code: ff ff 49 8b 06 48 89 85 98 ef ff ff 4c 89 e8 48 c1 e0 05 48 89 85 90 ef ff ff 48 8b 85 90 ef ff ff 48 39 c3 0f 84 58 ff ff ff <4d> 8b 54 1e 30 41 8b 77 08 31 c0 39 f0 72 6c be 20 00 00 00 bf 01
[ 4490.785456] btrfs[30088]: segfault at 7ffe400c1010 ip 000060fa70cab31a sp 00007ffe400be670 error 4 in btrfs[60fa70c3a000+91000] likely on CPU 3 (core 1, socket 0)
[ 4490.785487] Code: ff ff 49 8b 06 48 89 85 98 ef ff ff 4c 89 e8 48 c1 e0 05 48 89 85 90 ef ff ff 48 8b 85 90 ef ff ff 48 39 c3 0f 84 58 ff ff ff <4d> 8b 54 1e 30 41 8b 77 08 31 c0 39 f0 72 6c be 20 00 00 00 bf 01
[ 4720.307911] BTRFS info (device sdc1): last unmount of filesystem 71886b7f-bd43-4bfb-9170-269acbe80fd1
[ 4733.260077] BTRFS: device label WORK-DATA devid 2 transid 294111 /dev/sdd2 scanned by mount (31435)
[ 4733.260767] BTRFS info (device sdd2): first mount of filesystem 71886b7f-bd43-4bfb-9170-269acbe80fd1
[ 4733.260803] BTRFS info (device sdd2): using crc32c (crc32c-intel) checksum algorithm
[ 4733.260815] BTRFS info (device sdd2): disk space caching is enabled
[ 4733.282774] BTRFS warning: device /dev/sdc1 maj:min changed from 0:0 to 8:33
[ 4734.159815] BTRFS info (device sdd2): checking UUID tree
[ 4776.573384] btrfs[31679]: segfault at 7ffce63cc010 ip 000062a3be79531a sp 00007ffce63c91f0 error 4 in btrfs[62a3be724000+91000] likely on CPU 0 (core 0, socket 0)
[ 4776.573417] Code: ff ff 49 8b 06 48 89 85 98 ef ff ff 4c 89 e8 48 c1 e0 05 48 89 85 90 ef ff ff 48 8b 85 90 ef ff ff 48 39 c3 0f 84 58 ff ff ff <4d> 8b 54 1e 30 41 8b 77 08 31 c0 39 f0 72 6c be 20 00 00 00 bf 01
[ 4929.659392] btrfs[32549]: segfault at 7ffd3f62d000 ip 00005e00d06f431a sp 00007ffd3f629700 error 4 in btrfs[5e00d0683000+91000] likely on CPU 7 (core 3, socket 0)
[ 4929.659424] Code: ff ff 49 8b 06 48 89 85 98 ef ff ff 4c 89 e8 48 c1 e0 05 48 89 85 90 ef ff ff 48 8b 85 90 ef ff ff 48 39 c3 0f 84 58 ff ff ff <4d> 8b 54 1e 30 41 8b 77 08 31 c0 39 f0 72 6c be 20 00 00 00 bf 01

This command works:

btrfs fi show /media/kes/WORK-DATA 
Label: 'WORK-DATA'  uuid: 71886b7f-bd43-4bfb-9170-269acbe80fd1
	Total devices 2 FS bytes used 17.49GiB
	devid    1 size 931.51GiB used 221.00GiB path /dev/sdc1
	devid    2 size 1.24TiB used 2.56GiB path /dev/sdd2

This one also succeed:

btrfs device delete /dev/sdc1 /media/kes/WORK-DATA/

When second device was deleted the usage works again:

root@work:/media/kes# btrfs fi usage /media/kes/WORK-DATA 
Overall:
    Device size:		   1.24TiB
    Device allocated:		  22.56GiB
    Device unallocated:		   1.21TiB
    Device missing:		     0.00B
    Device slack:		     0.00B
    Used:			  20.28GiB
    Free (estimated):		   1.22TiB	(min: 623.61GiB)
    Free (statfs, df):		   1.22TiB
    Data ratio:			      1.00
    Metadata ratio:		      2.00
    Global reserve:		  81.92MiB	(used: 0.00B)
    Multiple profiles:		        no

Data,single: Size:16.00GiB, Used:14.53GiB (90.80%)
   /dev/sdd2	  16.00GiB

Metadata,DUP: Size:3.25GiB, Used:2.88GiB (88.48%)
   /dev/sdd2	   6.50GiB

System,DUP: Size:32.00MiB, Used:16.00KiB (0.05%)
   /dev/sdd2	  64.00MiB

Unallocated:
   /dev/sdd2	   1.21TiB
root@work:/media/kes# btrfs fi usage /media/kes/WORK-DATA -T
Overall:
    Device size:		   1.24TiB
    Device allocated:		  22.56GiB
    Device unallocated:		   1.21TiB
    Device missing:		     0.00B
    Device slack:		     0.00B
    Used:			  20.28GiB
    Free (estimated):		   1.22TiB	(min: 623.61GiB)
    Free (statfs, df):		   1.22TiB
    Data ratio:			      1.00
    Metadata ratio:		      2.00
    Global reserve:		  81.92MiB	(used: 0.00B)
    Multiple profiles:		        no

             Data     Metadata System                            
Id Path      single   DUP      DUP      Unallocated Total   Slack
-- --------- -------- -------- -------- ----------- ------- -----
 2 /dev/sdd2 16.00GiB  6.50GiB 64.00MiB     1.21TiB 1.24TiB     -
-- --------- -------- -------- -------- ----------- ------- -----
   Total     16.00GiB  3.25GiB 32.00MiB     1.21TiB 1.24TiB 0.00B
   Used      14.53GiB  2.88GiB 16.00KiB                          
@adam900710
Copy link
Collaborator

adam900710 commented Feb 17, 2025

The failed to mount looks like btrfs failed to find out the seed device.

Have you unloaded the btrfs modules or ran btrfs dev scan -u to forgot the devices?
Anyway, you can use btrfs dev scan, then try to mount the writeable device, it should success again.

I can only reproduce the mount failure with the device forgotten, but not other ways.

@adam900710
Copy link
Collaborator

But I failed to reproduce your btrfs fi usage segfault, mind to provide the progs version?

[adam@btrfs-vm linux]$ sudo mount /dev/test/scratch1  /mnt/btrfs/
mount: /mnt/btrfs: WARNING: source write-protected, mounted read-only.
[adam@btrfs-vm linux]$ sudo btrfs dev add -f /dev/test/scratch2  /mnt/btrfs/
Performing full device TRIM /dev/test/scratch2 (10.00GiB) ...
[adam@btrfs-vm linux]$ sudo btrfs fi usage /mnt/btrfs/ -T
Overall:
    Device size:		  10.00GiB
    Device allocated:		   2.07GiB
    Device unallocated:		   7.93GiB
    Device missing:		     0.00B
    Device slack:		     0.00B
    Used:			   7.56MiB
    Free (estimated):		   8.93GiB	(min: 4.97GiB)
    Free (statfs, df):		   9.44GiB
    Data ratio:			      1.00
    Metadata ratio:		      2.00
    Global reserve:		   5.50MiB	(used: 0.00B)
    Multiple profiles:		        no

                             Data    Metadata  System
Id Path                      single  DUP       DUP      Unallocated Total    Slack
-- ------------------------- ------- --------- -------- ----------- -------- -----
 2 /dev/mapper/test-scratch2       - 512.00MiB 64.00MiB     9.44GiB 10.00GiB     -
-- ------------------------- ------- --------- -------- ----------- -------- -----
   Total                     1.01GiB 512.00MiB 32.00MiB     9.44GiB 10.00GiB 0.00B
   Used                      5.34MiB   1.09MiB 16.00KiB

@KES777
Copy link
Author

KES777 commented Feb 17, 2025

Hi. @adam900710

  1. My versions:
$ btrfs --version
btrfs-progs v6.6.3

$ uname -a
Linux work 6.8.0-52-generic #53-Ubuntu SMP PREEMPT_DYNAMIC Sat Jan 11 00:06:25 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

The seed device was used under btrfs --version v5 or orlder (That one is shipped with Linux Mint 21.3). I recently upgraded the system. 1-2 weeks ago.

  1. You added the second device, why your output shows only one device?

  2. In my case the device was not empty.

    Device allocated:		 221.02GiB
    Used:			  20.40GiB

Overall delete operation took 20-30 min.
May you try sudo btrfs fi usage /mnt/btrfs/ -T command during btrfs device delete <device> operation?

@adam900710
Copy link
Collaborator

My versions:

Let me try with that version.

You added the second device, why your output shows only one device?

Because btrfs fi usage will skip seed device since it's not writable, thus makes no sense to output for any usage space.

In my case the device was not empty.

The same here, just less contents. Still no reproduce about the btrfs-progs crash.

@adam900710
Copy link
Collaborator

Tried that specific btrfs-progs, still no crash.

@KES777
Copy link
Author

KES777 commented Feb 17, 2025

Could it be related to the fact that btrfs was create with old tools, but I add device when they were upgraded to the version above?

@adam900710
Copy link
Collaborator

I tried the older mkfs configs (v1 cache, no no-holes etc), still the same.

If you can compile the btrfs-progs, please enable backtrace by ./configure --enable-backtrace so we can have a better clue.
Or even better, compile btrfs-progs with debuginfo so we can go proper debugger to know what's going wrong.

adam900710 added a commit to adam900710/linux that referenced this issue Feb 18, 2025
[BUG]
If btrfs failed to locate the seed device for whatever reason, mounting
the sprouted device will fail without any meaning error message:

 # mkfs.btrfs -f /dev/test/scratch1
 # btrfstune -S1 /dev/test/scratch1
 # mount /dev/test/scratch1 /mnt/btrfs
 # btrfs dev add -f /dev/test/scratch2 /mnt/btrfs
 # umount /mnt/btrfs
 # btrfs dev scan -u
 # btrfs mount /dev/test/scratch2 /mnt/btrfs
 mount: /mnt/btrfs: fsconfig system call failed: No such file or directory.
       dmesg(1) may have more information after failed mount system call.
 # dmesg -t | tail -n6
 BTRFS info (device dm-5): first mount of filesystem 64252ded-5953-4868-b962-cea48f7ac4ea
 BTRFS info (device dm-5): using crc32c (crc32c-generic) checksum algorithm
 BTRFS info (device dm-5): using free-space-tree
 BTRFS error (device dm-5): failed to read chunk tree: -2
 BTRFS error (device dm-5): open_ctree failed: -2

[CAUSE]
The failure to mount is pretty straight forward, just unable to find the
seed device and its fsid, caused by `btrfs dev scan -u`.

But the lack of any useful info is a problem.

[FIX]
Just add an extra error message in open_seed_devices() to indicate the
error.

Now the error message would look like this:

 BTRFS info (device dm-4): first mount of filesystem 7769223d-4db1-4e4c-ac29-0a96f53576ab
 BTRFS info (device dm-4): using crc32c (crc32c-generic) checksum algorithm
 BTRFS info (device dm-4): using free-space-tree
 BTRFS error (device dm-4): failed to find fsid e87c12e6-584b-4e98-8b88-962c33a619ff when attempting to open seed devices
 BTRFS error (device dm-4): failed to read chunk tree: -2
 BTRFS error (device dm-4): open_ctree failed: -2

Link: kdave/btrfs-progs#959
Reviewed-by: Anand Jain <[email protected]>
Signed-off-by: Qu Wenruo <[email protected]>
---
Changelog:
v2:
- Enhance the error message to show a little more details
- Remove the dmesg timestamp from commit message
adam900710 added a commit to btrfs/linux that referenced this issue Feb 19, 2025
[BUG]
If btrfs failed to locate the seed device for whatever reason, mounting
the sprouted device will fail without any meaning error message:

 # mkfs.btrfs -f /dev/test/scratch1
 # btrfstune -S1 /dev/test/scratch1
 # mount /dev/test/scratch1 /mnt/btrfs
 # btrfs dev add -f /dev/test/scratch2 /mnt/btrfs
 # umount /mnt/btrfs
 # btrfs dev scan -u
 # btrfs mount /dev/test/scratch2 /mnt/btrfs
 mount: /mnt/btrfs: fsconfig system call failed: No such file or directory.
       dmesg(1) may have more information after failed mount system call.
 # dmesg -t | tail -n6
 BTRFS info (device dm-5): first mount of filesystem 64252ded-5953-4868-b962-cea48f7ac4ea
 BTRFS info (device dm-5): using crc32c (crc32c-generic) checksum algorithm
 BTRFS info (device dm-5): using free-space-tree
 BTRFS error (device dm-5): failed to read chunk tree: -2
 BTRFS error (device dm-5): open_ctree failed: -2

[CAUSE]
The failure to mount is pretty straight forward, just unable to find the
seed device and its fsid, caused by `btrfs dev scan -u`.

But the lack of any useful info is a problem.

[FIX]
Just add an extra error message in open_seed_devices() to indicate the
error.

Now the error message would look like this:

 BTRFS info (device dm-4): first mount of filesystem 7769223d-4db1-4e4c-ac29-0a96f53576ab
 BTRFS info (device dm-4): using crc32c (crc32c-generic) checksum algorithm
 BTRFS info (device dm-4): using free-space-tree
 BTRFS error (device dm-4): failed to find fsid e87c12e6-584b-4e98-8b88-962c33a619ff when attempting to open seed devices
 BTRFS error (device dm-4): failed to read chunk tree: -2
 BTRFS error (device dm-4): open_ctree failed: -2

Link: kdave/btrfs-progs#959
Reviewed-by: Anand Jain <[email protected]>
Reviewed-by: Filipe Manana <[email protected]>
Signed-off-by: Qu Wenruo <[email protected]>
kdave pushed a commit to btrfs/linux that referenced this issue Feb 19, 2025
[BUG]
If btrfs failed to locate the seed device for whatever reason, mounting
the sprouted device will fail without any meaning error message:

  # mkfs.btrfs -f /dev/test/scratch1
  # btrfstune -S1 /dev/test/scratch1
  # mount /dev/test/scratch1 /mnt/btrfs
  # btrfs dev add -f /dev/test/scratch2 /mnt/btrfs
  # umount /mnt/btrfs
  # btrfs dev scan -u
  # btrfs mount /dev/test/scratch2 /mnt/btrfs
  mount: /mnt/btrfs: fsconfig system call failed: No such file or directory.
        dmesg(1) may have more information after failed mount system call.
  # dmesg -t | tail -n6
  BTRFS info (device dm-5): first mount of filesystem 64252ded-5953-4868-b962-cea48f7ac4ea
  BTRFS info (device dm-5): using crc32c (crc32c-generic) checksum algorithm
  BTRFS info (device dm-5): using free-space-tree
  BTRFS error (device dm-5): failed to read chunk tree: -2
  BTRFS error (device dm-5): open_ctree failed: -2

[CAUSE]
The failure to mount is pretty straight forward, just unable to find the
seed device and its fsid, caused by `btrfs dev scan -u`.

But the lack of any useful info is a problem.

[FIX]
Just add an extra error message in open_seed_devices() to indicate the
error.

Now the error message would look like this:

 BTRFS info (device dm-4): first mount of filesystem 7769223d-4db1-4e4c-ac29-0a96f53576ab
 BTRFS info (device dm-4): using crc32c (crc32c-generic) checksum algorithm
 BTRFS info (device dm-4): using free-space-tree
 BTRFS error (device dm-4): failed to find fsid e87c12e6-584b-4e98-8b88-962c33a619ff when attempting to open seed devices
 BTRFS error (device dm-4): failed to read chunk tree: -2
 BTRFS error (device dm-4): open_ctree failed: -2

Link: kdave/btrfs-progs#959
Reviewed-by: Anand Jain <[email protected]>
Reviewed-by: Filipe Manana <[email protected]>
Signed-off-by: Qu Wenruo <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
adam900710 added a commit to adam900710/linux that referenced this issue Feb 20, 2025
[BUG]
If btrfs failed to locate the seed device for whatever reason, mounting
the sprouted device will fail without any meaning error message:

 # mkfs.btrfs -f /dev/test/scratch1
 # btrfstune -S1 /dev/test/scratch1
 # mount /dev/test/scratch1 /mnt/btrfs
 # btrfs dev add -f /dev/test/scratch2 /mnt/btrfs
 # umount /mnt/btrfs
 # btrfs dev scan -u
 # btrfs mount /dev/test/scratch2 /mnt/btrfs
 mount: /mnt/btrfs: fsconfig system call failed: No such file or directory.
       dmesg(1) may have more information after failed mount system call.
 # dmesg -t | tail -n6
 BTRFS info (device dm-5): first mount of filesystem 64252ded-5953-4868-b962-cea48f7ac4ea
 BTRFS info (device dm-5): using crc32c (crc32c-generic) checksum algorithm
 BTRFS info (device dm-5): using free-space-tree
 BTRFS error (device dm-5): failed to read chunk tree: -2
 BTRFS error (device dm-5): open_ctree failed: -2

[CAUSE]
The failure to mount is pretty straight forward, just unable to find the
seed device and its fsid, caused by `btrfs dev scan -u`.

But the lack of any useful info is a problem.

[FIX]
Just add an extra error message in open_seed_devices() to indicate the
error.

Now the error message would look like this:

 BTRFS info (device dm-4): first mount of filesystem 7769223d-4db1-4e4c-ac29-0a96f53576ab
 BTRFS info (device dm-4): using crc32c (crc32c-generic) checksum algorithm
 BTRFS info (device dm-4): using free-space-tree
 BTRFS error (device dm-4): failed to find fsid e87c12e6-584b-4e98-8b88-962c33a619ff when attempting to open seed devices
 BTRFS error (device dm-4): failed to read chunk tree: -2
 BTRFS error (device dm-4): open_ctree failed: -2

Link: kdave/btrfs-progs#959
Reviewed-by: Anand Jain <[email protected]>
Reviewed-by: Filipe Manana <[email protected]>
Signed-off-by: Qu Wenruo <[email protected]>
---
Changelog:
v2:
- Enhance the error message to show a little more details
- Remove the dmesg timestamp from commit message
kdave pushed a commit to kdave/btrfs-devel that referenced this issue Feb 21, 2025
[BUG]
If btrfs failed to locate the seed device for whatever reason, mounting
the sprouted device will fail without any meaning error message:

  # mkfs.btrfs -f /dev/test/scratch1
  # btrfstune -S1 /dev/test/scratch1
  # mount /dev/test/scratch1 /mnt/btrfs
  # btrfs dev add -f /dev/test/scratch2 /mnt/btrfs
  # umount /mnt/btrfs
  # btrfs dev scan -u
  # btrfs mount /dev/test/scratch2 /mnt/btrfs
  mount: /mnt/btrfs: fsconfig system call failed: No such file or directory.
        dmesg(1) may have more information after failed mount system call.
  # dmesg -t | tail -n6
  BTRFS info (device dm-5): first mount of filesystem 64252ded-5953-4868-b962-cea48f7ac4ea
  BTRFS info (device dm-5): using crc32c (crc32c-generic) checksum algorithm
  BTRFS info (device dm-5): using free-space-tree
  BTRFS error (device dm-5): failed to read chunk tree: -2
  BTRFS error (device dm-5): open_ctree failed: -2

[CAUSE]
The failure to mount is pretty straight forward, just unable to find the
seed device and its fsid, caused by `btrfs dev scan -u`.

But the lack of any useful info is a problem.

[FIX]
Just add an extra error message in open_seed_devices() to indicate the
error.

Now the error message would look like this:

 BTRFS info (device dm-4): first mount of filesystem 7769223d-4db1-4e4c-ac29-0a96f53576ab
 BTRFS info (device dm-4): using crc32c (crc32c-generic) checksum algorithm
 BTRFS info (device dm-4): using free-space-tree
 BTRFS error (device dm-4): failed to find fsid e87c12e6-584b-4e98-8b88-962c33a619ff when attempting to open seed devices
 BTRFS error (device dm-4): failed to read chunk tree: -2
 BTRFS error (device dm-4): open_ctree failed: -2

Link: kdave/btrfs-progs#959
Reviewed-by: Anand Jain <[email protected]>
Reviewed-by: Filipe Manana <[email protected]>
Signed-off-by: Qu Wenruo <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
@KES777
Copy link
Author

KES777 commented Feb 23, 2025

Sorry, I am not able to compile.

@Forza-tng
Copy link
Contributor

Sorry, I am not able to compile.

Hi, you can download static versions of btrfs-progs from the releases page. The static version is a self-contained binary that requires no external dependencies (other than kernel). You can run it directly and it requires no installation.

The v6.6.3 version is available at https://github.com/kdave/btrfs-progs/releases/tag/v6.6.3
The most recent version (6.13) is available from https://github.com/kdave/btrfs-progs/releases/tag/v6.13

I made a static version of v6.6.3 with debug and --enable-backtrace if you would like to try that one.
https://mirrors.tnonline.net/btrfs/btrfs-progs/x86_64/debug/btrfs-progs-6.6.3-x86_64-static/

This is the configure output:

./configure --disable-shared --disable-documentation --enable-backtrace --disable-convert

        btrfs-progs:        v6.6.3
        libbtrfs:           0.1.2 (deprecated)
        libbtrfsutil:       1.2.0
        prefix:             /usr/local
        exec prefix:        ${prefix}
        bindir:             ${exec_prefix}/bin
        libdir:             ${exec_prefix}/lib
        includedir:         ${prefix}/include
        pkgconfigdir:       ${libdir}/pkgconfig
        compiler:           gcc
        CFLAGS:             -march=x86-64 -g -ggdb
        LDFLAGS:
        programs:           yes
        shared libraries:   no
        static libraries:   yes
        documentation:      no
        doc generator:      none
        backtrace support:  yes
        btrfs-convert:      no
        zstd support:       yes
        lzo support:        yes
        fsverity support:   yes
        Python bindings:    no
        Python interpreter:
        crypto provider:    builtin
        libudev:            yes
        zoned device:       yes

@KES777
Copy link
Author

KES777 commented Feb 25, 2025

@Forza-tng Ok. I have two questions:

  1. How to install it?
  2. Because balance was finished I do not see the error after that. How to test?

@Forza-tng
Copy link
Contributor

Forza-tng commented Feb 25, 2025

@Forza-tng Ok. I have two questions:

  1. How to install it?

It requires no installation. Simply unpack and run the btrfs.static file.

❯ ./btrfs.static fi us /
Overall:
    Device size:                 203.89GiB
    Device allocated:            128.06GiB
    Device unallocated:           75.82GiB
    Device missing:                  0.00B
    Device slack:                 24.00GiB
    Used:                        107.15GiB
    Free (estimated):             83.65GiB      (min: 45.74GiB)
    Free (statfs, df):            83.65GiB
    Data ratio:                       1.00
    Metadata ratio:                   2.00
    Global reserve:              512.00MiB      (used: 0.00B)
    Multiple profiles:                  no
Data,single: Size:104.00GiB, Used:96.17GiB (92.47%)
   /dev/nvme0n1p5        104.00GiB
Metadata,DUP: Size:12.00GiB, Used:5.49GiB (45.75%)
   /dev/nvme0n1p5         24.00GiB
System,DUP: Size:32.00MiB, Used:16.00KiB (0.05%)
   /dev/nvme0n1p5         64.00MiB
Unallocated:
   /dev/nvme0n1p5         75.82GiB

@adam900710 Is there any other option you wanted the btrfs-progs compiled with?

kdave pushed a commit to btrfs/linux that referenced this issue Feb 25, 2025
[BUG]
If btrfs failed to locate the seed device for whatever reason, mounting
the sprouted device will fail without any meaning error message:

  # mkfs.btrfs -f /dev/test/scratch1
  # btrfstune -S1 /dev/test/scratch1
  # mount /dev/test/scratch1 /mnt/btrfs
  # btrfs dev add -f /dev/test/scratch2 /mnt/btrfs
  # umount /mnt/btrfs
  # btrfs dev scan -u
  # btrfs mount /dev/test/scratch2 /mnt/btrfs
  mount: /mnt/btrfs: fsconfig system call failed: No such file or directory.
        dmesg(1) may have more information after failed mount system call.
  # dmesg -t | tail -n6
  BTRFS info (device dm-5): first mount of filesystem 64252ded-5953-4868-b962-cea48f7ac4ea
  BTRFS info (device dm-5): using crc32c (crc32c-generic) checksum algorithm
  BTRFS info (device dm-5): using free-space-tree
  BTRFS error (device dm-5): failed to read chunk tree: -2
  BTRFS error (device dm-5): open_ctree failed: -2

[CAUSE]
The failure to mount is pretty straight forward, just unable to find the
seed device and its fsid, caused by `btrfs dev scan -u`.

But the lack of any useful info is a problem.

[FIX]
Just add an extra error message in open_seed_devices() to indicate the
error.

Now the error message would look like this:

 BTRFS info (device dm-4): first mount of filesystem 7769223d-4db1-4e4c-ac29-0a96f53576ab
 BTRFS info (device dm-4): using crc32c (crc32c-generic) checksum algorithm
 BTRFS info (device dm-4): using free-space-tree
 BTRFS error (device dm-4): failed to find fsid e87c12e6-584b-4e98-8b88-962c33a619ff when attempting to open seed devices
 BTRFS error (device dm-4): failed to read chunk tree: -2
 BTRFS error (device dm-4): open_ctree failed: -2

Link: kdave/btrfs-progs#959
Reviewed-by: Anand Jain <[email protected]>
Reviewed-by: Filipe Manana <[email protected]>
Signed-off-by: Qu Wenruo <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants