GNU bug report logs - #38435
BTRFS open_ctree failed

Previous Next

Package: guix;

Reported by: raingloom <raingloom <at> riseup.net>

Date: Sat, 30 Nov 2019 13:47:01 UTC

Severity: normal

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 38435 in the body.
You can then email your comments to 38435 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#38435; Package guix. (Sat, 30 Nov 2019 13:47:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to raingloom <raingloom <at> riseup.net>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Sat, 30 Nov 2019 13:47:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: raingloom <raingloom <at> riseup.net>
To: bug-guix <at> gnu.org
Subject: BTRFS open_ctree failed
Date: Sat, 30 Nov 2019 14:45:39 +0100
This is what I get after a recent `guix system reconfigure` :
Scanning for Btrfs filesystems
[    2.342790] BTRFS error (device sda1): open_ctree failed

Previous profiles work, I haven't modified anything about my config.scm
between them.

Full output from kernel (taken by booting it from QEMU and redirecting
ttyS0 to stdio):
```
qemu-system-x86_64 -enable-kvm -cpu host -smp 2 -hda /dev/sda -m 1G
-serial stdio WARNING: Image format was not specified for '/dev/sda'
and probing guessed raw. Automatically detecting the format is
dangerous for raw images, write operations on block 0 will be
restricted. Specify the 'raw' format explicitly to remove the
restrictions. GC Warning: pthread_getattr_np or pthread_attr_getstack
failed for main thread GC Warning: Couldn't read /proc/stat Welcome,
this is GNU's early boot Guile. Use '--repl' for an initrd REPL.

loading kernel modules...
Scanning for Btrfs filesystems
[    2.342790] BTRFS error (device sda1): open_ctree failed
ERROR: In procedure mount:
In procedure mount: Invalid argument

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
GNU Guile 2.2.6
Copyright (C) 1995-2019 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> ,bt
In gnu/build/linux-boot.scm:
   533:14  2 (_)
    387:8  1 (mount-root-file-system _ _ #:volatile-root? _ #:options …)
In unknown file:
           0 (mount "/dev/sda1" "/root" "btrfs" 0 "lazytime,compress")
scheme@(guile-user)> ,q  
[   42.345826] Kernel panic - not syncing: Attempted to kill init!
```
(rest of stack trace snipped for brevity's sake)

output of `guix describe` as root:
```
Generation 26	Nov 29 2019 21:22:41	(current)
  nonguix 2df6923
    repository URL: https://gitlab.com/nonguix/nonguix.git
    branch: master
    commit: 2df692312100ac5bea9ed8e8bf0032e6db100e91
  guix dac7928
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: dac7928d502d9ba4fc6a9621e5b2b15019d92d5b
```

Contents of /etc/profile.scm:

```
(define use-proprietary-crap? #f)

(use-modules (gnu)
	     (gnu system nss)
	     (gnu packages shells)
	     (gnu packages package-management)
	     (gnu packages gnome))

(if use-proprietary-crap?
    (use-modules (nongnu packages linux))
    (use-modules (gnu packages linux)))

(use-service-modules desktop ssh nix)
(use-package-modules
 bootloaders
 certs
 ratpoison
 suckless
 wm)

(operating-system
  (host-name "bingobongo")
  (timezone "Europe/Budapest")
  (locale "en_US.utf8")
  (kernel
   (if use-proprietary-crap?
       linux
       linux-libre))
  (firmware (append
	     (if use-proprietary-crap?
		 (list iwlwifi-firmware)
		 '())
	     %base-firmware))

  ;; Use the UEFI variant of GRUB with the EFI System
  ;; Partition mounted on /boot/efi.
  (bootloader (bootloader-configuration
                (bootloader grub-bootloader)
                (target "/dev/sda")))

  ;; Assume the target root file system is labelled "my-root",
  ;; and the EFI System Partition has UUID 1234-ABCD.
  (file-systems (cons* (file-system
                         (device (file-system-label "GUIX"))
                         (mount-point "/")
			 (options "lazytime,compress")
                         (type "btrfs"))
                       ;(file-system
                       ;  (device (uuid "1234-ABCD" 'fat))
                       ;  (mount-point "/boot/efi")
                       ;  (type "vfat"))
                       %base-file-systems))

  (users (append (list
		  (user-account
		   (name "raingloom")
		   (comment "your friendly localhost admin")
		   (group "users")
		   (shell "/run/current-system/profile/bin/zsh")
		   (supplementary-groups '("wheel" "netdev" "audio"
  "video" "kvm")) (home-directory "/home/raingloom")))
               %base-user-accounts))

  ;; Add a bunch of window managers; we can choose one at
  ;; the log-in screen with F1.
  (packages (cons* i3-wm i3status dmenu ;window managers
                   nss-certs            ;for HTTPS access
                   zsh                  ;nicer login shell
                   gvfs
                   nix
                   gnome
                   orca
                   %base-packages))

  ;; Use the "desktop" services, which include the X11
  ;; log-in service, networking with NetworkManager, and more.
  (services
   (append (list (service nix-service-type) (service
  openssh-service-type (openssh-configuration (x11-forwarding? #t))))
  (modify-services %desktop-services
	    (elogind-service-type config =>
				  (elogind-configuration
				   (inherit config)
				   (handle-lid-switch 'ignore))))))

  ;; Allow resolution of '.local' host names with mDNS.
  (name-service-switch %mdns-host-lookup-nss))
```




Information forwarded to bug-guix <at> gnu.org:
bug#38435; Package guix. (Sat, 30 Nov 2019 14:54:02 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Guillaume Le Vaillant <glv <at> posteo.net>
To: bug-guix <at> gnu.org
Cc: 38435 <at> debbugs.gnu.org
Subject: Re: bug#38435: BTRFS open_ctree failed
Date: Sat, 30 Nov 2019 15:53:11 +0100
raingloom skribis:

> This is what I get after a recent `guix system reconfigure` :
> Scanning for Btrfs filesystems
> [    2.342790] BTRFS error (device sda1): open_ctree failed
>
> Previous profiles work, I haven't modified anything about my config.scm
> between them.
>
> [...]
>
>
> Contents of /etc/profile.scm:
>
> [...]
>
>   (file-systems (cons* (file-system
>                          (device (file-system-label "GUIX"))
>                          (mount-point "/")
> 			 (options "lazytime,compress")
>                          (type "btrfs"))
>                        ;(file-system
>                        ;  (device (uuid "1234-ABCD" 'fat))
>                        ;  (mount-point "/boot/efi")
>                        ;  (type "vfat"))
>                        %base-file-systems))
>

I just tried adding the 'lazytime' option to my root file system, and
I got the same error as you when booting. Could you try removing it and
see if it works?

Until recently, the options declared in 'file-system' records were
always ignored when mounting the root file system. Now they are taken
into consideration, and I think it reveals a bug in the way file systems
are mounted. If some options like 'lazytime' or 'defaults' are declared
in a 'file-system' record (root file system or not), mounting it fails.
However some other options like 'compress' or 'autodefrag' work fine.

I suspect Guix adds some options by default when trying to mount file
systems, and maybe we end up with conflicting options or doubled options
that cause problems.




Information forwarded to bug-guix <at> gnu.org:
bug#38435; Package guix. (Sat, 30 Nov 2019 14:54:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-guix <at> gnu.org:
bug#38435; Package guix. (Sat, 30 Nov 2019 16:02:01 GMT) Full text and rfc822 format available.

Message #14 received at 38435 <at> debbugs.gnu.org (full text, mbox):

From: Guillaume Le Vaillant <glv <at> posteo.net>
To: 38435 <at> debbugs.gnu.org
Cc: raingloom <raingloom <at> riseup.net>
Subject: Re: bug#38435: BTRFS open_ctree failed
Date: Sat, 30 Nov 2019 17:01:08 +0100
Guillaume Le Vaillant skribis:

> raingloom skribis:
>
>> This is what I get after a recent `guix system reconfigure` :
>> Scanning for Btrfs filesystems
>> [    2.342790] BTRFS error (device sda1): open_ctree failed
>>
>> Previous profiles work, I haven't modified anything about my config.scm
>> between them.
>>
>> [...]
>>
>>
>> Contents of /etc/profile.scm:
>>
>> [...]
>>
>>   (file-systems (cons* (file-system
>>                          (device (file-system-label "GUIX"))
>>                          (mount-point "/")
>> 			 (options "lazytime,compress")
>>                          (type "btrfs"))
>>                        ;(file-system
>>                        ;  (device (uuid "1234-ABCD" 'fat))
>>                        ;  (mount-point "/boot/efi")
>>                        ;  (type "vfat"))
>>                        %base-file-systems))
>>
>
> I just tried adding the 'lazytime' option to my root file system, and
> I got the same error as you when booting. Could you try removing it and
> see if it works?
>
> Until recently, the options declared in 'file-system' records were
> always ignored when mounting the root file system. Now they are taken
> into consideration, and I think it reveals a bug in the way file systems
> are mounted. If some options like 'lazytime' or 'defaults' are declared
> in a 'file-system' record (root file system or not), mounting it fails.
> However some other options like 'compress' or 'autodefrag' work fine.
>
> I suspect Guix adds some options by default when trying to mount file
> systems, and maybe we end up with conflicting options or doubled options
> that cause problems.

Apparently, Guix uses the 'mount' system call directly to mount file
systems (c.f. 'guix/build/syscalls.scm'), and passes all the options
declared in the 'file-system' records in the 'data' argument.

However the man page for mount(2) indicates:

--8<---------------cut here---------------start------------->8---
int mount(const char *source, const char *target,
                const char *filesystemtype, unsigned long mountflags,
                const void *data);

[...]

The data argument is interpreted by the different filesystems.
Typically it is a string of comma-separated options understood by this
filesystem.  See mount(8) for details of the options available for each
filesystem type.
--8<---------------cut here---------------end--------------->8---

If I understand correcly, the generic options (e.g. 'lazytime') must be
passed in 'mountflags', and the options specific to the file system
(e.g. 'compress') must be passed in 'data'.

This would mean that before calling the 'mount' system call, we must
remove the generic options from the 'options' variable (which is then
passed in 'data'), and add their corresponding flags to the 'flags'
variable (which is then passed in 'mountflags').

What do you think?




Information forwarded to bug-guix <at> gnu.org:
bug#38435; Package guix. (Sun, 01 Dec 2019 11:04:02 GMT) Full text and rfc822 format available.

Message #17 received at 38435 <at> debbugs.gnu.org (full text, mbox):

From: raingloom <raingloom <at> riseup.net>
To: 38435 <at> debbugs.gnu.org
Subject: Re: bug#38435: BTRFS open_ctree failed
Date: Sun, 1 Dec 2019 12:02:51 +0100
On Sat, 30 Nov 2019 15:53:11 +0100
Guillaume Le Vaillant <glv <at> posteo.net> wrote:

> raingloom skribis:
> 
> > This is what I get after a recent `guix system reconfigure` :
> > Scanning for Btrfs filesystems
> > [    2.342790] BTRFS error (device sda1): open_ctree failed
> >
> > Previous profiles work, I haven't modified anything about my
> > config.scm between them.
> >
> > [...]
> >
> >
> > Contents of /etc/profile.scm:
> >
> > [...]
> >
> >   (file-systems (cons* (file-system
> >                          (device (file-system-label "GUIX"))
> >                          (mount-point "/")
> > 			 (options "lazytime,compress")
> >                          (type "btrfs"))
> >                        ;(file-system
> >                        ;  (device (uuid "1234-ABCD" 'fat))
> >                        ;  (mount-point "/boot/efi")
> >                        ;  (type "vfat"))
> >                        %base-file-systems))
> >  
> 
> I just tried adding the 'lazytime' option to my root file system, and
> I got the same error as you when booting. Could you try removing it
> and see if it works?
> 
> Until recently, the options declared in 'file-system' records were
> always ignored when mounting the root file system. Now they are taken
> into consideration, and I think it reveals a bug in the way file
> systems are mounted. If some options like 'lazytime' or 'defaults'
> are declared in a 'file-system' record (root file system or not),
> mounting it fails. However some other options like 'compress' or
> 'autodefrag' work fine.
> 
> I suspect Guix adds some options by default when trying to mount file
> systems, and maybe we end up with conflicting options or doubled
> options that cause problems.
> 
> 
> 

I removed it and ran reconfigure and now it works.




Information forwarded to bug-guix <at> gnu.org:
bug#38435; Package guix. (Tue, 03 Dec 2019 09:49:02 GMT) Full text and rfc822 format available.

Message #20 received at 38435 <at> debbugs.gnu.org (full text, mbox):

From: Guillaume Le Vaillant <glv <at> posteo.net>
To: raingloom <raingloom <at> riseup.net>
Cc: 38435 <at> debbugs.gnu.org
Subject: Re: bug#38435: BTRFS open_ctree failed
Date: Tue, 03 Dec 2019 10:47:48 +0100
raingloom skribis:

> On Sat, 30 Nov 2019 15:53:11 +0100
> Guillaume Le Vaillant <glv <at> posteo.net> wrote:
>
>> raingloom skribis:
>> 
>> > This is what I get after a recent `guix system reconfigure` :
>> > Scanning for Btrfs filesystems
>> > [    2.342790] BTRFS error (device sda1): open_ctree failed
>> >
>> > Previous profiles work, I haven't modified anything about my
>> > config.scm between them.
>> >
>> > [...]
>> >
>> >
>> > Contents of /etc/profile.scm:
>> >
>> > [...]
>> >
>> >   (file-systems (cons* (file-system
>> >                          (device (file-system-label "GUIX"))
>> >                          (mount-point "/")
>> > 			 (options "lazytime,compress")
>> >                          (type "btrfs"))
>> >                        ;(file-system
>> >                        ;  (device (uuid "1234-ABCD" 'fat))
>> >                        ;  (mount-point "/boot/efi")
>> >                        ;  (type "vfat"))
>> >                        %base-file-systems))
>> >  
>> 
>> I just tried adding the 'lazytime' option to my root file system, and
>> I got the same error as you when booting. Could you try removing it
>> and see if it works?
>> 
>> Until recently, the options declared in 'file-system' records were
>> always ignored when mounting the root file system. Now they are taken
>> into consideration, and I think it reveals a bug in the way file
>> systems are mounted. If some options like 'lazytime' or 'defaults'
>> are declared in a 'file-system' record (root file system or not),
>> mounting it fails. However some other options like 'compress' or
>> 'autodefrag' work fine.
>> 
>> I suspect Guix adds some options by default when trying to mount file
>> systems, and maybe we end up with conflicting options or doubled
>> options that cause problems.
>> 
>> 
>> 
>
> I removed it and ran reconfigure and now it works.

Applying patches #38462 and #38468 and changing the file system
definition to the following should allow you to mount the root file
system with the 'lazytime' option:

--8<---------------cut here---------------start------------->8---
(file-system
  (device (file-system-label "GUIX"))
  (mount-point "/")
  (flags '(lazy-time))
  (options "compress")
  (type "btrfs"))
--8<---------------cut here---------------end--------------->8---




Information forwarded to bug-guix <at> gnu.org:
bug#38435; Package guix. (Tue, 18 Feb 2020 16:31:02 GMT) Full text and rfc822 format available.

Message #23 received at 38435 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Guillaume Le Vaillant <glv <at> posteo.net>
Cc: 38435 <at> debbugs.gnu.org
Subject: Re: bug#38435: BTRFS open_ctree failed
Date: Tue, 18 Feb 2020 11:29:53 -0500
Hello,

Guillaume Le Vaillant <glv <at> posteo.net> writes:

> raingloom skribis:
>
>> This is what I get after a recent `guix system reconfigure` :
>> Scanning for Btrfs filesystems
>> [    2.342790] BTRFS error (device sda1): open_ctree failed
>>
>> Previous profiles work, I haven't modified anything about my config.scm
>> between them.
>>
>> [...]
>>
>>
>> Contents of /etc/profile.scm:
>>
>> [...]
>>
>>   (file-systems (cons* (file-system
>>                          (device (file-system-label "GUIX"))
>>                          (mount-point "/")
>> 			 (options "lazytime,compress")
>>                          (type "btrfs"))
>>                        ;(file-system
>>                        ;  (device (uuid "1234-ABCD" 'fat))
>>                        ;  (mount-point "/boot/efi")
>>                        ;  (type "vfat"))
>>                        %base-file-systems))
>>
>
> I just tried adding the 'lazytime' option to my root file system, and
> I got the same error as you when booting. Could you try removing it and
> see if it works?
>
> Until recently, the options declared in 'file-system' records were
> always ignored when mounting the root file system. Now they are taken
> into consideration, and I think it reveals a bug in the way file systems
> are mounted. If some options like 'lazytime' or 'defaults' are declared
> in a 'file-system' record (root file system or not), mounting it fails.
> However some other options like 'compress' or 'autodefrag' work fine.
>
> I suspect Guix adds some options by default when trying to mount file
> systems, and maybe we end up with conflicting options or doubled options
> that cause problems.

The problem here is that "lazytime" is a file system independent mount
options (see FILESYSTEM-INDEPENDENT MOUNT OPTIONS in 'man 8 mount'),
which is not understood by the Btrfs file system driver itself.

Currently Guix targets mount(2) through its file-system record API,
although this could be easily abused before (because the options were
not passed to the `mount-file-system' calls that the init RAM disk
uses).

This leaves some work to be done though, as if we target mount(2), we
need some glue code to translate mount(2) flags into mount(8) file
system independent mount options (otherwise you wouldn't be able to have
'lazytime' in your /etc/fstab).

I have a partial solution posted for review here:
https://lists.gnu.org/archive/html/guix-patches/2020-02/msg00382.html,
in the patch:
https://lists.gnu.org/archive/html/guix-patches/2020-02/msg00382.html.
Currently it filters out the file system independent mount options
before passing the options to `mount-file-system'.

Comments or patches welcome!




Reply sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
You have taken responsibility. (Mon, 01 Feb 2021 19:17:02 GMT) Full text and rfc822 format available.

Notification sent to raingloom <raingloom <at> riseup.net>:
bug acknowledged by developer. (Mon, 01 Feb 2021 19:17:02 GMT) Full text and rfc822 format available.

Message #28 received at 38435-done <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Guillaume Le Vaillant <glv <at> posteo.net>
Cc: 38435-done <at> debbugs.gnu.org, raingloom <raingloom <at> riseup.net>
Subject: Re: bug#38435: BTRFS open_ctree failed
Date: Mon, 01 Feb 2021 14:16:10 -0500
Hello,

Guillaume Le Vaillant <glv <at> posteo.net> writes:

[...]

>>> >   (file-systems (cons* (file-system
>>> >                          (device (file-system-label "GUIX"))
>>> >                          (mount-point "/")
>>> > 			 (options "lazytime,compress")
>>> >                          (type "btrfs"))
>>> >                        ;(file-system
>>> >                        ;  (device (uuid "1234-ABCD" 'fat))
>>> >                        ;  (mount-point "/boot/efi")
>>> >                        ;  (type "vfat"))
>>> >                        %base-file-systems))
>>> >  
>>> 
>>> I just tried adding the 'lazytime' option to my root file system, and
>>> I got the same error as you when booting. Could you try removing it
>>> and see if it works?
>>> 
>>> Until recently, the options declared in 'file-system' records were
>>> always ignored when mounting the root file system. Now they are taken
>>> into consideration, and I think it reveals a bug in the way file
>>> systems are mounted. If some options like 'lazytime' or 'defaults'
>>> are declared in a 'file-system' record (root file system or not),
>>> mounting it fails. However some other options like 'compress' or
>>> 'autodefrag' work fine.
>>> 
>>> I suspect Guix adds some options by default when trying to mount file
>>> systems, and maybe we end up with conflicting options or doubled
>>> options that cause problems.
>>> 
>>> 
>>> 
>>
>> I removed it and ran reconfigure and now it works.
>
> Applying patches #38462 and #38468 and changing the file system
> definition to the following should allow you to mount the root file
> system with the 'lazytime' option:
>
> (file-system
>   (device (file-system-label "GUIX"))
>   (mount-point "/")
>   (flags '(lazy-time))
>   (options "compress")
>   (type "btrfs"))

I see these earlier patches of yours got merged already and the original
issue addressed.

Thank you!

Closing.

Maxim




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 02 Mar 2021 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 56 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.