unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#25573: Adding btrfs support may break reconfigured system
@ 2017-01-29 18:03 Alex Kost
  2017-01-30  9:41 ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Kost @ 2017-01-29 18:03 UTC (permalink / raw)
  To: 25573

[-- Attachment #1: Type: text/plain, Size: 761 bytes --]

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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fix-btrfs.diff --]
[-- Type: text/x-diff, Size: 975 bytes --]

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))

[-- Attachment #3: Type: text/plain, Size: 407 bytes --]


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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: bare-bones.scm --]
[-- Type: text/x-scheme, Size: 918 bytes --]

(use-modules (gnu))

(operating-system
  (host-name "leviafan")
  (timezone "Europe/Moscow")
  (locale "en_US.utf8")
  (bootloader (grub-configuration (device "/dev/sda")))
  (initrd (lambda (fs . args)
            (apply base-initrd fs
                   #:extra-modules '("sata_nv") ; for my HDD
                   args)))
  (file-systems (cons (file-system
                        (device "guix")
                        (title 'label)
                        (mount-point "/")
                        (type "ext4"))
                      %base-file-systems))
  (users (cons (user-account
                (name "al")
                (group "users")
                (supplementary-groups '("wheel" "audio" "video"))
                (home-directory "/home/al"))
               %base-user-accounts))
  (packages %base-packages)
  (services (cons* (console-keymap-service "dvorak")
                   %base-services)))

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#25573: Adding btrfs support may break reconfigured system
  2017-01-29 18:03 bug#25573: Adding btrfs support may break reconfigured system Alex Kost
@ 2017-01-30  9:41 ` Ludovic Courtès
  2017-01-31 17:29   ` Alex Kost
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2017-01-30  9:41 UTC (permalink / raw)
  To: Alex Kost; +Cc: 25573

[-- Attachment #1: Type: text/plain, Size: 597 bytes --]

Hi,

Alex Kost <alezost@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’.


[-- Attachment #2: Type: text/x-patch, Size: 1988 bytes --]

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@gnu.org>
+;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016, 2017 David Craven <david@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."

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#25573: Adding btrfs support may break reconfigured system
  2017-01-30  9:41 ` Ludovic Courtès
@ 2017-01-31 17:29   ` Alex Kost
  2017-01-31 22:23     ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Kost @ 2017-01-31 17:29 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 25573

Ludovic Courtès (2017-01-30 10:41 +0100) wrote:

> Hi,
>
> Alex Kost <alezost@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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#25573: Adding btrfs support may break reconfigured system
  2017-01-31 17:29   ` Alex Kost
@ 2017-01-31 22:23     ` Ludovic Courtès
  0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2017-01-31 22:23 UTC (permalink / raw)
  To: Alex Kost; +Cc: 25573-done

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2017-01-30 10:41 +0100) wrote:
>
>> Hi,
>>
>> Alex Kost <alezost@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’.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-01-31 22:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-29 18:03 bug#25573: Adding btrfs support may break reconfigured system Alex Kost
2017-01-30  9:41 ` Ludovic Courtès
2017-01-31 17:29   ` Alex Kost
2017-01-31 22:23     ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).