Skip to contentSkip to conversation

bug 1872049 - integrity bitmap

PATCH Mikulas Patocka 1 participant 1 message Aug 31, 2020 1 message not in the archive Device mapper

lore
Share & tools
lore

Mikulas Patocka

author maintainer
#1 lore raw
In reply to a message not in the archive
Quoted 5 lines · David Teigland

Hi Mikulas, it looks to me like this bz could be a problem with the bitmap mode, since both Corey and I have seen unrepaired data without any crash, and the same tests work fine with journal mode. One clue might be that I did not see the problem if the corruption occured while the LV was inactive.

Hi

Here I'm submitting a patch for this bug. Try it.

Mikulas

From: Mikulas Patocka <[email protected]>
Subject: [PATCH] dm-integrity: fix error reporting in bitmap mode after creation

The dm-integrity target did not report errors in bitmap mode just after creation. The reason is that the function integrity_recalc didn't clean up ic->recalc_bitmap as it proceeded with recalculation. This patch makes it update the bitmap.

Fixes 468dfca38b1a ("dm integrity: add a bitmap mode")
---
 drivers/md/dm-integrity.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/md/dm-integrity.c +12 -0
Index: linux-2.6/drivers/md/dm-integrity.c
===================================================================
@@ -2487,6 +2487,7 @@ next_chunk:
 	range.logical_sector = le64_to_cpu(ic->sb->recalc_sector);
 	if (unlikely(range.logical_sector >= ic->provided_data_sectors)) {
 		if (ic->mode == 'B') {
+			block_bitmap_op(ic, ic->recalc_bitmap, 0, ic->provided_data_sectors, BITMAP_OP_CLEAR);
 			DEBUG_print("queue_delayed_work: bitmap_flush_work\n");
 			queue_delayed_work(ic->commit_wq, &ic->bitmap_flush_work, 0);
 		}
@@ -2564,6 +2565,17 @@ next_chunk:
 		goto err;
 	}
 
+	if (ic->mode == 'B') {
+		sector_t start, end;
+		start = range.logical_sector
+			>> (ic->sb->log2_sectors_per_block + ic->log2_blocks_per_bitmap_bit)
+			<< (ic->sb->log2_sectors_per_block + ic->log2_blocks_per_bitmap_bit);
+		end = (range.logical_sector + range.n_sectors)
+			>> (ic->sb->log2_sectors_per_block + ic->log2_blocks_per_bitmap_bit)
+			<< (ic->sb->log2_sectors_per_block + ic->log2_blocks_per_bitmap_bit);
+		block_bitmap_op(ic, ic->recalc_bitmap, start, end - start, BITMAP_OP_CLEAR);
+	}
+
 advance_and_next:
 	cond_resched();