[Drbd-dev] [PATCH 02/21] drbd: simplify drbd_md_set_sector_offsets()

Fabian Frederick fabf at skynet.be
Fri Nov 27 22:26:07 CET 2015


Some metadata informations were duplicated in layout switch.

Signed-off-by: Fabian Frederick <fabf at skynet.be>
---
 drivers/block/drbd/drbd_nl.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index c055c5e..ef136a9 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -794,20 +794,9 @@ static void drbd_md_set_sector_offsets(struct drbd_device *device,
 	unsigned int al_size_sect = bdev->md.al_size_4k * 8;
 
 	bdev->md.md_offset = drbd_md_ss(bdev);
+	md_size_sect = MD_128MB_SECT;
 
 	switch (bdev->md.meta_dev_idx) {
-	default:
-		/* v07 style fixed size indexed meta data */
-		bdev->md.md_size_sect = MD_128MB_SECT;
-		bdev->md.al_offset = MD_4kB_SECT;
-		bdev->md.bm_offset = MD_4kB_SECT + al_size_sect;
-		break;
-	case DRBD_MD_INDEX_FLEX_EXT:
-		/* just occupy the full device; unit: sectors */
-		bdev->md.md_size_sect = drbd_get_capacity(bdev->md_bdev);
-		bdev->md.al_offset = MD_4kB_SECT;
-		bdev->md.bm_offset = MD_4kB_SECT + al_size_sect;
-		break;
 	case DRBD_MD_INDEX_INTERNAL:
 	case DRBD_MD_INDEX_FLEX_INT:
 		/* al size is still fixed */
@@ -822,11 +811,20 @@ static void drbd_md_set_sector_offsets(struct drbd_device *device,
 		 * and the activity log; */
 		md_size_sect += MD_4kB_SECT + al_size_sect;
 
-		bdev->md.md_size_sect = md_size_sect;
 		/* bitmap offset is adjusted by 'super' block size */
 		bdev->md.bm_offset   = -md_size_sect + MD_4kB_SECT;
 		break;
+	case DRBD_MD_INDEX_FLEX_EXT:
+		/* just occupy the full device; unit: sectors */
+		md_size_sect = drbd_get_capacity(bdev->md_bdev);
+	default:
+		/* v07 style fixed size indexed meta data */
+		bdev->md.al_offset = MD_4kB_SECT;
+		bdev->md.bm_offset = MD_4kB_SECT + al_size_sect;
+		break;
 	}
+
+	bdev->md.md_size_sect = md_size_sect;
 }
 
 /* input size is expected to be in KB */
-- 
2.1.4



More information about the drbd-dev mailing list