summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sent <richard@freakingpenguin.com>2024-04-25 00:56:03 -0400
committerGuix Patches Tester <>2024-04-25 12:19:11 +0200
commit3cc9a4c4c5c64788a2179d7c286455390819c970 (patch)
tree3809921c916e0fa36b745822c681b224a11ce038
parent83e6437e92ad056838fe170963d920d446d0e4db (diff)
downloadguix-patches-3cc9a4c4c5c64788a2179d7c286455390819c970.tar
guix-patches-3cc9a4c4c5c64788a2179d7c286455390819c970.tar.gz
services: base: Add optional delayed mount of file-systems
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. * gnu/services/base.scm (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 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 requirements. Change-Id: If0392db03d48e8820aa53df1df482c12ec72e1a5
-rw-r--r--doc/guix.texi13
-rw-r--r--gnu/services/base.scm14
-rw-r--r--gnu/system/file-systems.scm3
3 files changed, 28 insertions, 2 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 3ee9f54773..5c89e2110f 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -17750,6 +17750,19 @@ a dependency of @file{/sys/fs/cgroup/cpu} and
Another example is a file system that depends on a mapped device, for
example for an encrypted partition (@pxref{Mapped Devices}).
+
+@item @code{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 requirements field
+are mounted after Shepherd services have begun. Any Shepherd service
+that depends on a file system with a non-empty 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 3f912225a0..4fd946c4aa 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -403,6 +403,7 @@ upon boot."
(create? (file-system-create-mount-point? file-system))
(mount? (file-system-mount? file-system))
(dependencies (file-system-dependencies file-system))
+ (requirements (file-system-requirements file-system))
(packages (file-system-packages (list file-system))))
(and (or mount? create?)
(with-imported-modules (source-module-closure
@@ -411,7 +412,8 @@ upon boot."
(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?
@@ -460,12 +462,20 @@ upon boot."
(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-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 af0567bd3e..76a51a2b69 100644
--- a/gnu/system/file-systems.scm
+++ b/gnu/system/file-systems.scm
@@ -57,6 +57,7 @@
file-system-repair
file-system-create-mount-point?
file-system-dependencies
+ file-system-requirements
file-system-location
file-system-type-predicate
@@ -185,6 +186,8 @@ flags are found."
(default #f))
(dependencies file-system-dependencies ; list of <file-system>
(default '())) ; or <mapped-device>
+ (requirements file-system-requirements ; list of symbols
+ (default '()))
(location file-system-location
(default (current-source-location))
(innate)))