From 5c8a88356d436f6a87e2c40347dd19d6f5b50198 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 15 Jul 2019 12:07:42 +0200 Subject: libblkid: (drbd) simplify padding We do not need all the metadata and it seems the extra padding is problematic in some cases. Let's keep is simple and use fixed offset for the metadata rather than sizeof(). References: https://github.com/karelzak/util-linux/pull/820 Signed-off-by: Karel Zak --- libblkid/src/superblocks/drbd.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libblkid/src/superblocks/drbd.c b/libblkid/src/superblocks/drbd.c index c27a8b384..000a34879 100644 --- a/libblkid/src/superblocks/drbd.c +++ b/libblkid/src/superblocks/drbd.c @@ -45,6 +45,13 @@ enum drbd_uuid_index { UI_EXTENDED_SIZE /* Everything. */ }; + +/* + * Used by libblkid to avoid unnecessary padding at the end of the structs and + * too large unused structs in memory. + */ +#define DRBD_MD_OFFSET 4096 + /* * user/shared/drbdmeta.c * Minor modifications wrt. types @@ -63,7 +70,8 @@ struct md_on_disk_08 { uint32_t bm_bytes_per_bit; uint32_t reserved_u32[4]; - char reserved[8 * 512 - (8*(UI_SIZE+3)+4*11)]; + /** Unnecessary for libblkid ** + * char reserved[8 * 512 - (8*(UI_SIZE+3)+4*11)]; */ }; /* @@ -109,7 +117,9 @@ struct meta_data_on_disk_9 { struct peer_dev_md_on_disk_9 peers[DRBD_PEERS_MAX]; uint64_t history_uuids[HISTORY_UUIDS]; - uint8_t padding[2704]; + /** Unnecessary for libblkid ** + * char padding[0] __attribute__((aligned(4096))); + */ } __attribute__((packed)); @@ -118,7 +128,7 @@ static int probe_drbd_84(blkid_probe pr) struct md_on_disk_08 *md; off_t off; - off = pr->size - sizeof(*md); + off = pr->size - DRBD_MD_OFFSET; /* Small devices cannot be drbd (?) */ if (pr->size < 0x10000) @@ -159,7 +169,7 @@ static int probe_drbd_90(blkid_probe pr) struct meta_data_on_disk_9 *md; off_t off; - off = pr->size - sizeof(*md); + off = pr->size - DRBD_MD_OFFSET; /* * Smaller ones are certainly not DRBD9 devices. -- cgit v1.2.3-55-g7522