// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2023 Red Hat
*/
#include "encodings.h"
#include <linux/log2.h>
#include "logger.h"
#include "memory-alloc.h"
#include "permassert.h"
#include "constants.h"
#include "status-codes.h"
#include "types.h"
/** The maximum logical space is 4 petabytes, which is 1 terablock. */
static const block_count_t MAXIMUM_VDO_LOGICAL_BLOCKS = 1024ULL * 1024 * 1024 * 1024;
/** The maximum physical space is 256 terabytes, which is 64 gigablocks. */
static const block_count_t MAXIMUM_VDO_PHYSICAL_BLOCKS = 1024ULL * 1024 * 1024 * 64;
struct geometry_block {
char magic_number[VDO_GEOMETRY_MAGIC_NUMBER_SIZE];
struct packed_header header;
u32 checksum;
} __packed;
static const struct header GEOMETRY_BLOCK_HEADER_5_0 = {
.id = VDO_GEOMETRY_BLOCK,
.version = {
.major_version = 5,
.minor_version = 0,
},
/*
* Note: this size isn't just the payload size following the header, like it is everywhere
* else in VDO.
*/
.size = sizeof(struct geometry_block) + sizeof(struct volume_geometry),
};
static const struct header GEOMETRY_BLOCK_HEADER_4_0 = {
.id = VDO_GEOMETRY_BLOCK,
.version = {
.major_version = 4,
.minor_version = 0,
},
/*
* Note: this size isn't just the payload size following the header, like it is everywhere
* else in VDO.
*/
.size = sizeof(struct geometry_block) + sizeof