GNU bug report logs - #58086
[PATCH] gnu: Add fstrim-service-type.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: iyzsong@HIDDEN; Keywords: patch moreinfo; merged with #61964; Done: Maxim Cournoyer <maxim.cournoyer@HIDDEN>; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 58086-done <at> debbugs.gnu.org:


Received: (at 58086-done) by debbugs.gnu.org; 22 Mar 2023 14:13:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 22 10:13:12 2023
Received: from localhost ([127.0.0.1]:36238 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pezDD-00085i-Tb
	for submit <at> debbugs.gnu.org; Wed, 22 Mar 2023 10:13:12 -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 <maxim.cournoyer@HIDDEN>)
 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 <maxim.cournoyer@HIDDEN>
To: Bruno Victal <mirai@HIDDEN>
Subject: Re: bug#61964: [PATCH] services: Add fstrim-service-type.
References: <9fec722b58c87211f019fa702a5c7047577bec64.1677952942.git.mirai@HIDDEN>
 <2be8cc336a7e56ee6c15a57548c3b7690803101f.1679485589.git.mirai@HIDDEN>
Date: Wed, 22 Mar 2023 10:13:03 -0400
In-Reply-To: <2be8cc336a7e56ee6c15a57548c3b7690803101f.1679485589.git.mirai@HIDDEN>
 (Bruno Victal's message of "Wed, 22 Mar 2023 11:47:19 +0000")
Message-ID: <874jqcj2mo.fsf_-_@HIDDEN>
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: 58086-done
Cc: 61964-done <at> debbugs.gnu.org, 58086-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi,

Bruno Victal <mirai@HIDDEN> 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: <https://issues.guix.gnu.org/62374>.
-   ;; 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




Notification sent to Bruno Victal <mirai@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Maxim Cournoyer <maxim.cournoyer@HIDDEN>:
You have taken responsibility. Full text available.

Message received at 58086-done <at> debbugs.gnu.org:


Received: (at 58086-done) by debbugs.gnu.org; 22 Mar 2023 14:13:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 22 10:13:12 2023
Received: from localhost ([127.0.0.1]:36238 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pezDD-00085i-Tb
	for submit <at> debbugs.gnu.org; Wed, 22 Mar 2023 10:13:12 -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 <maxim.cournoyer@HIDDEN>)
 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 <maxim.cournoyer@HIDDEN>
To: Bruno Victal <mirai@HIDDEN>
Subject: Re: bug#61964: [PATCH] services: Add fstrim-service-type.
References: <9fec722b58c87211f019fa702a5c7047577bec64.1677952942.git.mirai@HIDDEN>
 <2be8cc336a7e56ee6c15a57548c3b7690803101f.1679485589.git.mirai@HIDDEN>
Date: Wed, 22 Mar 2023 10:13:03 -0400
In-Reply-To: <2be8cc336a7e56ee6c15a57548c3b7690803101f.1679485589.git.mirai@HIDDEN>
 (Bruno Victal's message of "Wed, 22 Mar 2023 11:47:19 +0000")
Message-ID: <874jqcj2mo.fsf_-_@HIDDEN>
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: 58086-done
Cc: 61964-done <at> debbugs.gnu.org, 58086-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi,

Bruno Victal <mirai@HIDDEN> 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: <https://issues.guix.gnu.org/62374>.
-   ;; 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




Notification sent to iyzsong@HIDDEN:
bug acknowledged by developer. Full text available.
Reply sent to Maxim Cournoyer <maxim.cournoyer@HIDDEN>:
You have taken responsibility. Full text available.
Merged 58086 61964. Request was from Maxim Cournoyer <maxim.cournoyer@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 58086 <at> debbugs.gnu.org:


Received: (at 58086) by debbugs.gnu.org; 22 Mar 2023 12:03:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 22 08:03:56 2023
Received: from localhost ([127.0.0.1]:33706 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pexC8-0007db-Dm
	for submit <at> debbugs.gnu.org; Wed, 22 Mar 2023 08:03:56 -0400
Received: from smtpm2.myservices.hosting ([185.26.105.233]:34810)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1pexC7-0007dU-2k
 for 58086 <at> debbugs.gnu.org; Wed, 22 Mar 2023 08:03:55 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm2.myservices.hosting (Postfix) with ESMTP id 7068920F38;
 Wed, 22 Mar 2023 13:03:53 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 2775D800A3;
 Wed, 22 Mar 2023 13:03:50 +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 0LZ-bNZ6mPMW; Wed, 22 Mar 2023 13:03:49 +0100 (CET)
Received: from [192.168.1.239] (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id BD0CB800A1;
 Wed, 22 Mar 2023 13:03:48 +0100 (CET)
Message-ID: <1a1991d3-afc0-4e2b-50a4-dfad763907f7@HIDDEN>
Date: Wed, 22 Mar 2023 12:03:44 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.8.0
Subject: Re: [bug#58086] [PATCH] gnu: Add fstrim-service-type.
Content-Language: en-US
To: iyzsong@HIDDEN
References: <20220926072825.4689-1-iyzsong@HIDDEN>
From: Bruno Victal <mirai@HIDDEN>
In-Reply-To: <20220926072825.4689-1-iyzsong@HIDDEN>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -1.1 (-)
X-Debbugs-Envelope-To: 58086
Cc: =?UTF-8?Q?Ludovic_Court=c3=a8s?= <ludo@HIDDEN>, 58086 <at> debbugs.gnu.org,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.1 (--)

Hi 宋文武,

I didn't notice this patch and ended up reimplementing another fstrim-service-type at [1].
Where we differ in the implementations:
* I didn't attempt to implement anacron capabilities, since I made the scheduling configurable.
* Uses define-configuration which can embed documentation and generate it for the manual.
* Slightly more “guix-y” style of configuration.


[1]: <https://issues.guix.gnu.org/61964>


Apologies for the duplicated effort!


Cheers,
Bruno




Information forwarded to guix-patches@HIDDEN:
bug#58086; Package guix-patches. Full text available.
Added tag(s) moreinfo. Request was from Christopher Baines <mail@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 58086 <at> debbugs.gnu.org:


Received: (at 58086) by debbugs.gnu.org; 6 Oct 2022 21:00:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 06 17:00:24 2022
Received: from localhost ([127.0.0.1]:33655 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ogXyh-0005Lj-N2
	for submit <at> debbugs.gnu.org; Thu, 06 Oct 2022 17:00:24 -0400
Received: from eggs.gnu.org ([209.51.188.92]:38740)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1ogXyb-0005LQ-Qw
 for 58086 <at> debbugs.gnu.org; Thu, 06 Oct 2022 17:00:21 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:48526)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1ogXyV-0001b8-Ns; Thu, 06 Oct 2022 17:00:11 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To:
 From; bh=n5a+n3bvghe6R4u4WwEVb/3FK5BW+Ew4yefy5D4Siqw=; b=F5G8fWwDGnYI78LTBwDp
 7gqQjNrwkwTujNxQL6arQkVnrs6s/dHgD0IuCB4EjmbUZGjUD7UbuWIhaDD4RUXixE+azv8TPCjDZ
 cHN4o5zInd7te7WtfOsqGONXL5tYWW+0pMrdj2n455yJ1GF5Jfp/d2WKfewCRKOnjRZ/Xc5zr5YGY
 wgHLcLf79bj6FhB1iSrHiG7AYMZM6jPLufEyKw9vow9cvHT4X1hRIAQOjMbg09DYouPZWKyHrm636
 C5ruzAKnVnH3DDD28KHCS7kzc0lkWAEFKO6A4T4ES6YCFRmXcVWSFHomZHRxGyaHTx3BqzP1RXJ7B
 cn0tsCFwsg452w==;
Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:59648
 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1ogXyV-0006Xn-4N; Thu, 06 Oct 2022 17:00:11 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: iyzsong@HIDDEN
Subject: Re: bug#58086: [PATCH] gnu: Add fstrim-service-type.
References: <20220926072825.4689-1-iyzsong@HIDDEN>
Date: Thu, 06 Oct 2022 23:00:08 +0200
In-Reply-To: <20220926072825.4689-1-iyzsong@HIDDEN> (iyzsong@HIDDEN's
 message of "Mon, 26 Sep 2022 15:28:25 +0800")
Message-ID: <87a668hdlz.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 58086
Cc: =?utf-8?B?5a6L5paH5q2m?= <iyzsong@HIDDEN>, 58086 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi,

iyzsong@HIDDEN skribis:

> From: =E5=AE=8B=E6=96=87=E6=AD=A6 <iyzsong@HIDDEN>
>
> A timestamp file "/var/lib/mcron/fstrim.stamp" is used to ensure we will
> catch up on missed job runs when the system was powered down.
>
> * gnu/services/mcron.scm (%mcron-activation): New extension to create
> '/var/lib/mcron'.
> * gnu/services/admin.scm (fstrim-configuration): New record type.
> (fstrim-mcron-jobs): New procedure.
> (fstrim-service-type): New service type.

Please add documentation in doc/guix.texi.  :-)


[...]

> +(define fstrim-mcron-jobs
> +  (match-lambda
> +    (($ <fstrim-configuration> command interval)
> +     (list
> +      #~(job
> +         (let ((last-time
> +                (catch #t
> +                  (lambda ()
> +                    (with-input-from-file #$fstrim-mcron-stamp read))
> +                  ;; We schedule a first run immediately.
> +                  (const 0))))
> +           (lambda (current-time)
> +             (let ((next-time (max current-time (+ #$interval last-time)=
)))
> +               (set! last-time next-time)
> +               next-time)))
> +         (lambda ()
> +           (apply system* '#$command)
> +           (with-output-to-file #$fstrim-mcron-stamp
> +             (lambda () (write (current-time))))))))))

That seems a little bit complicated, no?  That=E2=80=99s because you want to
make sure it runs immediately at boot if it never ran before, right?  Is
that important?

> +(define fstrim-service-type
> +  (service-type
> +   (name 'fstrim)
> +   (extensions
> +    (list (service-extension mcron-service-type
> +                             fstrim-mcron-jobs)))
> +   (description
> +    "Periodically discard unused blocks on filesystems.")

=E2=80=9Cfile systems=E2=80=9D, two words.  Perhaps add a few more words me=
ntioning the
fstrim package?

> +++ b/gnu/services/mcron.scm
> @@ -154,6 +154,12 @@ (define mcron-shepherd-services
>                (actions
>                 (list (shepherd-schedule-action mcron files)))))))))
>=20=20
> +(define %mcron-activation
> +  (with-imported-modules '((guix build utils))
> +    #~(begin
> +        (use-modules (guix build utils))
> +        (mkdir-p "/var/lib/mcron"))))

I=E2=80=99m not sure the fstrim timestamp should leave in a directory that =
looks
as if it was =E2=80=9Cowned=E2=80=9D by mcron.

Could you send an updated patch?

Thanks,
Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#58086; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 26 Sep 2022 07:28:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 26 03:28:44 2022
Received: from localhost ([127.0.0.1]:49137 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ociXk-0008HD-Bj
	for submit <at> debbugs.gnu.org; Mon, 26 Sep 2022 03:28:44 -0400
Received: from lists.gnu.org ([209.51.188.17]:44722)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <iyzsong@HIDDEN>) id 1ociXh-0008H3-EN
 for submit <at> debbugs.gnu.org; Mon, 26 Sep 2022 03:28:43 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:51722)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <iyzsong@HIDDEN>) id 1ociXh-00023o-8j
 for guix-patches@HIDDEN; Mon, 26 Sep 2022 03:28:41 -0400
Received: from mail.envs.net ([5.199.136.28]:36160)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <iyzsong@HIDDEN>) id 1ociXf-00063j-9D
 for guix-patches@HIDDEN; Mon, 26 Sep 2022 03:28:40 -0400
Received: from localhost (mail.envs.net [127.0.0.1])
 by mail.envs.net (Postfix) with ESMTP id 9384938A0FAF;
 Mon, 26 Sep 2022 07:28:27 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=envs.net; s=modoboa;
 t=1664177307; bh=9/+nvn8WChAUUV+3J7HnA2dmlJjtknS7GG63KUWr3Y4=;
 h=From:To:Cc:Subject:Date:From;
 b=p0OOb0EMde0lm0sroadJDxsHWtZjD7x/xbFjEjrYCIq0oh3TZcoVftEzKWd8Hc8EV
 td3kVvUn7BUhhBdqHmDiUf61qPC5E9t8ceVZpGNX2/NElLOzT2H9bYf88C6Y+O9FbN
 n4Fh9yv/Ct8IcZZFx+NfU0Z/PfH2xMAKt0oXtZG7131nhQxYeb1LrwYPhqhwxE+X+w
 Y/1K4dSVX1GWNiaGM6TR1USWXa0OBBfXDwhHWI+HHaUN3gKANAkf492Yoi7ntK/7h9
 MAsUyAvsljp9/zIZQc8Wb72Rec8yhPR8bqzKo03XOj5hCoLRorz4ThuH89YQwsWAft
 6sgLlVo/KkdnHfr7N1BaIlM8C3d15f1e1nqdJwiwzpcE0s9Ob/Nr4L10sSyfOJh/V1
 oT+SnlY3TbUlsZCw1vYUyxdmXwvjvb/oTHWuXPfGQOKza9hrxzTLOtf8uOzeKi0Gbz
 RtRGRAu4o76CxT0y64R3ZX4VOThxvMMvTY8Q+WWJeblyJ8wHHv49KA5jZccDqFdLUz
 tI5f1X4VAkcbI0R33ClhqGlUjcmg22qX301k9eptQ3CQ6y762KzwI9Sjb60Rq8416y
 F9hFpX+5x6nNfveQ3sH4ZHiL5k4+qCuZlS0WoXlElaBmRaxiqXBSPFnHFFnL6Bkzed
 6000qHgu3rIYeYBJeGlhW4fY=
X-Virus-Scanned: Debian amavisd-new at mail.envs.net
Received: from mail.envs.net ([127.0.0.1])
 by localhost (mail.envs.net [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id 2kjrR0VJni_Q; Mon, 26 Sep 2022 07:28:24 +0000 (UTC)
Received: from localhost (unknown [182.150.116.135])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest
 SHA256) (No client certificate requested)
 by mail.envs.net (Postfix) with ESMTPSA;
 Mon, 26 Sep 2022 07:28:24 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
 by localhost (OpenSMTPD) with ESMTP id efc52026;
 Mon, 26 Sep 2022 07:28:27 +0000 (UTC)
From: iyzsong@HIDDEN
To: guix-patches@HIDDEN
Subject: [PATCH] gnu: Add fstrim-service-type.
Date: Mon, 26 Sep 2022 15:28:25 +0800
Message-Id: <20220926072825.4689-1-iyzsong@HIDDEN>
X-Mailer: git-send-email 2.37.3
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=5.199.136.28; envelope-from=iyzsong@HIDDEN;
 helo=mail.envs.net
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
Cc: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

From: 宋文武 <iyzsong@HIDDEN>

A timestamp file "/var/lib/mcron/fstrim.stamp" is used to ensure we will
catch up on missed job runs when the system was powered down.

* gnu/services/mcron.scm (%mcron-activation): New extension to create
'/var/lib/mcron'.
* gnu/services/admin.scm (fstrim-configuration): New record type.
(fstrim-mcron-jobs): New procedure.
(fstrim-service-type): New service type.
---
 gnu/services/admin.scm | 56 +++++++++++++++++++++++++++++++++++++++++-
 gnu/services/mcron.scm |  8 ++++++
 2 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 252bedb0bd..2b22fc5b33 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -21,6 +21,7 @@
 (define-module (gnu services admin)
   #:use-module (gnu packages admin)
   #:use-module (gnu packages certs)
+  #:use-module (gnu packages linux)
   #:use-module (gnu packages package-management)
   #:use-module (gnu services)
   #:use-module (gnu services mcron)
@@ -30,6 +31,7 @@ (define-module (gnu services admin)
   #:use-module (guix packages)
   #:use-module (guix records)
   #:use-module (srfi srfi-1)
+  #:use-module (ice-9 match)
   #:use-module (ice-9 vlist)
   #:export (%default-rotations
             %rotated-files
@@ -63,7 +65,11 @@ (define-module (gnu services admin)
             unattended-upgrade-configuration-services-to-restart
             unattended-upgrade-configuration-system-expiration
             unattended-upgrade-configuration-maximum-duration
-            unattended-upgrade-configuration-log-file))
+            unattended-upgrade-configuration-log-file
+
+            fstrim-service-type
+            fstrim-configuration
+            fstrim-configuration?))
 
 ;;; Commentary:
 ;;;
@@ -376,4 +382,52 @@ (define unattended-upgrade-service-type
     "Periodically upgrade the system from the current configuration.")
    (default-value (unattended-upgrade-configuration))))
 
+
+;;;
+;;; fstrim.
+;;;
+
+(define-record-type* <fstrim-configuration>
+  fstrim-configuration make-fstrim-configuration fstrim-configuration?
+  (command  fstrim-configuration-command
+            (default
+              (list (file-append util-linux "/sbin/fstrim")
+                    "--verbose" "--quiet-unsupported"
+                    "--listed-in" "/etc/fstab")))
+  (interval fstrim-configuration-interval (default (* 60 60 24 7)))) ; weekly
+
+;;; By storing the time of job's last run in a file, we can catch up on missed
+;;; runs when the system was powered down.
+(define fstrim-mcron-stamp "/var/lib/mcron/fstrim.stamp")
+
+(define fstrim-mcron-jobs
+  (match-lambda
+    (($ <fstrim-configuration> command interval)
+     (list
+      #~(job
+         (let ((last-time
+                (catch #t
+                  (lambda ()
+                    (with-input-from-file #$fstrim-mcron-stamp read))
+                  ;; We schedule a first run immediately.
+                  (const 0))))
+           (lambda (current-time)
+             (let ((next-time (max current-time (+ #$interval last-time))))
+               (set! last-time next-time)
+               next-time)))
+         (lambda ()
+           (apply system* '#$command)
+           (with-output-to-file #$fstrim-mcron-stamp
+             (lambda () (write (current-time))))))))))
+
+(define fstrim-service-type
+  (service-type
+   (name 'fstrim)
+   (extensions
+    (list (service-extension mcron-service-type
+                             fstrim-mcron-jobs)))
+   (description
+    "Periodically discard unused blocks on filesystems.")
+   (default-value (fstrim-configuration))))
+
 ;;; admin.scm ends here
diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm
index 23760ebda4..833d979ab4 100644
--- a/gnu/services/mcron.scm
+++ b/gnu/services/mcron.scm
@@ -154,6 +154,12 @@ (define mcron-shepherd-services
               (actions
                (list (shepherd-schedule-action mcron files)))))))))
 
+(define %mcron-activation
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+        (mkdir-p "/var/lib/mcron"))))
+
 (define mcron-service-type
   (service-type (name 'mcron)
                 (description
@@ -161,6 +167,8 @@ (define mcron-service-type
                 (extensions
                  (list (service-extension shepherd-root-service-type
                                           mcron-shepherd-services)
+                       (service-extension activation-service-type
+                                          (const %mcron-activation))
                        (service-extension profile-service-type
                                           (compose list
                                                    mcron-configuration-mcron))))
-- 
2.37.3





Acknowledgement sent to iyzsong@HIDDEN:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#58086; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 22 Mar 2023 14:15:02 UTC

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