GNU bug report logs - #25573
Adding btrfs support may break reconfigured system

Previous Next

Package: guix;

Reported by: Alex Kost <alezost <at> gmail.com>

Date: Sun, 29 Jan 2017 18:05:01 UTC

Severity: important

Done: ludo <at> gnu.org (Ludovic Courtès)

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 25573 in the body.
You can then email your comments to 25573 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#25573; Package guix. (Sun, 29 Jan 2017 18:05:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alex Kost <alezost <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Sun, 29 Jan 2017 18:05:02 GMT) Full text and rfc822 format available.

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

From: Alex Kost <alezost <at> gmail.com>
To: bug-guix <at> gnu.org
Subject: Adding btrfs support may break reconfigured system
Date: Sun, 29 Jan 2017 21:03:56 +0300
[Message part 1 (text/plain, inline)]
Hello, recently I found that "guix system" makes a "broken" system for
me.  When I boot a freshly created system, I get something like this:

  In procedure <...> at ./gnu/build/file-systems.scm:282:4 (device)
  In procedure fport_seek: Invalid argument

and I'm thrown at the Guile promt.

The same problem (well, I think it's the same) was also reported by
roptat on #guix:

  https://gnunet.org/bot/log/guix/2017-01-28#T1277485

After bisecting the guix git checkout, I found that commit b1a505baf6¹
was the first one where my system starts to fail.  And indeed when I
reverted this commit on the latest master, guix built a working system.
Moreover, the following simple diff (it's a partial revert of that
commit) "fixes" guix for me:

[fix-btrfs.diff (text/x-diff, inline)]
diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index 6e5c6aa..f05e035 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -294,15 +294,11 @@ partition field reader that returned a value."
 
 (define %partition-label-readers
   (list (partition-field-reader read-ext2-superblock
-                                ext2-superblock-volume-name)
-        (partition-field-reader read-btrfs-superblock
-                                btrfs-superblock-volume-name)))
+                                ext2-superblock-volume-name)))
 
 (define %partition-uuid-readers
   (list (partition-field-reader read-ext2-superblock
-                                ext2-superblock-uuid)
-        (partition-field-reader read-btrfs-superblock
-                                btrfs-superblock-uuid)))
+                                ext2-superblock-uuid)))
 
 (define read-partition-label
   (cut read-partition-field <> %partition-label-readers))
[Message part 3 (text/plain, inline)]
I don't have btrfs anywhere (only ext4).  During bisecting experiments I
used the attached system config (but the config shouldn't matter I think
as I tried various variants, and all gave me the same result).

Any idea how to dig further?  Perhaps there is something I can do in the
Guile prompt.

¹ http://git.savannah.gnu.org/cgit/guix.git/commit/?id=b1a505baf61cc771197eb44af9173f31d2bace46

[bare-bones.scm (text/x-scheme, attachment)]

Information forwarded to bug-guix <at> gnu.org:
bug#25573; Package guix. (Mon, 30 Jan 2017 09:43:02 GMT) Full text and rfc822 format available.

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

From: ludo <at> gnu.org (Ludovic Courtès)
To: Alex Kost <alezost <at> gmail.com>
Cc: 25573 <at> debbugs.gnu.org
Subject: Re: bug#25573: Adding btrfs support may break reconfigured system
Date: Mon, 30 Jan 2017 10:41:49 +0100
[Message part 1 (text/plain, inline)]
Hi,

Alex Kost <alezost <at> gmail.com> skribis:

> Hello, recently I found that "guix system" makes a "broken" system for
> me.  When I boot a freshly created system, I get something like this:
>
>   In procedure <...> at ./gnu/build/file-systems.scm:282:4 (device)
>   In procedure fport_seek: Invalid argument
>
> and I'm thrown at the Guile promt.

I think this is due to ‘read-superblock’ trying to seek beyond the end
of one of the devices that’s on your machine.

Could you try the attached patch and see if it solves the problem?

Thanks for reporting it!

Ludo’.

[Message part 2 (text/x-patch, inline)]
diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index 6e5c6aaf1..f8ab95370 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2016, 2017 David Craven <david <at> craven.ch>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -72,14 +72,25 @@
   "Bind-mount SOURCE at TARGET."
   (mount source target "" MS_BIND))
 
+(define (seek* fd/port offset whence)
+  "Like 'seek' but return -1 instead of throwing to 'system-error' upon
+EINVAL.  This makes it easier to catch cases like OFFSET being too large for
+FD/PORT."
+  (catch 'system-error
+    (lambda ()
+      (seek fd/port offset whence))
+    (lambda args
+      (if (= EINVAL (system-error-errno args))
+          -1
+          (apply throw args)))))
+
 (define (read-superblock device offset size magic?)
   "Read a superblock of SIZE from OFFSET and DEVICE.  Return the raw
 superblock on success, and #f if no valid superblock was found.  MAGIC?
 takes a bytevector and returns #t when it's a valid superblock."
   (call-with-input-file device
     (lambda (port)
-      (seek port offset SEEK_SET)
-
+      (and (= offset (seek* port offset SEEK_SET))
            (let ((block (make-bytevector size)))
              (match (get-bytevector-n! port block 0 (bytevector-length block))
                ((? eof-object?)
@@ -87,7 +98,7 @@ takes a bytevector and returns #t when it's a valid superblock."
                ((? number? len)
                 (and (= len (bytevector-length block))
                      (and (magic? block)
-                     block))))))))
+                          block)))))))))
 
 (define (sub-bytevector bv start size)
   "Return a copy of the SIZE bytes of BV starting from offset START."

Severity set to 'important' from 'normal' Request was from ludo <at> gnu.org (Ludovic Courtès) to control <at> debbugs.gnu.org. (Mon, 30 Jan 2017 22:27:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-guix <at> gnu.org:
bug#25573; Package guix. (Tue, 31 Jan 2017 17:30:02 GMT) Full text and rfc822 format available.

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

From: Alex Kost <alezost <at> gmail.com>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 25573 <at> debbugs.gnu.org
Subject: Re: bug#25573: Adding btrfs support may break reconfigured system
Date: Tue, 31 Jan 2017 20:29:45 +0300
Ludovic Courtès (2017-01-30 10:41 +0100) wrote:

> Hi,
>
> Alex Kost <alezost <at> gmail.com> skribis:
>
>> Hello, recently I found that "guix system" makes a "broken" system for
>> me.  When I boot a freshly created system, I get something like this:
>>
>>   In procedure <...> at ./gnu/build/file-systems.scm:282:4 (device)
>>   In procedure fport_seek: Invalid argument
>>
>> and I'm thrown at the Guile promt.
>
> I think this is due to ‘read-superblock’ trying to seek beyond the end
> of one of the devices that’s on your machine.
>
> Could you try the attached patch and see if it solves the problem?

Yes, guix makes a bootable system with this modification, thank you!

> Thanks for reporting it!

Thanks for fixing it! :-)

-- 
Alex




Reply sent to ludo <at> gnu.org (Ludovic Courtès):
You have taken responsibility. (Tue, 31 Jan 2017 22:24:01 GMT) Full text and rfc822 format available.

Notification sent to Alex Kost <alezost <at> gmail.com>:
bug acknowledged by developer. (Tue, 31 Jan 2017 22:24:02 GMT) Full text and rfc822 format available.

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

From: ludo <at> gnu.org (Ludovic Courtès)
To: Alex Kost <alezost <at> gmail.com>
Cc: 25573-done <at> debbugs.gnu.org
Subject: Re: bug#25573: Adding btrfs support may break reconfigured system
Date: Tue, 31 Jan 2017 23:23:07 +0100
Alex Kost <alezost <at> gmail.com> skribis:

> Ludovic Courtès (2017-01-30 10:41 +0100) wrote:
>
>> Hi,
>>
>> Alex Kost <alezost <at> gmail.com> skribis:
>>
>>> Hello, recently I found that "guix system" makes a "broken" system for
>>> me.  When I boot a freshly created system, I get something like this:
>>>
>>>   In procedure <...> at ./gnu/build/file-systems.scm:282:4 (device)
>>>   In procedure fport_seek: Invalid argument
>>>
>>> and I'm thrown at the Guile promt.
>>
>> I think this is due to ‘read-superblock’ trying to seek beyond the end
>> of one of the devices that’s on your machine.
>>
>> Could you try the attached patch and see if it solves the problem?
>
> Yes, guix makes a bootable system with this modification, thank you!

Fixed in 2fe4ceee18f8687de8520d28dbfefc7bc3a7e084, thanks for testing!

Ludo’.




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

This bug report was last modified 7 years and 29 days ago.

Previous Next


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