From 3b9873b9a97658f8fca84d68f15de60862e2c73e Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 3 Jun 2023 01:06:54 +0300 Subject: [PATCH] Rename meta_version to meta_format --- src/blockstore_disk.cpp | 4 ++-- src/blockstore_disk.h | 2 +- src/blockstore_flush.cpp | 4 ++-- src/blockstore_impl.h | 4 ++-- src/blockstore_init.cpp | 22 +++++++++++----------- src/disk_tool_meta.cpp | 22 +++++++++++----------- src/disk_tool_resize.cpp | 2 +- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/blockstore_disk.cpp b/src/blockstore_disk.cpp index 7a9fd81b..a5f088c3 100644 --- a/src/blockstore_disk.cpp +++ b/src/blockstore_disk.cpp @@ -193,7 +193,7 @@ void blockstore_disk_t::calc_lengths(bool skip_meta_check) meta_len = (1 + (block_count - 1 + meta_block_size / clean_entry_size) / (meta_block_size / clean_entry_size)) * meta_block_size; if (!skip_meta_check && meta_area_size < meta_len) { - if (!data_csum_type && !meta_version) + if (!data_csum_type && !meta_format) { uint64_t clean_entry_v0_size = sizeof(clean_disk_entry) + 2*clean_entry_bitmap_size; uint64_t meta_v0_len = (1 + (block_count - 1 + meta_block_size / clean_entry_v0_size) @@ -204,7 +204,7 @@ void blockstore_disk_t::calc_lengths(bool skip_meta_check) printf("Warning: Forcing metadata format without checksums because the new format doesn't fit into provided area\n"); clean_entry_size = clean_entry_v0_size; meta_len = meta_v0_len; - meta_version = BLOCKSTORE_META_VERSION_V1; + meta_format = BLOCKSTORE_META_FORMAT_V1; } } if (meta_area_size < meta_len) diff --git a/src/blockstore_disk.h b/src/blockstore_disk.h index a9c9c364..45c285ec 100644 --- a/src/blockstore_disk.h +++ b/src/blockstore_disk.h @@ -33,7 +33,7 @@ struct blockstore_disk_t bool disable_flock = false; int meta_fd = -1, data_fd = -1, journal_fd = -1; - uint64_t meta_offset, meta_device_sect, meta_device_size, meta_len, meta_version = 0; + uint64_t meta_offset, meta_device_sect, meta_device_size, meta_len, meta_format = 0; uint64_t data_offset, data_device_sect, data_device_size, data_len; uint64_t journal_offset, journal_device_sect, journal_device_size, journal_len; diff --git a/src/blockstore_flush.cpp b/src/blockstore_flush.cpp index 678179e7..6407fb0a 100644 --- a/src/blockstore_flush.cpp +++ b/src/blockstore_flush.cpp @@ -665,7 +665,7 @@ void journal_flusher_co::update_metadata_entry() new_entry->version = cur.version; if (!bs->inmemory_meta) memcpy(&new_entry->bitmap, new_clean_bitmap, bs->dsk.clean_dyn_size); - if (bs->dsk.meta_version >= BLOCKSTORE_META_VERSION_V2) + if (bs->dsk.meta_format >= BLOCKSTORE_META_FORMAT_V2) { // Calculate metadata entry checksum uint32_t *new_entry_csum = (uint32_t*)((uint8_t*)new_entry + bs->dsk.clean_entry_size - 4); @@ -810,7 +810,7 @@ bool journal_flusher_co::clear_incomplete_csum_block_bits(int wait_base) calc_block_checksums(new_data_csums, true); if (!bs->inmemory_meta) memcpy(&new_entry->bitmap, new_clean_bitmap, bs->dsk.clean_dyn_size); - if (bs->dsk.meta_version >= BLOCKSTORE_META_VERSION_V2) + if (bs->dsk.meta_format >= BLOCKSTORE_META_FORMAT_V2) { // calculate metadata entry checksum uint32_t *new_entry_csum = (uint32_t*)((uint8_t*)new_entry + bs->dsk.clean_entry_size - 4); diff --git a/src/blockstore_impl.h b/src/blockstore_impl.h index 5371ccd5..643e6137 100644 --- a/src/blockstore_impl.h +++ b/src/blockstore_impl.h @@ -93,8 +93,8 @@ // "VITAstor" #define BLOCKSTORE_META_MAGIC_V1 0x726F747341544956l -#define BLOCKSTORE_META_VERSION_V1 1 -#define BLOCKSTORE_META_VERSION_V2 2 +#define BLOCKSTORE_META_FORMAT_V1 1 +#define BLOCKSTORE_META_FORMAT_V2 2 // metadata header (superblock) struct __attribute__((__packed__)) blockstore_meta_header_v1_t diff --git a/src/blockstore_init.cpp b/src/blockstore_init.cpp index a334b11b..a33ff295 100644 --- a/src/blockstore_init.cpp +++ b/src/blockstore_init.cpp @@ -80,7 +80,7 @@ resume_1: blockstore_meta_header_v2_t *hdr = (blockstore_meta_header_v2_t *)metadata_buffer; hdr->zero = 0; hdr->magic = BLOCKSTORE_META_MAGIC_V1; - hdr->version = BLOCKSTORE_META_VERSION_V2; + hdr->version = BLOCKSTORE_META_FORMAT_V2; hdr->meta_block_size = bs->dsk.meta_block_size; hdr->data_block_size = bs->dsk.data_block_size; hdr->bitmap_granularity = bs->dsk.bitmap_granularity; @@ -114,7 +114,7 @@ resume_1: else { blockstore_meta_header_v2_t *hdr = (blockstore_meta_header_v2_t *)metadata_buffer; - if (hdr->zero != 0 || hdr->magic != BLOCKSTORE_META_MAGIC_V1 || hdr->version < BLOCKSTORE_META_VERSION_V1) + if (hdr->zero != 0 || hdr->magic != BLOCKSTORE_META_MAGIC_V1 || hdr->version < BLOCKSTORE_META_FORMAT_V1) { printf( "Metadata is corrupt or too old (pre-0.6.x).\n" @@ -123,15 +123,15 @@ resume_1: ); exit(1); } - if (bs->dsk.meta_version && bs->dsk.meta_version != hdr->version) + if (bs->dsk.meta_format && bs->dsk.meta_format != hdr->version) { printf( "Metadata format version is %lu on disk, but %lu is currently selected in OSD configuration.\n" - " Please upgrade using vitastor-disk.\n", hdr->version, bs->dsk.meta_version + " Please upgrade using vitastor-disk.\n", hdr->version, bs->dsk.meta_format ); exit(1); } - if (hdr->version == BLOCKSTORE_META_VERSION_V2) + if (hdr->version == BLOCKSTORE_META_FORMAT_V2) { uint32_t csum = hdr->header_csum; hdr->header_csum = 0; @@ -141,9 +141,9 @@ resume_1: exit(1); } hdr->header_csum = csum; - bs->dsk.meta_version = BLOCKSTORE_META_VERSION_V2; + bs->dsk.meta_format = BLOCKSTORE_META_FORMAT_V2; } - else if (hdr->version == BLOCKSTORE_META_VERSION_V1) + else if (hdr->version == BLOCKSTORE_META_FORMAT_V1) { hdr->data_csum_type = 0; hdr->csum_block_size = 0; @@ -152,14 +152,14 @@ resume_1: bs->dsk.clean_entry_size = sizeof(clean_disk_entry) + bs->dsk.clean_entry_bitmap_size*2; bs->dsk.meta_len = (1 + (bs->dsk.block_count - 1 + bs->dsk.meta_block_size / bs->dsk.clean_entry_size) / (bs->dsk.meta_block_size / bs->dsk.clean_entry_size)) * bs->dsk.meta_block_size; - bs->dsk.meta_version = BLOCKSTORE_META_VERSION_V1; + bs->dsk.meta_format = BLOCKSTORE_META_FORMAT_V1; printf("Warning: Starting with metadata in the old format without checksums, as stored on disk\n"); } - else if (hdr->version > BLOCKSTORE_META_VERSION_V2) + else if (hdr->version > BLOCKSTORE_META_FORMAT_V2) { printf( "Metadata format is too new for me (stored version is %lu, max supported %u).\n", - hdr->version, BLOCKSTORE_META_VERSION_V2 + hdr->version, BLOCKSTORE_META_FORMAT_V2 ); exit(1); } @@ -327,7 +327,7 @@ bool blockstore_init_meta::handle_meta_block(uint8_t *buf, uint64_t entries_per_ clean_disk_entry *entry = (clean_disk_entry*)(buf + i*bs->dsk.clean_entry_size); if (entry->oid.inode > 0) { - if (bs->dsk.meta_version >= BLOCKSTORE_META_VERSION_V2) + if (bs->dsk.meta_format >= BLOCKSTORE_META_FORMAT_V2) { // Check entry crc32 uint32_t *entry_csum = (uint32_t*)((uint8_t*)entry + bs->dsk.clean_entry_size - 4); diff --git a/src/disk_tool_meta.cpp b/src/disk_tool_meta.cpp index 015ccb21..217e4e3b 100644 --- a/src/disk_tool_meta.cpp +++ b/src/disk_tool_meta.cpp @@ -31,14 +31,14 @@ int disk_tool_t::process_meta(std::function blockstore_meta_header_v2_t *hdr = (blockstore_meta_header_v2_t *)data; if (hdr->zero == 0 && hdr->magic == BLOCKSTORE_META_MAGIC_V1) { - if (hdr->version == BLOCKSTORE_META_VERSION_V1) + if (hdr->version == BLOCKSTORE_META_FORMAT_V1) { // Vitastor 0.6-0.8 - static array of clean_disk_entry with bitmaps hdr->data_csum_type = 0; hdr->csum_block_size = 0; hdr->header_csum = 0; } - else if (hdr->version == BLOCKSTORE_META_VERSION_V2) + else if (hdr->version == BLOCKSTORE_META_FORMAT_V2) { // Vitastor 0.9 - static array of clean_disk_entry with bitmaps and checksums if (hdr->data_csum_type != 0 && @@ -54,7 +54,7 @@ int disk_tool_t::process_meta(std::function else { // Unsupported version - fprintf(stderr, "Metadata format is too new for me (stored version is %lu, max supported %u).\n", hdr->version, BLOCKSTORE_META_VERSION_V2); + fprintf(stderr, "Metadata format is too new for me (stored version is %lu, max supported %u).\n", hdr->version, BLOCKSTORE_META_FORMAT_V2); free(data); close(dsk.meta_fd); dsk.meta_fd = -1; @@ -74,7 +74,7 @@ int disk_tool_t::process_meta(std::function hdr = (blockstore_meta_header_v2_t *)data; } } - dsk.meta_version = hdr->version; + dsk.meta_format = hdr->version; dsk.data_block_size = hdr->data_block_size; dsk.csum_block_size = hdr->csum_block_size; dsk.data_csum_type = hdr->data_csum_type; @@ -85,7 +85,7 @@ int disk_tool_t::process_meta(std::function ? ((hdr->data_block_size+hdr->csum_block_size-1)/hdr->csum_block_size *(hdr->data_csum_type & 0xff)) : 0) - + (dsk.meta_version == BLOCKSTORE_META_VERSION_V2 ? 4 /*entry_csum*/ : 0); + + (dsk.meta_format == BLOCKSTORE_META_FORMAT_V2 ? 4 /*entry_csum*/ : 0); uint64_t block_num = 0; hdr_fn(hdr); hdr = NULL; @@ -164,7 +164,7 @@ void disk_tool_t::dump_meta_header(blockstore_meta_header_v2_t *hdr) { if (hdr) { - if (hdr->version == BLOCKSTORE_META_VERSION_V1) + if (hdr->version == BLOCKSTORE_META_FORMAT_V1) { printf( "{\"version\":\"0.6\",\"meta_block_size\":%u,\"data_block_size\":%u,\"bitmap_granularity\":%u," @@ -172,7 +172,7 @@ void disk_tool_t::dump_meta_header(blockstore_meta_header_v2_t *hdr) hdr->meta_block_size, hdr->data_block_size, hdr->bitmap_granularity ); } - else if (hdr->version == BLOCKSTORE_META_VERSION_V2) + else if (hdr->version == BLOCKSTORE_META_FORMAT_V2) { printf( "{\"version\":\"0.9\",\"meta_block_size\":%u,\"data_block_size\":%u,\"bitmap_granularity\":%u," @@ -235,8 +235,8 @@ int disk_tool_t::write_json_meta(json11::Json meta) blockstore_meta_header_v2_t *new_hdr = (blockstore_meta_header_v2_t *)new_meta_buf; new_hdr->zero = 0; new_hdr->magic = BLOCKSTORE_META_MAGIC_V1; - new_hdr->version = meta["version"].uint64_value() == BLOCKSTORE_META_VERSION_V1 - ? BLOCKSTORE_META_VERSION_V1 : BLOCKSTORE_META_VERSION_V2; + new_hdr->version = meta["version"].uint64_value() == BLOCKSTORE_META_FORMAT_V1 + ? BLOCKSTORE_META_FORMAT_V1 : BLOCKSTORE_META_FORMAT_V2; new_hdr->meta_block_size = meta["meta_block_size"].uint64_value() ? meta["meta_block_size"].uint64_value() : 4096; new_hdr->data_block_size = meta["data_block_size"].uint64_value() @@ -249,7 +249,7 @@ int disk_tool_t::write_json_meta(json11::Json meta) ? BLOCKSTORE_CSUM_CRC32C : BLOCKSTORE_CSUM_NONE); new_hdr->csum_block_size = meta["csum_block_size"].uint64_value(); - uint32_t new_clean_entry_header_size = (new_hdr->version == BLOCKSTORE_META_VERSION_V1 + uint32_t new_clean_entry_header_size = (new_hdr->version == BLOCKSTORE_META_FORMAT_V1 ? sizeof(clean_disk_entry) : sizeof(clean_disk_entry) + 4 /*entry_csum*/); new_clean_entry_bitmap_size = (new_hdr->data_block_size / new_hdr->bitmap_granularity + 7) / 8; new_data_csum_size = (new_hdr->data_csum_type @@ -278,7 +278,7 @@ int disk_tool_t::write_json_meta(json11::Json meta) ((uint8_t*)new_entry) + sizeof(clean_disk_entry)); fromhexstr(e["ext_bitmap"].string_value(), new_clean_entry_bitmap_size, ((uint8_t*)new_entry) + sizeof(clean_disk_entry) + new_clean_entry_bitmap_size); - if (new_hdr->version == BLOCKSTORE_META_VERSION_V2) + if (new_hdr->version == BLOCKSTORE_META_FORMAT_V2) { if (new_hdr->data_csum_type != 0) { diff --git a/src/disk_tool_resize.cpp b/src/disk_tool_resize.cpp index db4263a9..d0b32060 100644 --- a/src/disk_tool_resize.cpp +++ b/src/disk_tool_resize.cpp @@ -466,7 +466,7 @@ int disk_tool_t::resize_rewrite_meta() blockstore_meta_header_v2_t *new_hdr = (blockstore_meta_header_v2_t *)new_meta_buf; new_hdr->zero = 0; new_hdr->magic = BLOCKSTORE_META_MAGIC_V1; - new_hdr->version = BLOCKSTORE_META_VERSION_V1; + new_hdr->version = BLOCKSTORE_META_FORMAT_V1; new_hdr->meta_block_size = dsk.meta_block_size; new_hdr->data_block_size = dsk.data_block_size; new_hdr->bitmap_granularity = dsk.bitmap_granularity ? dsk.bitmap_granularity : 4096;