summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2019-07-15 12:07:42 +0200
committerKarel Zak2019-07-15 12:07:42 +0200
commit5c8a88356d436f6a87e2c40347dd19d6f5b50198 (patch)
tree34183f9e7d0e9f81db4e3a59d68589bfe845c104
parentMerge branch '2019wk27' of https://github.com/kerolasa/util-linux (diff)
downloadkernel-qcow2-util-linux-5c8a88356d436f6a87e2c40347dd19d6f5b50198.tar.gz
kernel-qcow2-util-linux-5c8a88356d436f6a87e2c40347dd19d6f5b50198.tar.xz
kernel-qcow2-util-linux-5c8a88356d436f6a87e2c40347dd19d6f5b50198.zip
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 <kzak@redhat.com>
-rw-r--r--libblkid/src/superblocks/drbd.c18
1 files 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.