[btree] bad checksum exceptions now mention the block location

This commit is contained in:
Joe Thornber 2015-08-04 15:12:41 +01:00
parent 7134a58134
commit b67cc29609

View File

@ -38,11 +38,17 @@ namespace {
node_header const *n = &data->header; node_header const *n = &data->header;
crc32c sum(BTREE_CSUM_XOR); crc32c sum(BTREE_CSUM_XOR);
sum.append(&n->flags, MD_BLOCK_SIZE - sizeof(uint32_t)); sum.append(&n->flags, MD_BLOCK_SIZE - sizeof(uint32_t));
if (sum.get_sum() != to_cpu<uint32_t>(n->csum)) if (sum.get_sum() != to_cpu<uint32_t>(n->csum)) {
throw checksum_error("bad checksum in btree node"); std::ostringstream out;
out << "bad checksum in btree node (block " << location << ")";
throw checksum_error(out.str());
}
if (to_cpu<uint64_t>(n->blocknr) != location) if (to_cpu<uint64_t>(n->blocknr) != location) {
throw checksum_error("bad block nr in btree node"); std::ostringstream out;
out << "bad block nr in btree node (block = " << location << ")";
throw checksum_error(out.str());
}
} }
virtual void prepare(void *raw, block_address location) const { virtual void prepare(void *raw, block_address location) const {