From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 04 13:04:00 2023 Received: (at submit) by debbugs.gnu.org; 4 Mar 2023 18:04:00 +0000 Received: from localhost ([127.0.0.1]:37704 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYWEi-0007s8-3E for submit@debbugs.gnu.org; Sat, 04 Mar 2023 13:04:00 -0500 Received: from lists.gnu.org ([209.51.188.17]:48634) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYWEg-0007s0-2K for submit@debbugs.gnu.org; Sat, 04 Mar 2023 13:03:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pYWEf-0001Xe-QE for guix-patches@gnu.org; Sat, 04 Mar 2023 13:03:57 -0500 Received: from smtpm4.myservices.hosting ([185.26.105.235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pYWEd-0000E2-Ps for guix-patches@gnu.org; Sat, 04 Mar 2023 13:03:57 -0500 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm4.myservices.hosting (Postfix) with ESMTP id 1C3CD20AE4 for ; Sat, 4 Mar 2023 19:03:41 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id C954480097; Sat, 4 Mar 2023 19:03:41 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id M09wF7cnjDEO; Sat, 4 Mar 2023 19:03:37 +0100 (CET) Received: from guix-nuc.home.arpa (bl9-119-177.dsl.telepac.pt [85.242.119.177]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 5BFED80079; Sat, 4 Mar 2023 19:03:37 +0100 (CET) From: Bruno Victal To: guix-patches@gnu.org Subject: [PATCH] services: Add fstrim-service-type. Date: Sat, 4 Mar 2023 18:03:28 +0000 Message-Id: <9fec722b58c87211f019fa702a5c7047577bec64.1677952942.git.mirai@makinata.eu> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=185.26.105.235; envelope-from=mirai@makinata.eu; helo=smtpm4.myservices.hosting X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Bruno Victal X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) * gnu/services/linux.scm (fstrim-service-type): New variable. (fstrim-mcron-job, serialize-fstrim-configuration) (fstrim-serialize-list-of-strings, fstrim-serialize-boolean): New procedure. (mcron-time?): New predicate. (fstrim-configuration): New record. * doc/guix.texi (Linux Services): Document new fstrim-service-type. --- doc/guix.texi | 62 +++++++++++++++++++++++ gnu/services/linux.scm | 109 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 171 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 74658dbc86..d5a83e387f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -37436,6 +37436,68 @@ Linux Services @end table @end deftp +@cindex fstrim service +@cindex solid state drives, periodic trim +@cindex solid state drives, trim +@subsubheading fstrim Service + +The command @command{fstrim} can be used to discard (or @dfn{trim}) +unused blocks on a mounted filesystem. + +@c This was copied from the fstrim manpage, with some texinfo touch-ups. +@quotation Warning +Running @command{fstrim} frequently, or even using +@command{mount -o discard}, might negatively affect the lifetime of +poor-quality SSD devices. For most desktop and server systems a +sufficient trimming frequency is once a week. Note that not all devices +support a queued trim, so each trim command incurs a performance penalty +on whatever else might be trying to use the disk at the time. +@end quotation + +@defvar fstrim-service-type +Type for a service that periodically runs @command{fstrim}, whose value must +be a @code{} object. The service can be instantiated +in its default configuration with: + +@lisp +(service fstrim-service-type) +@end lisp +@end defvar + +@c %start of fragment +@deftp {Data Type} fstrim-configuration +Available @code{fstrim-configuration} fields are: + +@table @asis +@item @code{package} (default: @code{util-linux}) (type: file-like) +The package providing @command{fstrim}. + +@item @code{schedule} (default: @code{"0 0 * * 0"}) (type: mcron-time) +Schedule for launching @command{fstrim}. This can be a procedure, a +list or a string. For additional information, @pxref{Guile Syntax,, Job +specification, mcron,the mcron manual}. By default this is set to run +weekly on Sunday at 00:00. + +@item @code{listed-in} (default: @code{("/etc/fstab" "/proc/self/mountinfo")}) (type: maybe-list-of-strings) +List of files in fstab or kernel mountinfo format. All missing or empty +files are silently ignored. The evaluation of the list @emph{stops} +after the first non-empty file. Filesystems with @code{X-fstrim.notrim} +mount option in fstab are skipped. + +@item @code{verbose?} (default: @code{#t}) (type: boolean) +Verbose execution. + +@item @code{quiet-unsupported?} (default: @code{#t}) (type: boolean) +Suppress error messages if trim operation (ioctl) is unsupported. + +@item @code{extra-arguments} (type: maybe-list-of-strings) +Extra options to append to @command{fstrim} command.@footnote{Run +@command{man fstrim} for more information.} + +@end table +@end deftp +@c %end of fragment + @cindex modprobe @cindex kernel module loader @subsubheading Kernel Module Loader Service diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm index 60e2093e1d..f5ec5fec48 100644 --- a/gnu/services/linux.scm +++ b/gnu/services/linux.scm @@ -5,6 +5,7 @@ ;;; Copyright © 2021 raid5atemyhomework ;;; Copyright © 2021 B. Wilson ;;; Copyright © 2022 Josselin Poiret +;;; Copyright © 2023 Bruno Victal ;;; ;;; This file is part of GNU Guix. ;;; @@ -30,12 +31,15 @@ (define-module (gnu services linux) #:use-module (guix ui) #:use-module (gnu services) #:use-module (gnu services base) + #:use-module (gnu services configuration) + #:use-module (gnu services mcron) #:use-module (gnu services shepherd) #:use-module (gnu packages linux) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) + #:use-module (ice-9 format) #:use-module (ice-9 match) #:export (earlyoom-configuration earlyoom-configuration? @@ -50,6 +54,16 @@ (define-module (gnu services linux) earlyoom-configuration-send-notification-command earlyoom-service-type + fstrim-configuration + fstrim-configuration? + fstrim-configuration-package + fstrim-configuration-schedule + fstrim-configuration-listed-in + fstrim-configuration-verbose? + fstrim-configuration-quiet-unsupported? + fstrim-configuration-extra-arguments + fstrim-service-type + kernel-module-loader-service-type rasdaemon-configuration @@ -150,6 +164,101 @@ (define earlyoom-service-type (compose list earlyoom-shepherd-service)))) (description "Run @command{earlyoom}, the Early OOM daemon."))) + +;;; +;;; fstrim +;;; + +(define (mcron-time? x) + (or (procedure? x) (string? x) (list? x))) + +(define-maybe list-of-strings (prefix fstrim-)) + +(define (fstrim-serialize-boolean field-name value) + (list (format #f "~:[~;--~a~]" value + ;; drop trailing '?' character + (string-drop-right (symbol->string field-name) 1)))) + +(define (fstrim-serialize-list-of-strings field-name value) + (list (string-append "--" (symbol->string field-name)) + #~(string-join '#$value ":"))) + +(define-configuration fstrim-configuration + (package + (file-like util-linux) + "The package providing @command{fstrim}." + empty-serializer) + + (schedule + (mcron-time "0 0 * * 0") + "Schedule for launching @command{fstrim}. This can be a procedure, a list +or a string. For additional information, @pxref{Guile Syntax,, +Job specification, mcron, the mcron manual}. By default this is set to run +weekly on Sunday at 00:00." + empty-serializer) + + ;; fstrim options + (listed-in + (maybe-list-of-strings '("/etc/fstab" "/proc/self/mountinfo")) + ;; XXX: documentation sourced from the fstrim manpage. + "List of files in fstab or kernel mountinfo format. All missing or +empty files are silently ignored. The evaluation of the list @emph{stops} +after the first non-empty file. Filesystems with @code{X-fstrim.notrim} mount +option in fstab are skipped.") + + (verbose? + (boolean #t) + "Verbose execution.") + + (quiet-unsupported? + (boolean #t) + "Suppress error messages if trim operation (ioctl) is unsupported.") + + (extra-arguments + maybe-list-of-strings + ;; FIXME@GUILE(TEXINFO): @footnote causes errors when calling + ;; configuration->documentation. + ;; > Throw to key `parser-error' with args `(#f "Unknown command" footnote)' + "Extra options to append to @command{fstrim} command.@footnote{Run +@command{man fstrim} for more information.}" + (lambda (_ value) + (if (maybe-value-set? value) + value '()))) + + (prefix fstrim-)) + +(define (serialize-fstrim-configuration config) + (concatenate + (filter list? + (map (lambda (field) + ((configuration-field-serializer field) + (configuration-field-name field) + ((configuration-field-getter field) config))) + fstrim-configuration-fields)))) + +(define (fstrim-mcron-job config) + (match-record config (package schedule) + #~(job + ;; XXX: The “if” below is to ensure that + ;; lists are ungexp'd correctly since @var{schedule} + ;; can be either a procedure, a string or a list. + #$(if (list? schedule) + `(list ,@schedule) + schedule) + (lambda () + (system* #$(file-append package "/sbin/fstrim") + #$@(serialize-fstrim-configuration config))) + "fstrim"))) + +(define fstrim-service-type + (service-type + (name 'fstrim) + (extensions + (list (service-extension mcron-service-type + (compose list fstrim-mcron-job)))) + (description "Discard unused blocks from filesystems.") + (default-value (fstrim-configuration)))) + ;;; ;;; Kernel module loader. base-commit: d6045055720bc0763f8a079d75b941b4898349a4 -- 2.39.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 21 22:35:28 2023 Received: (at 61964) by debbugs.gnu.org; 22 Mar 2023 02:35:28 +0000 Received: from localhost ([127.0.0.1]:33105 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1peoJz-0007lu-VW for submit@debbugs.gnu.org; Tue, 21 Mar 2023 22:35:28 -0400 Received: from mail-qt1-f176.google.com ([209.85.160.176]:40530) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1peoJy-0007lh-Ff for 61964@debbugs.gnu.org; Tue, 21 Mar 2023 22:35:27 -0400 Received: by mail-qt1-f176.google.com with SMTP id x1so21131226qtr.7 for <61964@debbugs.gnu.org>; Tue, 21 Mar 2023 19:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679452520; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=Dim1VUewredpsQMyc1x60cM9U2lQKx0FxTh8xxDlOgk=; b=OffapvUTTu1ryO5hO/AJ/cl4mdr1PmhvJ498zSw5ix13uIIP6Gz6eEAM2/2GmdKCor cEGqiJE1JVaP/kzhNWhpaytvGiMZbhGRSDlQVu0NTXjkXv4X/mRhZYLBpV7dLL0em5wj PNtuDhbFl0ma9Fp6pz1b4pS5RuqPwsSpCKtx6o4RkpDKzav3/kYzGZ11QRhXAwIQxuDC B4Z3U/Lq3NmiOBMLimINpHFi+H0YTs7n3JhIuG7evkH0+ELqRug3hf1cguVoQfyoQcyL bEZNkac84/rqXCgsnTMcd2Xj7EqAVs868ZiB0w6Uu/hLDN4EYps3uLLROnTp7+zOL7bR wciA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679452520; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Dim1VUewredpsQMyc1x60cM9U2lQKx0FxTh8xxDlOgk=; b=fk4zuJAiqG1bcHI73s+KUuRKBy8aA4gsxh4uDQ45b4Fy2NatbzVIqi/C5Byn/E7faz PXYBU+pXXFHvy/HeW8Jv5KuqTimrL588Tom8mJO958E0XYQ32s7N4p6Eh7cZX+NSeR7R BZe93MA43KUsh6XWgmAwGEksf46KIz/VvJDxsWuezXcPUX0FVZ8P9onNQtOTDEfDaNhE Yz1ngk8JOB3ebCfi6Fn+tKrrB7gLgu6C6CLCqPRC+0TVqDHUlkgaq4VfICt686J4A1/N 3msbMnT5kMI1QYmy1ZSuaHbEkhV3ihQKGCxSHc9v99JqXd1G+N08QOg8aIJuqKF5DNHv MF8g== X-Gm-Message-State: AO0yUKVmkf+7auIhTm0xAIO8hNSXPHe3A6u3nxW9+Y3WGKdLJCFfHc6v Lu++Zm8LuqrQrxxadK+48W7rscndwU7cxQ== X-Google-Smtp-Source: AK7set+wBNTJHae39w+QARxB8iStJd+XnYB7vKw8xEb6z3LW5fR6KyqEXiBreVfFRST1yRYWsWM/3g== X-Received: by 2002:ac8:5c85:0:b0:3c0:3d68:540c with SMTP id r5-20020ac85c85000000b003c03d68540cmr3412490qta.65.1679452520567; Tue, 21 Mar 2023 19:35:20 -0700 (PDT) Received: from hurd (dsl-10-130-195.b2b2c.ca. [72.10.130.195]) by smtp.gmail.com with ESMTPSA id o197-20020a3741ce000000b0073b575f3603sm10485140qka.101.2023.03.21.19.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 19:35:20 -0700 (PDT) From: Maxim Cournoyer To: Bruno Victal Subject: Re: bug#61964: [PATCH] services: Add fstrim-service-type. References: <9fec722b58c87211f019fa702a5c7047577bec64.1677952942.git.mirai@makinata.eu> Date: Tue, 21 Mar 2023 22:35:18 -0400 In-Reply-To: <9fec722b58c87211f019fa702a5c7047577bec64.1677952942.git.mirai@makinata.eu> (Bruno Victal's message of "Sat, 4 Mar 2023 18:03:28 +0000") Message-ID: <87o7olikd5.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61964 Cc: 61964@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi! Bruno Victal writes: > * gnu/services/linux.scm (fstrim-service-type): New variable. > (fstrim-mcron-job, serialize-fstrim-configuration) > (fstrim-serialize-list-of-strings, fstrim-serialize-boolean): New procedu= re. > (mcron-time?): New predicate. > (fstrim-configuration): New record. > * doc/guix.texi (Linux Services): Document new fstrim-service-type. Thanks! This looks nice. > --- > doc/guix.texi | 62 +++++++++++++++++++++++ > gnu/services/linux.scm | 109 +++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 171 insertions(+) > > diff --git a/doc/guix.texi b/doc/guix.texi > index 74658dbc86..d5a83e387f 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -37436,6 +37436,68 @@ Linux Services > @end table > @end deftp >=20=20 > +@cindex fstrim service > +@cindex solid state drives, periodic trim > +@cindex solid state drives, trim > +@subsubheading fstrim Service > + > +The command @command{fstrim} can be used to discard (or @dfn{trim}) > +unused blocks on a mounted filesystem. Please s/filesystem/file system/, which is the preferred spelling in the GNU project. > + > +@c This was copied from the fstrim manpage, with some texinfo touch-ups. > Texinfo > +@quotation Warning > +Running @command{fstrim} frequently, or even using > +@command{mount -o discard}, might negatively affect the lifetime of > +poor-quality SSD devices. For most desktop and server systems a > +sufficient trimming frequency is once a week. Note that not all devices > +support a queued trim, so each trim command incurs a performance penalty > +on whatever else might be trying to use the disk at the time. > +@end quotation > + > +@defvar fstrim-service-type > +Type for a service that periodically runs @command{fstrim}, whose value = must > +be a @code{} object. The service can be instantia= ted > +in its default configuration with: > + > +@lisp > +(service fstrim-service-type) > +@end lisp > +@end defvar > + > +@c %start of fragment > +@deftp {Data Type} fstrim-configuration > +Available @code{fstrim-configuration} fields are: > + > +@table @asis > +@item @code{package} (default: @code{util-linux}) (type: file-like) > +The package providing @command{fstrim}. > + > +@item @code{schedule} (default: @code{"0 0 * * 0"}) (type: mcron-time) > +Schedule for launching @command{fstrim}. This can be a procedure, a > +list or a string. For additional information, @pxref{Guile Syntax,, Job > +specification, mcron,the mcron manual}. By default this is set to run > +weekly on Sunday at 00:00. pxref is supposed to be used in between parentheses (Parenthetical Cross-Reference); I think you can use just "see: @ref{...}" instead, without parentheses. > +@item @code{listed-in} (default: @code{("/etc/fstab" "/proc/self/mountin= fo")}) (type: maybe-list-of-strings) > +List of files in fstab or kernel mountinfo format. All missing or empty > +files are silently ignored. The evaluation of the list @emph{stops} > +after the first non-empty file. Filesystems with @code{X-fstrim.notrim} File systems > +mount option in fstab are skipped. > + > +@item @code{verbose?} (default: @code{#t}) (type: boolean) > +Verbose execution. > + > +@item @code{quiet-unsupported?} (default: @code{#t}) (type: boolean) > +Suppress error messages if trim operation (ioctl) is unsupported. > + > +@item @code{extra-arguments} (type: maybe-list-of-strings) > +Extra options to append to @command{fstrim} command.@footnote{Run > +@command{man fstrim} for more information.} I think @command is to denote a single command, not a command line (command + arguments); I'd use @samp{man fstrim} instead, and replace the footnote by (see @samp{man fstrim} for more information). > +@end table > +@end deftp > +@c %end of fragment > + > @cindex modprobe > @cindex kernel module loader > @subsubheading Kernel Module Loader Service > diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm > index 60e2093e1d..f5ec5fec48 100644 > --- a/gnu/services/linux.scm > +++ b/gnu/services/linux.scm > @@ -5,6 +5,7 @@ > ;;; Copyright =C2=A9 2021 raid5atemyhomework > ;;; Copyright =C2=A9 2021 B. Wilson > ;;; Copyright =C2=A9 2022 Josselin Poiret > +;;; Copyright =C2=A9 2023 Bruno Victal > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -30,12 +31,15 @@ (define-module (gnu services linux) > #:use-module (guix ui) > #:use-module (gnu services) > #:use-module (gnu services base) > + #:use-module (gnu services configuration) > + #:use-module (gnu services mcron) > #:use-module (gnu services shepherd) > #:use-module (gnu packages linux) > #:use-module (srfi srfi-1) > #:use-module (srfi srfi-26) > #:use-module (srfi srfi-34) > #:use-module (srfi srfi-35) > + #:use-module (ice-9 format) > #:use-module (ice-9 match) > #:export (earlyoom-configuration > earlyoom-configuration? > @@ -50,6 +54,16 @@ (define-module (gnu services linux) > earlyoom-configuration-send-notification-command > earlyoom-service-type >=20=20 > + fstrim-configuration > + fstrim-configuration? > + fstrim-configuration-package > + fstrim-configuration-schedule > + fstrim-configuration-listed-in > + fstrim-configuration-verbose? > + fstrim-configuration-quiet-unsupported? > + fstrim-configuration-extra-arguments > + fstrim-service-type > + > kernel-module-loader-service-type >=20=20 > rasdaemon-configuration > @@ -150,6 +164,101 @@ (define earlyoom-service-type > (compose list earlyoom-shepherd-service)))) > (description "Run @command{earlyoom}, the Early OOM daemon."))) >=20=20 > + > +;;; > +;;; fstrim > +;;; > + > +(define (mcron-time? x) > + (or (procedure? x) (string? x) (list? x))) > + > +(define-maybe list-of-strings (prefix fstrim-)) > + > +(define (fstrim-serialize-boolean field-name value) > + (list (format #f "~:[~;--~a~]" value > + ;; drop trailing '?' character Use full sentence for standalone comment (;; Drop [...] character.) > + (string-drop-right (symbol->string field-name) 1)))) > + > +(define (fstrim-serialize-list-of-strings field-name value) > + (list (string-append "--" (symbol->string field-name)) > + #~(string-join '#$value ":"))) > + > +(define-configuration fstrim-configuration > + (package > + (file-like util-linux) > + "The package providing @command{fstrim}." providing the @command{fstrim} command. > + empty-serializer) > + > + (schedule > + (mcron-time "0 0 * * 0") > + "Schedule for launching @command{fstrim}. This can be a procedure, a = list > +or a string. For additional information, @pxref{Guile Syntax,, > +Job specification, mcron, the mcron manual}. By default this is set to r= un > +weekly on Sunday at 00:00." > + empty-serializer) >From here on, the text started to use single sentence spacing. Please make it double sentence spacing. > + ;; fstrim options > + (listed-in > + (maybe-list-of-strings '("/etc/fstab" "/proc/self/mountinfo")) > + ;; XXX: documentation sourced from the fstrim manpage. What is "dirty" about the above comment? I'd just use ;; Note: [...]. > + "List of files in fstab or kernel mountinfo format. All missing or > +empty files are silently ignored. The evaluation of the list @emph{stops} > +after the first non-empty file. Filesystems with @code{X-fstrim.notrim} = mount > +option in fstab are skipped.") File systems. > + > + (verbose? > + (boolean #t) > + "Verbose execution.") > + > + (quiet-unsupported? > + (boolean #t) > + "Suppress error messages if trim operation (ioctl) is unsupported.") > + > + (extra-arguments > + maybe-list-of-strings > + ;; FIXME@GUILE(TEXINFO): @footnote causes errors when calling > + ;; configuration->documentation. > + ;; > Throw to key `parser-error' with args `(#f "Unknown command" foo= tnote)' Please take the time to report the issue upstream (bug-guile@gnu.org) and link to it here. > + "Extra options to append to @command{fstrim} command.@footnote{Run > +@command{man fstrim} for more information.}" > + (lambda (_ value) > + (if (maybe-value-set? value) > + value '()))) > + > + (prefix fstrim-)) > + > +(define (serialize-fstrim-configuration config) > + (concatenate > + (filter list? > + (map (lambda (field) > + ((configuration-field-serializer field) > + (configuration-field-name field) > + ((configuration-field-getter field) config))) > + fstrim-configuration-fields)))) > + > +(define (fstrim-mcron-job config) > + (match-record config (package schedule) > + #~(job > + ;; XXX: The =E2=80=9Cif=E2=80=9D below is to ensure that > + ;; lists are ungexp'd correctly since @var{schedule} > + ;; can be either a procedure, a string or a list. I'd turn the XXX into a 'Note' here as well. XXX is for ugly hacks that should be eventually replaced with something more elegant, when someone finds a way to do so. > + #$(if (list? schedule) > + `(list ,@schedule) > + schedule) > + (lambda () > + (system* #$(file-append package "/sbin/fstrim") > + #$@(serialize-fstrim-configuration config))) > + "fstrim"))) > + > +(define fstrim-service-type > + (service-type > + (name 'fstrim) > + (extensions > + (list (service-extension mcron-service-type > + (compose list fstrim-mcron-job)))) > + (description "Discard unused blocks from filesystems.") I think the main takeaway from my review is this: file systems! Eh. More seriously, thanks, this looks good! --=20 Thanks, Maxim From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 21 22:35:38 2023 Received: (at control) by debbugs.gnu.org; 22 Mar 2023 02:35:38 +0000 Received: from localhost ([127.0.0.1]:33108 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1peoK9-0007mJ-Nt for submit@debbugs.gnu.org; Tue, 21 Mar 2023 22:35:37 -0400 Received: from mail-qt1-f181.google.com ([209.85.160.181]:45841) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1peoK8-0007m7-Dl for control@debbugs.gnu.org; Tue, 21 Mar 2023 22:35:36 -0400 Received: by mail-qt1-f181.google.com with SMTP id t19so7057309qta.12 for ; Tue, 21 Mar 2023 19:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679452531; h=subject:from:to:message-id:date:from:to:cc:subject:date:message-id :reply-to; bh=kbyM6CG11Zwn/Xu/baxyRzoY1hAtNEDekHE5440/g7I=; b=DEOdiAaAU31lc42vs9cOEGi02grlRw29c9dotCAE3tm/rJNPj6eUaYu3OH6y+dqVvD FL1bGIMUcCAcA2ajA72ApM26jEr73U0Wdu0he21TtG2cbD1OZMqtm/d7JnIdf3Wpk1UQ jXJvBCjOyw+QnpEJCPRkfzlOMex3aHkWrhc/2C4c8+nnuMQ638/2NYwNROHUzj0vqqXP X8Ft8FdQ09LXrjiEerjGEhy50tqrITN3gx070IAIYriuhAbn6faSzUfNJaR2cOJ68hfQ 0PCvcvwwo+TGxY0Y+nt8sQS6aHTN0NcVR4KMPOxE9wtLFEZFL+aExdYdAYUA/nzWl5Lo Oopw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679452531; h=subject:from:to:message-id:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kbyM6CG11Zwn/Xu/baxyRzoY1hAtNEDekHE5440/g7I=; b=3suQS4DE1ciBPZ0YVkreTSr09wWX1ce8k69BZ543Z8iDXcpyUZr3XzWDH5ZsppfYvT ov7OL92EL/yaDyc2qjbwtbjg8SWhGMgpj2vqow/1ZLWaubG6Cy82D2g3/FXRutuidxUO RW4BpxQcRsplk/lmqH/EpB2aKkFl7IeA/jRXGSLQ09qOsGmcgGYmoEeciSFSqBL6GXne NK+xXmhcBCVr2uZK8m57Mj4veu4KrGmMRC3VUttCy62K1NZeU3YXYTh8ixiYtRkiopr/ 6kEW8cRKgLS1x64adoT1NuOmXD4XtSExsC/md/FhemZt+kxe9royDXjaTV6DUkkFj06D NpQQ== X-Gm-Message-State: AO0yUKUAaN/LTYaRBBWPKbTPjMPuhEQBA+ieDuNNgipQSAV/QIfGyGZO 6hxk1UugetknlG2nQSJnMOpis/wIhm/zVg== X-Google-Smtp-Source: AK7set9VUPPoW7MKHur0j0AaEm0dgnubQwP1y2sNrOiSGwXx4rjKUAPqTQ6Ump+lRu8Ikqa6DblS0A== X-Received: by 2002:ac8:580a:0:b0:3d8:6b0d:f9a6 with SMTP id g10-20020ac8580a000000b003d86b0df9a6mr3353530qtg.61.1679452530838; Tue, 21 Mar 2023 19:35:30 -0700 (PDT) Received: from hurd (dsl-10-130-195.b2b2c.ca. [72.10.130.195]) by smtp.gmail.com with ESMTPSA id k18-20020ac84792000000b003ba19e53e43sm6247193qtq.25.2023.03.21.19.35.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 19:35:30 -0700 (PDT) Date: Tue, 21 Mar 2023 22:35:29 -0400 Message-Id: <87mt45ikcu.fsf@gmail.com> To: control@debbugs.gnu.org From: Maxim Cournoyer Subject: control message for bug #61964 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 61964 + moreinfo quit From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 22 07:54:35 2023 Received: (at 61964) by debbugs.gnu.org; 22 Mar 2023 11:54:35 +0000 Received: from localhost ([127.0.0.1]:33686 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pex34-0007Nn-Hq for submit@debbugs.gnu.org; Wed, 22 Mar 2023 07:54:35 -0400 Received: from smtpm1.myservices.hosting ([185.26.105.232]:59646) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pex32-0007Ne-6r for 61964@debbugs.gnu.org; Wed, 22 Mar 2023 07:54:33 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm1.myservices.hosting (Postfix) with ESMTP id B149A20489; Wed, 22 Mar 2023 12:54:29 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id EB59C800A8; Wed, 22 Mar 2023 12:47:30 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id cMTkG5Bpso7o; Wed, 22 Mar 2023 12:47:27 +0100 (CET) Received: from guix-nuc.home.arpa (bl9-119-177.dsl.telepac.pt [85.242.119.177]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 2CEE7800A7; Wed, 22 Mar 2023 12:47:27 +0100 (CET) From: Bruno Victal To: 61964@debbugs.gnu.org Subject: [PATCH v2] services: Add fstrim-service-type. Date: Wed, 22 Mar 2023 11:47:19 +0000 Message-Id: <2be8cc336a7e56ee6c15a57548c3b7690803101f.1679485589.git.mirai@makinata.eu> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61964 Cc: Bruno Victal , maxim.cournoyer@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/services/linux.scm (fstrim-service-type): New variable. (fstrim-mcron-job, serialize-fstrim-configuration) (fstrim-serialize-list-of-strings, fstrim-serialize-boolean): New procedure. (mcron-time?): New predicate. (fstrim-configuration): New record. * doc/guix.texi (Linux Services): Document new fstrim-service-type. --- doc/guix.texi | 62 +++++++++++++++++++++++ gnu/services/linux.scm | 110 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 5a2dc2a3a3..29bad0c921 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -37485,6 +37485,68 @@ Linux Services @end table @end deftp +@subsubheading fstrim Service +@cindex fstrim service +@cindex solid state drives, periodic trim +@cindex solid state drives, trim + +The command @command{fstrim} can be used to discard (or @dfn{trim}) +unused blocks on a mounted file system. + +@c This was copied from the fstrim manpage, with some texinfo touch-ups. +@quotation Warning +Running @command{fstrim} frequently, or even using +@command{mount -o discard}, might negatively affect the lifetime of +poor-quality SSD devices. For most desktop and server systems a +sufficient trimming frequency is once a week. Note that not all devices +support a queued trim, so each trim command incurs a performance penalty +on whatever else might be trying to use the disk at the time. +@end quotation + +@defvar fstrim-service-type +Type for a service that periodically runs @command{fstrim}, whose value must +be a @code{} object. The service can be instantiated +in its default configuration with: + +@lisp +(service fstrim-service-type) +@end lisp +@end defvar + +@c %start of fragment +@deftp {Data Type} fstrim-configuration +Available @code{fstrim-configuration} fields are: + +@table @asis +@item @code{package} (default: @code{util-linux}) (type: file-like) +The package providing the @command{fstrim} command. + +@item @code{schedule} (default: @code{"0 0 * * 0"}) (type: mcron-time) +Schedule for launching @command{fstrim}. This can be a procedure, a +list or a string. For additional information, see @ref{Guile +Syntax,,Job specification,mcron,the mcron manual}. By default this is +set to run weekly on Sunday at 00:00. + +@item @code{listed-in} (default: @code{("/etc/fstab" "/proc/self/mountinfo")}) (type: maybe-list-of-strings) +List of files in fstab or kernel mountinfo format. All missing or empty +files are silently ignored. The evaluation of the list @emph{stops} +after the first non-empty file. File systems with +@code{X-fstrim.notrim} mount option in fstab are skipped. + +@item @code{verbose?} (default: @code{#t}) (type: boolean) +Verbose execution. + +@item @code{quiet-unsupported?} (default: @code{#t}) (type: boolean) +Suppress error messages if trim operation (ioctl) is unsupported. + +@item @code{extra-arguments} (type: maybe-list-of-strings) +Extra options to append to @command{fstrim} command.@footnote{Run +@samp{man fstrim} for more information.} + +@end table +@end deftp +@c %end of fragment + @cindex modprobe @cindex kernel module loader @subsubheading Kernel Module Loader Service diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm index 60e2093e1d..850c185734 100644 --- a/gnu/services/linux.scm +++ b/gnu/services/linux.scm @@ -5,6 +5,7 @@ ;;; Copyright © 2021 raid5atemyhomework ;;; Copyright © 2021 B. Wilson ;;; Copyright © 2022 Josselin Poiret +;;; Copyright © 2023 Bruno Victal ;;; ;;; This file is part of GNU Guix. ;;; @@ -30,12 +31,15 @@ (define-module (gnu services linux) #:use-module (guix ui) #:use-module (gnu services) #:use-module (gnu services base) + #:use-module (gnu services configuration) + #:use-module (gnu services mcron) #:use-module (gnu services shepherd) #:use-module (gnu packages linux) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) + #:use-module (ice-9 format) #:use-module (ice-9 match) #:export (earlyoom-configuration earlyoom-configuration? @@ -50,6 +54,16 @@ (define-module (gnu services linux) earlyoom-configuration-send-notification-command earlyoom-service-type + fstrim-configuration + fstrim-configuration? + fstrim-configuration-package + fstrim-configuration-schedule + fstrim-configuration-listed-in + fstrim-configuration-verbose? + fstrim-configuration-quiet-unsupported? + fstrim-configuration-extra-arguments + fstrim-service-type + kernel-module-loader-service-type rasdaemon-configuration @@ -150,6 +164,102 @@ (define earlyoom-service-type (compose list earlyoom-shepherd-service)))) (description "Run @command{earlyoom}, the Early OOM daemon."))) + +;;; +;;; fstrim +;;; + +(define (mcron-time? x) + (or (procedure? x) (string? x) (list? x))) + +(define-maybe list-of-strings (prefix fstrim-)) + +(define (fstrim-serialize-boolean field-name value) + (list (format #f "~:[~;--~a~]" value + ;; Drop trailing '?' character. + (string-drop-right (symbol->string field-name) 1)))) + +(define (fstrim-serialize-list-of-strings field-name value) + (list (string-append "--" (symbol->string field-name)) + #~(string-join '#$value ":"))) + +(define-configuration fstrim-configuration + (package + (file-like util-linux) + "The package providing the @command{fstrim} command." + empty-serializer) + + (schedule + (mcron-time "0 0 * * 0") + "Schedule for launching @command{fstrim}. This can be a procedure, a list +or a string. For additional information, see @ref{Guile Syntax,, +Job specification, mcron, the mcron manual}. By default this is set to run +weekly on Sunday at 00:00." + empty-serializer) + + ;; fstrim options + (listed-in + (maybe-list-of-strings '("/etc/fstab" "/proc/self/mountinfo")) + ;; Note: documentation sourced from the fstrim manpage. + "List of files in fstab or kernel mountinfo format. All missing or +empty files are silently ignored. The evaluation of the list @emph{stops} +after the first non-empty file. File systems with @code{X-fstrim.notrim} mount +option in fstab are skipped.") + + (verbose? + (boolean #t) + "Verbose execution.") + + (quiet-unsupported? + (boolean #t) + "Suppress error messages if trim operation (ioctl) is unsupported.") + + (extra-arguments + maybe-list-of-strings + ;; Tracked at: . + ;; FIXME@GUILE(TEXINFO): @footnote causes errors when calling + ;; configuration->documentation. + ;; > Throw to key `parser-error' with args `(#f "Unknown command" footnote)' + "Extra options to append to @command{fstrim} command.@footnote{Run +@samp{man fstrim} for more information.}" + (lambda (_ value) + (if (maybe-value-set? value) + value '()))) + + (prefix fstrim-)) + +(define (serialize-fstrim-configuration config) + (concatenate + (filter list? + (map (lambda (field) + ((configuration-field-serializer field) + (configuration-field-name field) + ((configuration-field-getter field) config))) + fstrim-configuration-fields)))) + +(define (fstrim-mcron-job config) + (match-record config (package schedule) + #~(job + ;; Note: The “if” below is to ensure that + ;; lists are ungexp'd correctly since @var{schedule} + ;; can be either a procedure, a string or a list. + #$(if (list? schedule) + `(list ,@schedule) + schedule) + (lambda () + (system* #$(file-append package "/sbin/fstrim") + #$@(serialize-fstrim-configuration config))) + "fstrim"))) + +(define fstrim-service-type + (service-type + (name 'fstrim) + (extensions + (list (service-extension mcron-service-type + (compose list fstrim-mcron-job)))) + (description "Discard unused blocks from file systems.") + (default-value (fstrim-configuration)))) + ;;; ;;; Kernel module loader. base-commit: cfccc9acdb2c9892d4c41ff56ed95347f1750e3f -- 2.39.1 From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 22 10:09:00 2023 Received: (at control) by debbugs.gnu.org; 22 Mar 2023 14:09:00 +0000 Received: from localhost ([127.0.0.1]:36212 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pez9A-0007wM-4c for submit@debbugs.gnu.org; Wed, 22 Mar 2023 10:09:00 -0400 Received: from mail-qv1-f44.google.com ([209.85.219.44]:42594) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pez97-0007wA-Vn for control@debbugs.gnu.org; Wed, 22 Mar 2023 10:08:58 -0400 Received: by mail-qv1-f44.google.com with SMTP id x8so12196770qvr.9 for ; Wed, 22 Mar 2023 07:08:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679494132; h=subject:from:to:message-id:date:from:to:cc:subject:date:message-id :reply-to; bh=cdNQE8gF7nxY1Sh1kNSg5XliRJh9fONbWmL8tpWK9og=; b=EucAQLs98/QLx+/gd4XaM8KH5HzIKZuivWsfGoExHqdAWZ6gBY4jl08v/oBsQV+4nw QYZ3uynmXLWWmF0R0uq4lxXWuxDuRtVMkHE1n6ft781PtnivOY+owSspJkBcUK9FZKnK 90Yb9w9KqKVZyzbIB1R1PFPStMGPRQowYcWkrdRWvlTFXDendmNcGDQql3f1hpeMNfzm H6yhfQWfXvkNUvhyTbhRTXAG7wF6ZJM5ns81vyklg/tboSSf0kCNDvuzEcAsFcMiA8kO eL9krFGNwci4+rdbSRwwQexRfdrivC4TxE8uNXlKCBJqMyLrh6Qo7+KgvjDdG3H/O/7z 3s1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679494132; h=subject:from:to:message-id:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cdNQE8gF7nxY1Sh1kNSg5XliRJh9fONbWmL8tpWK9og=; b=Y/JwDnL7vIk0LV2nmj3tPfzbcE/TEJYUu0fxzH2yUf++G+CNAoYUxG0SO+iQH4EfGp D01FOFAqv+g2igxG7x68YjmSTLyiqwiYidP0x4pggDdUz+DjRsJkM15nxYMyI8dOOTzd DkDaWXV8yRcxooncXo7OPRsPiNj2SGWZ1EjSkJmoWrBVxPQGRH8NU3s8HqmVtHijvVWh TbBgVzsPxhBRi9yN9dR/2nefLgWRDLb/uWfl7l/VWV4LJK354d0kTyOolN+oKJT/oldV bW9iNCZD8lriQfh6e1nkFtbgMAeWT/kDu/z19Ktoa95oDEs0xHvIXnSuqU56cCUKwrXt 4gTA== X-Gm-Message-State: AO0yUKX8jnQc+evcQF44LR3uSW/BSqnxC5JarNT0gImRrBpSZVuVjG6Z bgDWeVW5TzfOncUh9JkMbrI9WaR1RvHZGQ== X-Google-Smtp-Source: AK7set+AI/Y5yINQ8Jy/TG9UoTbMkQ5dkztGjQ62dXpcLU6d8/uxFIQMNZ5j22eVLX4/RxRtWe8ErQ== X-Received: by 2002:a05:6214:194d:b0:56c:376:3191 with SMTP id q13-20020a056214194d00b0056c03763191mr6287062qvk.44.1679494132175; Wed, 22 Mar 2023 07:08:52 -0700 (PDT) Received: from hurd (dsl-10-130-195.b2b2c.ca. [72.10.130.195]) by smtp.gmail.com with ESMTPSA id 141-20020a370793000000b0074672975d5csm7084107qkh.91.2023.03.22.07.08.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 07:08:51 -0700 (PDT) Date: Wed, 22 Mar 2023 10:08:50 -0400 Message-Id: <875yasj2tp.fsf@gmail.com> To: control@debbugs.gnu.org From: Maxim Cournoyer Subject: control message for bug #58086 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) merge 58086 61964 quit From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 22 10:13:15 2023 Received: (at 61964-done) by debbugs.gnu.org; 22 Mar 2023 14:13:16 +0000 Received: from localhost ([127.0.0.1]:36240 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pezDH-00085s-DQ for submit@debbugs.gnu.org; Wed, 22 Mar 2023 10:13:15 -0400 Received: from mail-qt1-f181.google.com ([209.85.160.181]:46981) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pezDC-00085S-CN; Wed, 22 Mar 2023 10:13:11 -0400 Received: by mail-qt1-f181.google.com with SMTP id c19so22696320qtn.13; Wed, 22 Mar 2023 07:13:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679494384; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=zmW7UCXZKNr8xskYaS8Wc9v5Bg8vnCPXA01QWkpvMOs=; b=DXKWlEWe8dkzLzDZgwvz5zIySJPJY77Wu8VbbVeM2dMXj5w8dV6gYKFIxIUZM2jleG W1iYkHXh6+yYy0UG7/EcseDCejdJe2OVQSQjsWBu9Hy3inrKkxsXCV45PI78yAvWAKfO sbgUOcCICWir6lDX7GskmSxAxgj8eq1x3CyhNtUdkVoqnCEgLcnnVMrEw9+NKpCBp/sl ksMcMtx+W4e8o8dkWbu6sqKFFIh9FSlZpCpvX2dKslkf3QEz/FO4Ngs8wHak6u6dFFgh ivEMXSj0Wi7B4iLPEV140gv5j0LkwjdYaZEyXUpyYrupaQ1G5x/iUpkHOvEYxWgbxYwp ekMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679494384; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zmW7UCXZKNr8xskYaS8Wc9v5Bg8vnCPXA01QWkpvMOs=; b=N/nA5ZJBVKOxJgWXK1qql7Upx60FzU4YgCWfdxgys7k9PUYTE7yYaWBPKuxME/XjQG a1qEw9MwiwA9MjDe+3UH3UXw2Lime1lolhStiCH/oNPr5o0FcGcKjCrznX29BAJAITTN Akma1BjHQpNvVB2HFIXPnmoV2QNxNs9nNI5dLS7sOB61N2dzHj1KnB7HqrNT8aVAlENL fBbHpVIZ7XCSgVhtP5rTbfyRKQLEuB3vQ3rmrnYSsNvGFiPub+t2sER5KUoj232+GNDQ bNG5FRD0VkRIm5s6yqIuN0YqOXRqohCnNI8uQgt40u1IOd6NSsziCJIBJlGrj71pGSNd PqLQ== X-Gm-Message-State: AO0yUKV/+bR9Ml8vOkr5GhKLpe6O1IC/ifh7GzTkQRXPk4lVP3/PXtkK qgv2SbE3vhOG+J3jvcRjf9SZpTpIMXZxYQ== X-Google-Smtp-Source: AK7set8vnO1FFYHNfGlTdK5KXT5luQxNG7+BxN0ZhOol/rDV1k4L4GMCuvPBrwAaHVawXGAeI4vABQ== X-Received: by 2002:ac8:5b4e:0:b0:3e0:8c58:1dd with SMTP id n14-20020ac85b4e000000b003e08c5801ddmr5518613qtw.55.1679494384475; Wed, 22 Mar 2023 07:13:04 -0700 (PDT) Received: from hurd (dsl-10-130-195.b2b2c.ca. [72.10.130.195]) by smtp.gmail.com with ESMTPSA id e1-20020ac84901000000b003d460ec242esm10168532qtq.81.2023.03.22.07.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 07:13:04 -0700 (PDT) From: Maxim Cournoyer To: Bruno Victal Subject: Re: bug#61964: [PATCH] services: Add fstrim-service-type. References: <9fec722b58c87211f019fa702a5c7047577bec64.1677952942.git.mirai@makinata.eu> <2be8cc336a7e56ee6c15a57548c3b7690803101f.1679485589.git.mirai@makinata.eu> Date: Wed, 22 Mar 2023 10:13:03 -0400 In-Reply-To: <2be8cc336a7e56ee6c15a57548c3b7690803101f.1679485589.git.mirai@makinata.eu> (Bruno Victal's message of "Wed, 22 Mar 2023 11:47:19 +0000") Message-ID: <874jqcj2mo.fsf_-_@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61964-done Cc: 61964-done@debbugs.gnu.org, 58086-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Bruno Victal writes: > * gnu/services/linux.scm (fstrim-service-type): New variable. > (fstrim-mcron-job, serialize-fstrim-configuration) > (fstrim-serialize-list-of-strings, fstrim-serialize-boolean): New procedure. > (mcron-time?): New predicate. > (fstrim-configuration): New record. > * doc/guix.texi (Linux Services): Document new fstrim-service-type. I've installed the change, with the following mostly cosmetic adjustments: --8<---------------cut here---------------start------------->8--- modified doc/guix.texi @@ -37493,7 +37493,7 @@ notifications. The command @command{fstrim} can be used to discard (or @dfn{trim}) unused blocks on a mounted file system. -@c This was copied from the fstrim manpage, with some texinfo touch-ups. +@c This was copied from the fstrim manpage, with some Texinfo touch-ups. @quotation Warning Running @command{fstrim} frequently, or even using @command{mount -o discard}, might negatively affect the lifetime of @@ -37540,8 +37540,8 @@ Verbose execution. Suppress error messages if trim operation (ioctl) is unsupported. @item @code{extra-arguments} (type: maybe-list-of-strings) -Extra options to append to @command{fstrim} command.@footnote{Run -@samp{man fstrim} for more information.} +Extra options to append to @command{fstrim} (run @samp{man fstrim} for +more information). @end table @end deftp modified gnu/services/linux.scm @@ -185,10 +185,9 @@ (define (fstrim-serialize-list-of-strings field-name value) (define-configuration fstrim-configuration (package - (file-like util-linux) - "The package providing the @command{fstrim} command." - empty-serializer) - + (file-like util-linux) + "The package providing the @command{fstrim} command." + empty-serializer) (schedule (mcron-time "0 0 * * 0") "Schedule for launching @command{fstrim}. This can be a procedure, a list @@ -196,8 +195,7 @@ (define-configuration fstrim-configuration Job specification, mcron, the mcron manual}. By default this is set to run weekly on Sunday at 00:00." empty-serializer) - - ;; fstrim options + ;; The following are fstrim-related options. (listed-in (maybe-list-of-strings '("/etc/fstab" "/proc/self/mountinfo")) ;; Note: documentation sourced from the fstrim manpage. @@ -205,27 +203,19 @@ (define-configuration fstrim-configuration empty files are silently ignored. The evaluation of the list @emph{stops} after the first non-empty file. File systems with @code{X-fstrim.notrim} mount option in fstab are skipped.") - (verbose? (boolean #t) "Verbose execution.") - (quiet-unsupported? (boolean #t) "Suppress error messages if trim operation (ioctl) is unsupported.") - (extra-arguments maybe-list-of-strings - ;; Tracked at: . - ;; FIXME@GUILE(TEXINFO): @footnote causes errors when calling - ;; configuration->documentation. - ;; > Throw to key `parser-error' with args `(#f "Unknown command" footnote)' - "Extra options to append to @command{fstrim} command.@footnote{Run -@samp{man fstrim} for more information.}" + "Extra options to append to @command{fstrim} (run @samp{man fstrim} for +more information)." (lambda (_ value) (if (maybe-value-set? value) value '()))) - (prefix fstrim-)) (define (serialize-fstrim-configuration config) --8<---------------cut here---------------end--------------->8--- Thank you! -- Maxim From unknown Sat Jun 14 19:29:24 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 21 Apr 2023 11:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator