]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
dm-integrity: Do not emit journal configuration in DM table for Inline mode
authorMilan Broz <gmazyland@gmail.com>
Sun, 16 Feb 2025 10:42:10 +0000 (11:42 +0100)
committerMikulas Patocka <mpatocka@redhat.com>
Mon, 17 Feb 2025 10:33:41 +0000 (11:33 +0100)
The Inline mode does not use a journal; it makes no sense to print
journal information in DM table. Print it only if the journal is used.

The same applies to interleave_sectors (unused for Inline mode).

Also, add comments for arg_count, as the current calculation
is quite obscure.

Signed-off-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/dm-integrity.c

index 555dc06b94228775de79fabdebe2705e258183a0..c45464b6576aaf20d2e1f2d0028fc98d4f69ccd5 100644 (file)
@@ -3790,16 +3790,18 @@ static void dm_integrity_status(struct dm_target *ti, status_type_t type,
                break;
 
        case STATUSTYPE_TABLE: {
-               arg_count = 3;
+               arg_count = 1; /* buffer_sectors */
                arg_count += !!ic->meta_dev;
                arg_count += ic->sectors_per_block != 1;
                arg_count += !!(ic->sb->flags & cpu_to_le32(SB_FLAG_RECALCULATING));
                arg_count += ic->reset_recalculate_flag;
                arg_count += ic->discard;
-               arg_count += ic->mode == 'J';
-               arg_count += ic->mode == 'J';
-               arg_count += ic->mode == 'B';
-               arg_count += ic->mode == 'B';
+               arg_count += ic->mode != 'I'; /* interleave_sectors */
+               arg_count += ic->mode == 'J'; /* journal_sectors */
+               arg_count += ic->mode == 'J'; /* journal_watermark */
+               arg_count += ic->mode == 'J'; /* commit_time */
+               arg_count += ic->mode == 'B'; /* sectors_per_bit */
+               arg_count += ic->mode == 'B'; /* bitmap_flush_interval */
                arg_count += !!ic->internal_hash_alg.alg_string;
                arg_count += !!ic->journal_crypt_alg.alg_string;
                arg_count += !!ic->journal_mac_alg.alg_string;
@@ -3818,14 +3820,15 @@ static void dm_integrity_status(struct dm_target *ti, status_type_t type,
                        DMEMIT(" reset_recalculate");
                if (ic->discard)
                        DMEMIT(" allow_discards");
-               DMEMIT(" journal_sectors:%u", ic->initial_sectors - SB_SECTORS);
-               DMEMIT(" interleave_sectors:%u", 1U << ic->sb->log2_interleave_sectors);
+               if (ic->mode != 'I')
+                       DMEMIT(" interleave_sectors:%u", 1U << ic->sb->log2_interleave_sectors);
                DMEMIT(" buffer_sectors:%u", 1U << ic->log2_buffer_sectors);
                if (ic->mode == 'J') {
                        __u64 watermark_percentage = (__u64)(ic->journal_entries - ic->free_sectors_threshold) * 100;
 
                        watermark_percentage += ic->journal_entries / 2;
                        do_div(watermark_percentage, ic->journal_entries);
+                       DMEMIT(" journal_sectors:%u", ic->initial_sectors - SB_SECTORS);
                        DMEMIT(" journal_watermark:%u", (unsigned int)watermark_percentage);
                        DMEMIT(" commit_time:%u", ic->autocommit_msec);
                }