Skip to contentSkip to conversation

md add bitmap support

PATCH New Jonathan Brassow 1 participant 1 message Dec 3, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 md add bitmap support

Patch name: md-add-bitmap-support.patch

Add bitmap support to the device-mapper specific metadata area.

Bitmaps are now created and written, but they are not honored when the array is started and I don't know why yet.

drivers/md/md.c +16 -1
Index: linux-2.6/drivers/md/md.c
===================================================================
@@ -1802,9 +1802,24 @@ static int super_2_load(mdk_rdev_t *rdev
 
 	sb = (struct mdp_superblock_2 *)page_address(rdev->sb_page);
 	if (sb->magic != cpu_to_le32(MD_DM_SB_MAGIC)) {
+		/*
+		 * If we are in this function at all, it means that
+		 * the device-mapper interface is being used /and/
+		 * metadata devices have been allocated and specified.
+		 *
+		 * If no superblock has been found, then we must create
+		 * a new one - including a new bitmap.  First, populate
+		 * the superblock with good info.  Then set the bitmap's
+		 * chunksize, which has the effect of notifying 'bitmap_create'
+		 * to allocate the bitmap's superblock page.  Finally,
+		 * ensure that the changes will be written by setting
+		 * MD_CHANGE_DEVS.
+		 */
 		printk(KERN_INFO "  Superblock not found: creating new\n");
 		super_2_sync(rdev->mddev, rdev);
 
+		rdev->mddev->bitmap_info.chunksize = rdev->mddev->chunk_sectors;
+
 		/* Force new superblocks to disk */
 		set_bit(MD_CHANGE_DEVS, &rdev->mddev->flags);
 
@@ -1865,7 +1880,7 @@ static int super_2_validate(mddev_t *mdd
 		}
 	}
 
-	rdev->mddev->bitmap_info.offset = 0; /* disable bitmap creation */
+	mddev->bitmap_info.offset = 1024 >> 9; /* enable bitmap creation */
 	rdev->mddev->bitmap_info.default_offset = 1024 >> 9;
 
 	/*
drivers/md/bitmap.c +100 -3

121 lines not on this page · raw message