]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
integritysetup: support mode=(journal|bitmap|direct)
authorAlfred Klomp <git@alfredklomp.com>
Thu, 8 Jun 2023 11:26:24 +0000 (13:26 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 8 Jun 2023 19:21:59 +0000 (20:21 +0100)
Add a parameter to the integritytab file to set the mode in which to
open the integrity volume. The mode can be journaled (the default),
bitmap without a journal, or direct mode without a journal or a bitmap.

This change removes the `no-journal' option because it is redundant,
being replaced with `mode=direct'.

Supercedes commit bcc1ee56c, from a week ago, which implemented
`no-journal'.

Resolves #27587

man/integritytab.xml
src/integritysetup/integrity-util.c

index 44da039ddecf9dce658a9d5c8ec9612b5e2c00a1..12ec2933a9d595ee7eb650cb8931e5d1674bf4b9 100644 (file)
       </varlistentry>
 
       <varlistentry>
-        <term><option>no-journal</option></term>
+        <term><option>mode=(journal|bitmap|direct)</option></term>
 
         <listitem><para>
-        Disable the journal. Corresponds to the "direct writes" mode documented in
+        Enable journaled, bitmapped or direct (passthrough) mode. Journaled mode is the default when this option is not specified.
+        It provides safety against crashes, but can be slow because all data has to be written twice.
+        Bitmap mode is more efficient since it requires only a single write, but it is less reliable because if data corruption happens when the machine crashes, it may not be detected.
+        Direct mode disables the journal and the bitmap. Corresponds to the "direct writes" mode documented in
         <ulink url="https://docs.kernel.org/admin-guide/device-mapper/dm-integrity.html">the dm-integrity documentation</ulink>.
         Note that without a journal, if there is a crash, it is possible that the integrity tags and data will not match. If used, the journal-*
         options below will have no effect if passed.
index 66f93e7d2eb2f86d0f5880c936a5e8116d99131f..c29d4fcd5da847a5da276b23b06e3a72c24b2f6e 100644 (file)
@@ -34,9 +34,22 @@ int parse_integrity_options(
                 else if (streq(word, "allow-discards")) {
                         if (ret_activate_flags)
                                 *ret_activate_flags |= CRYPT_ACTIVATE_ALLOW_DISCARDS;
-                } else if (streq(word, "no-journal")) {
-                        if (ret_activate_flags)
-                                *ret_activate_flags |= CRYPT_ACTIVATE_NO_JOURNAL;
+                } else if ((val = startswith(word, "mode="))) {
+                        if (streq(val, "journal")) {
+                                if (ret_activate_flags)
+                                        *ret_activate_flags &= ~(CRYPT_ACTIVATE_NO_JOURNAL | CRYPT_ACTIVATE_NO_JOURNAL_BITMAP);
+                        } else if (streq(val, "bitmap")) {
+                                if (ret_activate_flags) {
+                                        *ret_activate_flags &= ~CRYPT_ACTIVATE_NO_JOURNAL;
+                                        *ret_activate_flags |= CRYPT_ACTIVATE_NO_JOURNAL_BITMAP;
+                                }
+                        } else if (streq(val, "direct")) {
+                                if (ret_activate_flags) {
+                                        *ret_activate_flags |= CRYPT_ACTIVATE_NO_JOURNAL;
+                                        *ret_activate_flags &= ~CRYPT_ACTIVATE_NO_JOURNAL_BITMAP;
+                                }
+                        } else
+                                log_warning("Encountered unknown mode option '%s', ignoring.", val);
                 } else if ((val = startswith(word, "journal-watermark="))) {
                         r = parse_percent(val);
                         if (r < 0)