v1 (old) store fixes for merged version

This commit is contained in:
Vitaliy Filippov
2025-11-23 19:07:43 +03:00
parent 19a386e4b3
commit 388b5f19a1
11 changed files with 87 additions and 33 deletions
+6 -2
View File
@@ -1,8 +1,10 @@
// Copyright (c) Vitaliy Filippov, 2019+
// License: VNPL-1.1 (see README.md for details)
#include "blockstore_impl.h"
#include "blockstore_internal.h"
#include "impl.h"
#include "internal.h"
namespace v1 {
#define META_BLOCK_UNREAD 0
#define META_BLOCK_READ 1
@@ -1467,3 +1469,5 @@ bool journal_flusher_co::trim_journal(int wait_base)
}
return true;
}
} // namespace v1
+9 -5
View File
@@ -1,10 +1,12 @@
// Copyright (c) Vitaliy Filippov, 2019+
// License: VNPL-1.1 (see README.md for details)
#include "blockstore_impl.h"
#include "blockstore_internal.h"
#include "impl.h"
#include "internal.h"
blockstore_impl_t::blockstore_impl_t(blockstore_config_t & config, ring_loop_t *ringloop, timerfd_manager_t *tfd)
namespace v1 {
blockstore_impl_t::blockstore_impl_t(blockstore_config_t & config, ring_loop_i *ringloop, timerfd_manager_t *tfd)
{
assert(sizeof(blockstore_op_private_t) <= BS_OP_PRIVATE_DATA_SIZE);
this->tfd = tfd;
@@ -92,7 +94,7 @@ void blockstore_impl_t::loop()
if (initialized == 3)
{
if (!readonly && dsk.discard_on_start)
dsk.trim_data(data_alloc);
dsk.trim_data([this](uint64_t block_num){ return data_alloc->get(block_num); });
if (journal.flush_journal)
initialized = 4;
else
@@ -275,7 +277,7 @@ void blockstore_impl_t::check_wait(blockstore_op_t *op)
{
if (PRIV(op)->wait_for == WAIT_SQE)
{
if (ringloop->sqes_left() < PRIV(op)->wait_detail)
if (ringloop->space_left() < PRIV(op)->wait_detail)
{
// stop submission if there's still no free space
#ifdef BLOCKSTORE_DEBUG
@@ -804,3 +806,5 @@ std::string blockstore_impl_t::get_op_diag(blockstore_op_t *op)
snprintf(buf, sizeof(buf), "state=%d", priv->op_state);
return std::string(buf);
}
} // namespace v1
+10 -5
View File
@@ -26,10 +26,13 @@
#include "malloc_or_die.h"
#include "allocator.h"
#include "crc32c.h"
//#define BLOCKSTORE_DEBUG
#include "blockstore_journal.h"
namespace v1 {
#include "journal.h"
// 32 = 16 + 16 bytes per "clean" entry in memory (object_id => clean_entry)
struct __attribute__((__packed__)) clean_entry
@@ -80,9 +83,9 @@ struct used_clean_obj_t
typedef btree::btree_map<object_id, clean_entry> blockstore_clean_db_t;
typedef std::map<obj_ver_id, dirty_entry> blockstore_dirty_db_t;
#include "blockstore_init.h"
#include "init.h"
#include "blockstore_flush.h"
#include "flush.h"
struct blockstore_op_private_t
{
@@ -176,7 +179,7 @@ class blockstore_impl_t: public blockstore_i
std::map<uint64_t, used_clean_obj_t> used_clean_objects;
bool live = false, queue_stall = false;
ring_loop_t *ringloop;
ring_loop_i *ringloop;
timerfd_manager_t *tfd;
bool stop_sync_submitted;
@@ -279,7 +282,7 @@ class blockstore_impl_t: public blockstore_i
public:
blockstore_impl_t(blockstore_config_t & config, ring_loop_t *ringloop, timerfd_manager_t *tfd);
blockstore_impl_t(blockstore_config_t & config, ring_loop_i *ringloop, timerfd_manager_t *tfd);
~blockstore_impl_t();
void parse_config(blockstore_config_t & config);
@@ -327,3 +330,5 @@ public:
inline uint32_t get_bitmap_granularity() { return dsk.disk_alignment; }
inline uint64_t get_journal_size() { return dsk.journal_len; }
};
} // namespace v1
+19 -6
View File
@@ -1,8 +1,10 @@
// Copyright (c) Vitaliy Filippov, 2019+
// License: VNPL-1.1 (see README.md for details)
#include "blockstore_impl.h"
#include "blockstore_internal.h"
#include "impl.h"
#include "internal.h"
namespace v1 {
#define INIT_META_EMPTY 0
#define INIT_META_READING 1
@@ -161,6 +163,15 @@ resume_1:
printf("Warning: Starting with metadata in the old format without checksums, as stored on disk\n");
}
}
else if (hdr->version == BLOCKSTORE_META_FORMAT_HEAP)
{
printf(
"OSD is started with meta_format %ju, but actual stored version is %ju on disk."
" Please update the OSD superblock or startup options.\n",
bs->dsk.meta_format, hdr->version
);
exit(1);
}
else if (hdr->version > BLOCKSTORE_META_FORMAT_V2)
{
printf(
@@ -178,7 +189,7 @@ resume_1:
printf(
"Configuration stored in metadata superblock"
" (meta_block_size=%u, data_block_size=%u, bitmap_granularity=%u, data_csum_type=%u, csum_block_size=%u)"
" differs from OSD configuration (%ju/%u/%ju, %u/%u).\n",
" differs from OSD configuration (%u/%u/%u, %u/%u).\n",
hdr->meta_block_size, hdr->data_block_size, hdr->bitmap_granularity,
hdr->data_csum_type, hdr->csum_block_size,
bs->dsk.meta_block_size, bs->dsk.data_block_size, bs->dsk.bitmap_granularity,
@@ -193,7 +204,7 @@ resume_1:
entries_per_block = bs->dsk.meta_block_size / bs->dsk.clean_entry_size;
// Read the rest of the metadata
resume_2:
if (next_offset < bs->dsk.meta_len && submitted == 0)
if (next_offset < bs->dsk.meta_area_size && submitted == 0)
{
// Submit one read
for (int i = 0; i < 2; i++)
@@ -204,8 +215,8 @@ resume_2:
? next_offset-md_offset
: i*bs->metadata_buf_size);
bufs[i].offset = next_offset;
bufs[i].size = bs->dsk.meta_len-next_offset > bs->metadata_buf_size
? bs->metadata_buf_size : bs->dsk.meta_len-next_offset;
bufs[i].size = bs->dsk.meta_area_size-next_offset > bs->metadata_buf_size
? bs->metadata_buf_size : bs->dsk.meta_area_size-next_offset;
bufs[i].state = INIT_META_READING;
submitted++;
next_offset += bufs[i].size;
@@ -1217,3 +1228,5 @@ void blockstore_init_journal::erase_dirty_object(blockstore_dirty_db_t::iterator
// Otherwise it may end up referring to a small unstable write after reading the rest of the journal
bs->flusher->remove_flush(oid);
}
} // namespace v1
+6 -2
View File
@@ -1,8 +1,10 @@
// Copyright (c) Vitaliy Filippov, 2019+
// License: VNPL-1.1 (see README.md for details)
#include "blockstore_impl.h"
#include "blockstore_internal.h"
#include "impl.h"
#include "internal.h"
namespace v1 {
blockstore_journal_check_t::blockstore_journal_check_t(blockstore_impl_t *bs)
{
@@ -327,3 +329,5 @@ void journal_t::dump_diagnostics()
journal_used_it == used_sectors.end() ? 0 : journal_used_it->second
);
}
} // namespace v1
+7 -3
View File
@@ -2,7 +2,9 @@
// License: VNPL-1.1 (see README.md for details)
#include <sys/file.h>
#include "blockstore_impl.h"
#include "impl.h"
namespace v1 {
void blockstore_impl_t::parse_config(blockstore_config_t & config)
{
@@ -148,9 +150,9 @@ void blockstore_impl_t::calc_lengths()
journal.offset = dsk.journal_offset;
if (inmemory_meta)
{
metadata_buffer = memalign(MEM_ALIGNMENT, dsk.meta_len);
metadata_buffer = memalign(MEM_ALIGNMENT, dsk.meta_area_size);
if (!metadata_buffer)
throw std::runtime_error("Failed to allocate memory for the metadata ("+std::to_string(dsk.meta_len/1024/1024)+" MB)");
throw std::runtime_error("Failed to allocate memory for the metadata ("+std::to_string(dsk.meta_area_size/1024/1024)+" MB)");
}
else if (dsk.clean_entry_bitmap_size || dsk.data_csum_type)
{
@@ -181,3 +183,5 @@ void blockstore_impl_t::calc_lengths()
throw std::bad_alloc();
}
}
}
+6 -2
View File
@@ -2,8 +2,10 @@
// License: VNPL-1.1 (see README.md for details)
#include <limits.h>
#include "blockstore_impl.h"
#include "blockstore_internal.h"
#include "impl.h"
#include "internal.h"
namespace v1 {
int blockstore_impl_t::fulfill_read_push(blockstore_op_t *op, void *buf, uint64_t offset, uint64_t len,
uint32_t item_state, uint64_t item_version)
@@ -1031,3 +1033,5 @@ int blockstore_impl_t::read_bitmap(object_id oid, uint64_t target_version, void
memset(bitmap, 0, dsk.clean_entry_bitmap_size);
return -ENOENT;
}
} // namespace v1
+6 -2
View File
@@ -1,8 +1,10 @@
// Copyright (c) Vitaliy Filippov, 2019+
// License: VNPL-1.1 (see README.md for details)
#include "blockstore_impl.h"
#include "blockstore_internal.h"
#include "impl.h"
#include "internal.h"
namespace v1 {
int blockstore_impl_t::dequeue_rollback(blockstore_op_t *op)
{
@@ -257,3 +259,5 @@ void blockstore_impl_t::free_dirty_dyn_data(dirty_entry & e)
e.dyn_data = NULL;
}
}
} // namespace v1
+6 -2
View File
@@ -1,8 +1,10 @@
// Copyright (c) Vitaliy Filippov, 2019+
// License: VNPL-1.1 (see README.md for details)
#include "blockstore_impl.h"
#include "blockstore_internal.h"
#include "impl.h"
#include "internal.h"
namespace v1 {
// Stabilize small write:
// 1) Copy data from the journal to the data device
@@ -560,3 +562,5 @@ void blockstore_impl_t::mark_stable(obj_ver_id v, bool forget_dirty)
unstable_writes.erase(unstab_it);
}
}
} // namespace v1
+6 -2
View File
@@ -1,8 +1,10 @@
// Copyright (c) Vitaliy Filippov, 2019+
// License: VNPL-1.1 (see README.md for details)
#include "blockstore_impl.h"
#include "blockstore_internal.h"
#include "impl.h"
#include "internal.h"
namespace v1 {
#define SYNC_HAS_SMALL 1
#define SYNC_HAS_BIG 2
@@ -232,3 +234,5 @@ void blockstore_impl_t::ack_sync(blockstore_op_t *op)
op->retval = 0;
FINISH_OP(op);
}
} // namespace v1
+6 -2
View File
@@ -1,8 +1,10 @@
// Copyright (c) Vitaliy Filippov, 2019+
// License: VNPL-1.1 (see README.md for details)
#include "blockstore_impl.h"
#include "blockstore_internal.h"
#include "impl.h"
#include "internal.h"
namespace v1 {
bool blockstore_impl_t::enqueue_write(blockstore_op_t *op)
{
@@ -822,3 +824,5 @@ int blockstore_impl_t::dequeue_del(blockstore_op_t *op)
}
return 1;
}
} // namespace v1