]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: (drbd) simplify padding
authorKarel Zak <kzak@redhat.com>
Mon, 15 Jul 2019 10:07:42 +0000 (12:07 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 15 Jul 2019 10:07:42 +0000 (12:07 +0200)
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 <kzak@redhat.com>
libblkid/src/superblocks/drbd.c

index c27a8b3843a67fc6b7ea88f26a59b4c4a554392a..000a34879077dbd60d40e027817e8f80f5ff984e 100644 (file)
@@ -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.