Fix metadata partition length, fix journal allocation at the end

blocking-uring-test
Vitaliy Filippov 2019-11-27 19:39:15 +03:00
parent 876231d26b
commit 2630e2e3b9
4 changed files with 20 additions and 7 deletions

View File

@ -249,7 +249,12 @@ resume_0:
if (old_clean_loc == UINT64_MAX)
{
// Object not present at all. This is a bug.
throw std::runtime_error("BUG: Object we are trying to flush is not allocated on the data device");
char err[1024];
snprintf(
err, 1024, "BUG: Object %lu:%lu v%lu that we are trying to flush is not allocated on the data device",
cur.oid.inode, cur.oid.stripe, cur.version
);
throw std::runtime_error(err);
}
else
clean_loc = old_clean_loc;
@ -279,7 +284,7 @@ resume_0:
if (data->res != data->iov.iov_len)
{
throw std::runtime_error(
"write operation failed ("+std::to_string(data->res)+" != "+std::to_string(data->iov.iov_len)+
"metadata read operation failed ("+std::to_string(data->res)+" != "+std::to_string(data->iov.iov_len)+
"). in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111"
);
}
@ -440,9 +445,12 @@ resume_0:
flusher->journal_trim_counter = 0;
journal_used_it = bs->journal.used_sectors.lower_bound(bs->journal.used_start);
#ifdef BLOCKSTORE_DEBUG
printf("Trimming journal (used_start=%lu, next_free=%lu, first_used=%lu, usage_count=%lu)\n", bs->journal.used_start, bs->journal.next_free,
printf(
"Trimming journal (used_start=%lu, next_free=%lu, first_used=%lu, usage_count=%lu)\n",
bs->journal.used_start, bs->journal.next_free,
journal_used_it == bs->journal.used_sectors.end() ? 0 : journal_used_it->first,
journal_used_it == bs->journal.used_sectors.end() ? 0 : journal_used_it->second);
journal_used_it == bs->journal.used_sectors.end() ? 0 : journal_used_it->second
);
#endif
if (journal_used_it == bs->journal.used_sectors.end())
{

View File

@ -85,6 +85,9 @@ void blockstore_init_meta::handle_entries(struct clean_disk_entry* entries, int
if (entries[i].oid.inode > 0)
{
auto clean_it = bs->clean_db.find(entries[i].oid);
#ifdef BLOCKSTORE_DEBUG
printf("Clean entry %lu: %lu:%lu v%lu\n", done_cnt+i, entries[i].oid.inode, entries[i].oid.stripe, entries[i].version);
#endif
if (clean_it == bs->clean_db.end() || clean_it->second.version < entries[i].version)
{
if (clean_it != bs->clean_db.end())
@ -338,7 +341,9 @@ int blockstore_init_journal::handle_journal_part(void *buf, uint64_t len)
}
if (location != je->small_write.data_offset)
{
throw std::runtime_error("BUG: calculated journal data offset != stored journal data offset");
char err[1024];
snprintf(err, 1024, "BUG: calculated journal data offset (%lu) != stored journal data offset (%lu)", location, je->small_write.data_offset);
throw std::runtime_error(err);
}
obj_ver_id ov = {
.oid = je->small_write.oid,

View File

@ -37,7 +37,7 @@ void blockstore::calc_lengths(spp::sparse_hash_map<std::string, std::string> & c
}
// required metadata size
block_count = data_len / block_size;
meta_len = block_count * sizeof(clean_disk_entry);
meta_len = (block_count / (512 / sizeof(clean_disk_entry))) * 512;
if (meta_area < meta_len)
{
throw std::runtime_error("Metadata area is too small");

View File

@ -126,7 +126,7 @@ int blockstore::dequeue_write(blockstore_operation *op)
printf("journal offset %lu is used by %lu:%lu v%lu\n", dirty_it->second.journal_sector, dirty_it->first.oid.inode, dirty_it->first.oid.stripe, dirty_it->first.version);
#endif
// Figure out where data will be
journal.next_free = (journal.next_free + op->len) < journal.len ? journal.next_free : 512;
journal.next_free = (journal.next_free + op->len) <= journal.len ? journal.next_free : 512;
je->oid = op->oid;
je->version = op->version;
je->offset = op->offset;