forked from vitalif/vitastor
Add missing offset&len into big_writes journal dump, fix commas again
parent
1d80bcc8d0
commit
c08d1f2dfe
|
@ -56,7 +56,7 @@ struct disk_tool_t
|
||||||
uint64_t meta_pos;
|
uint64_t meta_pos;
|
||||||
uint64_t journal_pos, journal_calc_data_pos;
|
uint64_t journal_pos, journal_calc_data_pos;
|
||||||
|
|
||||||
bool first, first2;
|
bool first_block, first_entry;
|
||||||
|
|
||||||
allocator *data_alloc;
|
allocator *data_alloc;
|
||||||
std::map<uint64_t, uint64_t> data_remap;
|
std::map<uint64_t, uint64_t> data_remap;
|
||||||
|
|
|
@ -13,7 +13,7 @@ int disk_tool_t::dump_journal()
|
||||||
fprintf(stderr, "Invalid journal block size\n");
|
fprintf(stderr, "Invalid journal block size\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
first = true;
|
first_block = true;
|
||||||
if (json)
|
if (json)
|
||||||
printf("[\n");
|
printf("[\n");
|
||||||
if (all)
|
if (all)
|
||||||
|
@ -38,8 +38,8 @@ int disk_tool_t::dump_journal()
|
||||||
}
|
}
|
||||||
if (json)
|
if (json)
|
||||||
{
|
{
|
||||||
printf("%s{\"offset\":\"0x%lx\"", first ? "" : ",\n", journal_pos);
|
printf("%s{\"offset\":\"0x%lx\"", first_block ? "" : ",\n", journal_pos);
|
||||||
first = false;
|
first_block = false;
|
||||||
}
|
}
|
||||||
if (s == dsk.journal_block_size)
|
if (s == dsk.journal_block_size)
|
||||||
{
|
{
|
||||||
|
@ -55,10 +55,10 @@ int disk_tool_t::dump_journal()
|
||||||
printf("offset %08lx:\n", journal_pos);
|
printf("offset %08lx:\n", journal_pos);
|
||||||
else
|
else
|
||||||
printf(",\"entries\":[\n");
|
printf(",\"entries\":[\n");
|
||||||
first2 = true;
|
first_entry = true;
|
||||||
process_journal_block(journal_buf, [this](int num, journal_entry *je) { dump_journal_entry(num, je, json); });
|
process_journal_block(journal_buf, [this](int num, journal_entry *je) { dump_journal_entry(num, je, json); });
|
||||||
if (json)
|
if (json)
|
||||||
printf(first2 ? "]}" : "\n]}");
|
printf(first_entry ? "]}" : "\n]}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -75,39 +75,30 @@ int disk_tool_t::dump_journal()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
first_entry = true;
|
||||||
process_journal([this](void *data)
|
process_journal([this](void *data)
|
||||||
{
|
{
|
||||||
first2 = true;
|
if (json && dump_with_blocks)
|
||||||
|
first_entry = true;
|
||||||
if (!json)
|
if (!json)
|
||||||
printf("offset %08lx:\n", journal_pos);
|
printf("offset %08lx:\n", journal_pos);
|
||||||
auto pos = journal_pos;
|
auto pos = journal_pos;
|
||||||
int r = process_journal_block(data, [this, pos](int num, journal_entry *je)
|
int r = process_journal_block(data, [this, pos](int num, journal_entry *je)
|
||||||
{
|
{
|
||||||
if (json)
|
if (json && dump_with_blocks && first_entry)
|
||||||
{
|
printf("%s{\"offset\":\"0x%lx\",\"entries\":[\n", first_block ? "" : ",\n", pos);
|
||||||
if (dump_with_blocks)
|
|
||||||
{
|
|
||||||
if (first2)
|
|
||||||
printf("%s{\"offset\":\"0x%lx\",\"entries\":[\n", first ? "" : ",\n", pos);
|
|
||||||
}
|
|
||||||
else if (!first)
|
|
||||||
printf("%s", ",\n");
|
|
||||||
first = false;
|
|
||||||
}
|
|
||||||
dump_journal_entry(num, je, json);
|
dump_journal_entry(num, je, json);
|
||||||
|
first_block = false;
|
||||||
});
|
});
|
||||||
if (json)
|
if (json && dump_with_blocks && !first_entry)
|
||||||
{
|
printf("\n]}");
|
||||||
if (dump_with_blocks && !first2)
|
else if (!json && r <= 0)
|
||||||
printf("\n]}");
|
|
||||||
}
|
|
||||||
else if (r <= 0)
|
|
||||||
printf("end of the journal\n");
|
printf("end of the journal\n");
|
||||||
return r;
|
return r;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (json)
|
if (json)
|
||||||
printf(first ? "]\n" : "\n]\n");
|
printf(first_block ? "]\n" : "\n]\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,9 +205,9 @@ void disk_tool_t::dump_journal_entry(int num, journal_entry *je, bool json)
|
||||||
{
|
{
|
||||||
if (json)
|
if (json)
|
||||||
{
|
{
|
||||||
if (!first2)
|
if (!first_entry)
|
||||||
printf(",\n");
|
printf(",\n");
|
||||||
first2 = false;
|
first_entry = false;
|
||||||
printf(
|
printf(
|
||||||
"{\"crc32\":\"%08x\",\"valid\":%s,\"crc32_prev\":\"%08x\"",
|
"{\"crc32\":\"%08x\",\"valid\":%s,\"crc32_prev\":\"%08x\"",
|
||||||
je->crc32, (je_crc32(je) == je->crc32 ? "true" : "false"), je->crc32_prev
|
je->crc32, (je_crc32(je) == je->crc32 ? "true" : "false"), je->crc32_prev
|
||||||
|
@ -280,10 +271,12 @@ void disk_tool_t::dump_journal_entry(int num, journal_entry *je, bool json)
|
||||||
else if (je->type == JE_BIG_WRITE || je->type == JE_BIG_WRITE_INSTANT)
|
else if (je->type == JE_BIG_WRITE || je->type == JE_BIG_WRITE_INSTANT)
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
json ? ",\"type\":\"big_write%s\",\"inode\":\"0x%lx\",\"stripe\":\"0x%lx\",\"ver\":\"%lu\",\"loc\":\"0x%lx\""
|
json ? ",\"type\":\"big_write%s\",\"inode\":\"0x%lx\",\"stripe\":\"0x%lx\",\"ver\":\"%lu\",\"offset\":%u,\"len\":%u,\"loc\":\"0x%lx\""
|
||||||
: "je_big_write%s oid=%lx:%lx ver=%lu loc=%08lx",
|
: "je_big_write%s oid=%lx:%lx ver=%lu offset=%u len=%u loc=%08lx",
|
||||||
je->type == JE_BIG_WRITE_INSTANT ? "_instant" : "",
|
je->type == JE_BIG_WRITE_INSTANT ? "_instant" : "",
|
||||||
je->big_write.oid.inode, je->big_write.oid.stripe, je->big_write.version, je->big_write.location
|
je->big_write.oid.inode, je->big_write.oid.stripe,
|
||||||
|
je->big_write.version, je->big_write.offset, je->big_write.len,
|
||||||
|
je->big_write.location
|
||||||
);
|
);
|
||||||
if (je->big_write.size > sizeof(journal_entry_big_write))
|
if (je->big_write.size > sizeof(journal_entry_big_write))
|
||||||
{
|
{
|
||||||
|
@ -429,6 +422,7 @@ int disk_tool_t::write_json_journal(json11::Json entries)
|
||||||
.stripe = sscanf_json(NULL, rec["stripe"]),
|
.stripe = sscanf_json(NULL, rec["stripe"]),
|
||||||
},
|
},
|
||||||
.version = rec["ver"].uint64_value(),
|
.version = rec["ver"].uint64_value(),
|
||||||
|
.offset = (uint32_t)rec["offset"].uint64_value(),
|
||||||
.len = (uint32_t)rec["len"].uint64_value(),
|
.len = (uint32_t)rec["len"].uint64_value(),
|
||||||
.location = sscanf_json(NULL, rec["loc"]),
|
.location = sscanf_json(NULL, rec["loc"]),
|
||||||
};
|
};
|
||||||
|
|
|
@ -124,14 +124,14 @@ void disk_tool_t::dump_meta_header(blockstore_meta_header_v1_t *hdr)
|
||||||
{
|
{
|
||||||
printf("{\"version\":\"0.5\",\"meta_block_size\":%lu,\"entries\":[\n", dsk.meta_block_size);
|
printf("{\"version\":\"0.5\",\"meta_block_size\":%lu,\"entries\":[\n", dsk.meta_block_size);
|
||||||
}
|
}
|
||||||
first = true;
|
first_entry = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void disk_tool_t::dump_meta_entry(uint64_t block_num, clean_disk_entry *entry, uint8_t *bitmap)
|
void disk_tool_t::dump_meta_entry(uint64_t block_num, clean_disk_entry *entry, uint8_t *bitmap)
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
#define ENTRY_FMT "{\"block\":%lu,\"pool\":%u,\"inode\":\"0x%lx\",\"stripe\":\"0x%lx\",\"version\":%lu"
|
#define ENTRY_FMT "{\"block\":%lu,\"pool\":%u,\"inode\":\"0x%lx\",\"stripe\":\"0x%lx\",\"version\":%lu"
|
||||||
(first ? ENTRY_FMT : (",\n" ENTRY_FMT)),
|
(first_entry ? ENTRY_FMT : (",\n" ENTRY_FMT)),
|
||||||
#undef ENTRY_FMT
|
#undef ENTRY_FMT
|
||||||
block_num, INODE_POOL(entry->oid.inode), INODE_NO_POOL(entry->oid.inode),
|
block_num, INODE_POOL(entry->oid.inode), INODE_NO_POOL(entry->oid.inode),
|
||||||
entry->oid.stripe, entry->version
|
entry->oid.stripe, entry->version
|
||||||
|
@ -154,7 +154,7 @@ void disk_tool_t::dump_meta_entry(uint64_t block_num, clean_disk_entry *entry, u
|
||||||
{
|
{
|
||||||
printf("}");
|
printf("}");
|
||||||
}
|
}
|
||||||
first = false;
|
first_entry = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int disk_tool_t::write_json_meta(json11::Json meta)
|
int disk_tool_t::write_json_meta(json11::Json meta)
|
||||||
|
|
Loading…
Reference in New Issue