forked from vitalif/vitastor
Fix metadata partition length, fix journal allocation at the end
parent
876231d26b
commit
2630e2e3b9
|
@ -249,7 +249,12 @@ resume_0:
|
||||||
if (old_clean_loc == UINT64_MAX)
|
if (old_clean_loc == UINT64_MAX)
|
||||||
{
|
{
|
||||||
// Object not present at all. This is a bug.
|
// 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
|
else
|
||||||
clean_loc = old_clean_loc;
|
clean_loc = old_clean_loc;
|
||||||
|
@ -279,7 +284,7 @@ resume_0:
|
||||||
if (data->res != data->iov.iov_len)
|
if (data->res != data->iov.iov_len)
|
||||||
{
|
{
|
||||||
throw std::runtime_error(
|
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"
|
"). in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -440,9 +445,12 @@ resume_0:
|
||||||
flusher->journal_trim_counter = 0;
|
flusher->journal_trim_counter = 0;
|
||||||
journal_used_it = bs->journal.used_sectors.lower_bound(bs->journal.used_start);
|
journal_used_it = bs->journal.used_sectors.lower_bound(bs->journal.used_start);
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
#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->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
|
#endif
|
||||||
if (journal_used_it == bs->journal.used_sectors.end())
|
if (journal_used_it == bs->journal.used_sectors.end())
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,6 +85,9 @@ void blockstore_init_meta::handle_entries(struct clean_disk_entry* entries, int
|
||||||
if (entries[i].oid.inode > 0)
|
if (entries[i].oid.inode > 0)
|
||||||
{
|
{
|
||||||
auto clean_it = bs->clean_db.find(entries[i].oid);
|
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() || clean_it->second.version < entries[i].version)
|
||||||
{
|
{
|
||||||
if (clean_it != bs->clean_db.end())
|
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)
|
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 = {
|
obj_ver_id ov = {
|
||||||
.oid = je->small_write.oid,
|
.oid = je->small_write.oid,
|
||||||
|
|
|
@ -37,7 +37,7 @@ void blockstore::calc_lengths(spp::sparse_hash_map<std::string, std::string> & c
|
||||||
}
|
}
|
||||||
// required metadata size
|
// required metadata size
|
||||||
block_count = data_len / block_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)
|
if (meta_area < meta_len)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Metadata area is too small");
|
throw std::runtime_error("Metadata area is too small");
|
||||||
|
|
|
@ -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);
|
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
|
#endif
|
||||||
// Figure out where data will be
|
// 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->oid = op->oid;
|
||||||
je->version = op->version;
|
je->version = op->version;
|
||||||
je->offset = op->offset;
|
je->offset = op->offset;
|
||||||
|
|
Loading…
Reference in New Issue