Add metadata superblock and check it on start

Refuse to start if the superblock is missing or bad version;
zero out the metadata area when initializing superblock.
This commit is contained in:
Vitaliy Filippov
2021-04-10 22:26:17 +03:00
parent f684d9101a
commit 2a02f3c4c7
5 changed files with 152 additions and 27 deletions
+17
View File
@@ -78,6 +78,23 @@
#include "blockstore_journal.h"
// "VITAstor"
#define BLOCKSTORE_META_MAGIC 0x726F747341544956l
#define BLOCKSTORE_META_VERSION 1
// metadata header (superblock)
// FIXME: After adding the OSD superblock, add a key to metadata
// and journal headers to check if they belong to the same OSD
struct __attribute__((__packed__)) blockstore_meta_header_t
{
uint64_t zero;
uint64_t magic;
uint64_t version;
uint32_t meta_block_size;
uint32_t data_block_size;
uint32_t bitmap_granularity;
};
// 32 bytes = 24 bytes + block bitmap (4 bytes by default) + external attributes (also bitmap, 4 bytes by default)
// per "clean" entry on disk with fixed metadata tables
// FIXME: maybe add crc32's to metadata