all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Richard Sent <richard@freakingpenguin.com>
To: 70542@debbugs.gnu.org
Cc: "Richard Sent" <richard@freakingpenguin.com>,
	"Florian Pelz" <pelzflorian@pelzflorian.de>,
	"Ludovic Courtès" <ludo@gnu.org>,
	"Matthew Trzcinski" <matt@excalamus.com>,
	"Maxim Cournoyer" <maxim.cournoyer@gmail.com>
Subject: [bug#70542] [PATCH v3 1/3] services: base: Add optional delayed mount of file-systems
Date: Sat,  1 Jun 2024 19:26:16 -0400	[thread overview]
Message-ID: <9ce75e011c2459e20902e7fe1d68b691531daa66.1717283896.git.richard@freakingpenguin.com> (raw)
In-Reply-To: <cover.1717283896.git.richard@freakingpenguin.com>

Add a mechanism to only require mounting a subset of file-system entries
during early Shepherd initialization. Any file-system with additional Shepherd
service requirements (e.g. networking) is not required to provision
'file-systems.

* gnu/services/base.scm (file-system-shepherd-service): Splice
file-system-requirements into the Shepherd service requirement list.
(file-system-shepherd-services): Provision 'file-system only when file system
services without additional Shepherd requirements are started.
* gnu/system/file-systems.scm (file-system): Add shepherd-requirements field
to the file-system record. This field is used for adding additional Shepherd
requirements to a file-system Shepherd service.
* doc/guix.texi: Add documentation for file-system shepherd-requirements.

Change-Id: If0392db03d48e8820aa53df1df482c12ec72e1a5
---
 doc/guix.texi               | 14 +++++++++
 gnu/services/base.scm       | 14 +++++++--
 gnu/system/file-systems.scm | 57 +++++++++++++++++++------------------
 3 files changed, 56 insertions(+), 29 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 1224104038..158fd6c125 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -17862,6 +17862,20 @@ File Systems
 
 Another example is a file system that depends on a mapped device, for
 example for an encrypted partition (@pxref{Mapped Devices}).
+
+@item @code{shepherd-requirements} (default: @code{'()})
+This is a list of symbols denoting Shepherd requirements that must be
+met before mounting the file system.
+
+As an example, an NFS file system would typically have a requirement for
+@code{networking}.
+
+Typically, file systems are mounted before most other Shepherd services
+are started.  However, file systems with a non-empty
+shepherd-requirements field are mounted after Shepherd services have
+begun.  Any Shepherd service that depends on a file system with a
+non-empty shepherd-requirements field must depend on it directly and not
+on the generic symbol @code{file-systems}.
 @end table
 @end deftp
 
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 85160bd3ab..a552438753 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -404,6 +404,7 @@ (define (file-system-shepherd-service file-system)
         (create? (file-system-create-mount-point? file-system))
         (mount?  (file-system-mount? file-system))
         (dependencies (file-system-dependencies file-system))
+        (requirements (file-system-shepherd-requirements file-system))
         (packages (file-system-packages (list file-system))))
     (and (or mount? create?)
          (with-imported-modules (source-module-closure
@@ -412,7 +413,8 @@ (define (file-system-shepherd-service file-system)
             (provision (list (file-system->shepherd-service-name file-system)))
             (requirement `(root-file-system
                            udev
-                           ,@(map dependency->shepherd-service-name dependencies)))
+                           ,@(map dependency->shepherd-service-name dependencies)
+                           ,@requirements))
             (documentation "Check, mount, and unmount the given file system.")
             (start #~(lambda args
                        #$(if create?
@@ -461,12 +463,20 @@ (define (file-system-shepherd-services file-systems)
                                  (or (file-system-mount? x)
                                      (file-system-create-mount-point? x)))
                                file-systems)))
+
     (define sink
       (shepherd-service
        (provision '(file-systems))
        (requirement (cons* 'root-file-system 'user-file-systems
                            (map file-system->shepherd-service-name
-                                file-systems)))
+                                ;; Do not require file systems with Shepherd
+                                ;; requirements to provision
+                                ;; 'file-systems. Many Shepherd services
+                                ;; require 'file-systems, so we would likely
+                                ;; deadlock.
+                                (filter (lambda (file-system)
+                                          (null? (file-system-shepherd-requirements file-system)))
+                                        file-systems))))
        (documentation "Target for all the initially-mounted file systems")
        (start #~(const #t))
        (stop #~(const #f))))
diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm
index c791b24a9f..4ea8237c70 100644
--- a/gnu/system/file-systems.scm
+++ b/gnu/system/file-systems.scm
@@ -57,6 +57,7 @@ (define-module (gnu system file-systems)
             file-system-repair
             file-system-create-mount-point?
             file-system-dependencies
+            file-system-shepherd-requirements
             file-system-location
 
             file-system-type-predicate
@@ -161,33 +162,35 @@ (define-syntax validate-file-system-flags
 (define-record-type* <file-system> file-system
   make-file-system
   file-system?
-  (device           file-system-device) ; string | <uuid> | <file-system-label>
-  (mount-point      file-system-mount-point)      ; string
-  (type             file-system-type)             ; string
-  (flags            file-system-flags             ; list of symbols
-                    (default '())
-                    (sanitize validate-file-system-flags))
-  (options          file-system-options           ; string or #f
-                    (default #f))
-  (mount?           file-system-mount?            ; Boolean
-                    (default #t))
-  (mount-may-fail?  file-system-mount-may-fail?   ; Boolean
-                    (default #f))
-  (needed-for-boot? %file-system-needed-for-boot? ; Boolean
-                    (default #f))
-  (check?           file-system-check?            ; Boolean
-                    (default #t))
-  (skip-check-if-clean? file-system-skip-check-if-clean? ; Boolean
-                        (default #t))
-  (repair           file-system-repair            ; symbol or #f
-                    (default 'preen))
-  (create-mount-point? file-system-create-mount-point? ; Boolean
-                       (default #f))
-  (dependencies     file-system-dependencies      ; list of <file-system>
-                    (default '()))                ; or <mapped-device>
-  (location         file-system-location
-                    (default (current-source-location))
-                    (innate)))
+  (device                file-system-device)               ; string | <uuid> | <file-system-label>
+  (mount-point           file-system-mount-point)          ; string
+  (type                  file-system-type)                 ; string
+  (flags                 file-system-flags                 ; list of symbols
+                         (default '())
+                         (sanitize validate-file-system-flags))
+  (options               file-system-options               ; string or #f
+                         (default #f))
+  (mount?                file-system-mount?                ; Boolean
+                         (default #t))
+  (mount-may-fail?       file-system-mount-may-fail?       ; Boolean
+                         (default #f))
+  (needed-for-boot?      %file-system-needed-for-boot?     ; Boolean
+                         (default #f))
+  (check?                file-system-check?                ; Boolean
+                         (default #t))
+  (skip-check-if-clean?  file-system-skip-check-if-clean?  ; Boolean
+                         (default #t))
+  (repair                file-system-repair                ; symbol or #f
+                         (default 'preen))
+  (create-mount-point?   file-system-create-mount-point?   ; Boolean
+                         (default #f))
+  (dependencies          file-system-dependencies          ; list of <file-system>
+                         (default '()))                    ; or <mapped-device>
+  (shepherd-requirements file-system-shepherd-requirements ; list of symbols
+                         (default '()))
+  (location              file-system-location
+                         (default (current-source-location))
+                         (innate)))
 
 ;; A file system label for use in the 'device' field.
 (define-record-type <file-system-label>
-- 
2.41.0





  reply	other threads:[~2024-06-01 23:28 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-23 20:44 [bug#70542] [PATCH 0/4] Improve Shepherd service support for networked file systems Richard Sent
2024-04-23 20:47 ` [bug#70542] [PATCH 1/4] file-systems: Add requirements field to file-systems Richard Sent
2024-04-24 17:31   ` Liliana Marie Prikler
2024-04-23 20:47 ` [bug#70542] [PATCH 2/4] services: base: Use requirements to delay some file-systems Richard Sent
2024-04-24 17:30   ` Liliana Marie Prikler
2024-04-23 20:47 ` [bug#70542] [PATCH 3/4] file-systems: Add support for mounting CIFS file systems Richard Sent
2024-04-24 17:29   ` Liliana Marie Prikler
2024-04-24 18:22     ` Richard Sent
2024-04-24 18:47       ` Liliana Marie Prikler
2024-04-24 19:19         ` Richard Sent
2024-04-23 20:47 ` [bug#70542] [PATCH 4/4] system: Do not check for CIFS file system availability Richard Sent
2024-04-24 17:26   ` Liliana Marie Prikler
2024-04-23 20:51 ` [bug#70542] Missing reference in cover letter Richard Sent
2024-04-25  4:56 ` [bug#70542] [PATCH v2 1/3] services: base: Add optional delayed mount of file-systems Richard Sent
2024-04-25  4:56   ` [bug#70542] [PATCH v2 2/3] file-systems: Add host-to-ip nested function Richard Sent
2024-04-25  4:56   ` [bug#70542] [PATCH v2 3/3] file-systems: Add support for mounting CIFS file systems Richard Sent
2024-04-25  6:51 ` [bug#70542] [PATCH 0/4] Improve Shepherd service support for networked " Jonathan Brielmaier via Guix-patches via
2024-04-25 13:43   ` Richard Sent
2024-06-01 23:26 ` [bug#70542] [PATCH v3 0/3] " Richard Sent
2024-06-01 23:26   ` Richard Sent [this message]
2024-06-01 23:26   ` [bug#70542] [PATCH v3 2/3] file-systems: Add host-to-ip nested function Richard Sent
2024-06-01 23:26   ` [bug#70542] [PATCH v3 3/3] file-systems: Add support for mounting CIFS file systems Richard Sent
2024-06-04 10:06   ` bug#70542: [PATCH v3 0/3] Improve Shepherd service support for networked " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9ce75e011c2459e20902e7fe1d68b691531daa66.1717283896.git.richard@freakingpenguin.com \
    --to=richard@freakingpenguin.com \
    --cc=70542@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    --cc=matt@excalamus.com \
    --cc=maxim.cournoyer@gmail.com \
    --cc=pelzflorian@pelzflorian.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.