<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">When a mirror is reduced in size, clear the part of the bitmap that is
no longer used.

Signed-Off-By: Alasdair G Kergon &lt;agk@redhat.com&gt;

Index: linux-2.6.17/drivers/md/dm-log.c
===================================================================
--- linux-2.6.17.orig/drivers/md/dm-log.c	2006-06-21 17:17:56.000000000 +0100
+++ linux-2.6.17/drivers/md/dm-log.c	2006-06-21 17:17:56.000000000 +0100
@@ -447,7 +447,7 @@ static int disk_resume(struct dirty_log 
 	if (r)
 		return r;
 
-	/* set or clear any new bits */
+	/* set or clear any new bits -- device has grown */
 	if (lc-&gt;sync == NOSYNC)
 		for (i = lc-&gt;header.nr_regions; i &lt; lc-&gt;region_count; i++)
 			/* FIXME: amazingly inefficient */
@@ -457,6 +457,10 @@ static int disk_resume(struct dirty_log 
 			/* FIXME: amazingly inefficient */
 			log_clear_bit(lc, lc-&gt;clean_bits, i);
 
+	/* clear any old bits -- device has shrunk */
+	for (i = lc-&gt;region_count; i % (sizeof(*lc-&gt;clean_bits) &lt;&lt; BYTE_SHIFT); i++)
+		log_clear_bit(lc, lc-&gt;clean_bits, i);
+
 	/* copy clean across to sync */
 	memcpy(lc-&gt;sync_bits, lc-&gt;clean_bits, size);
 	lc-&gt;sync_count = count_bits32(lc-&gt;clean_bits, lc-&gt;bitset_uint32_count);
</pre></body></html>