Check journal entry size when checking block checksums
parent
d22d56f90a
commit
ddb078d5a7
|
@ -833,11 +833,28 @@ int blockstore_init_journal::handle_journal_part(void *buf, uint64_t done_pos, u
|
||||||
}
|
}
|
||||||
else if (je->small_write.len > 0)
|
else if (je->small_write.len > 0)
|
||||||
{
|
{
|
||||||
uint32_t *block_csums = (uint32_t*)((uint8_t*)je + sizeof(journal_entry_small_write) + bs->dsk.clean_entry_bitmap_size);
|
// FIXME: deduplicate with disk_tool_journal.cpp
|
||||||
|
// like in enqueue_write()
|
||||||
uint32_t start = je->small_write.offset / bs->dsk.csum_block_size;
|
uint32_t start = je->small_write.offset / bs->dsk.csum_block_size;
|
||||||
uint32_t end = (je->small_write.offset+je->small_write.len-1) / bs->dsk.csum_block_size;
|
uint32_t end = (je->small_write.offset+je->small_write.len-1) / bs->dsk.csum_block_size;
|
||||||
|
uint32_t data_csum_size = (end-start+1) * (bs->dsk.data_csum_type & 0xFF);
|
||||||
|
uint32_t required_size = sizeof(journal_entry_small_write) + bs->dsk.clean_entry_bitmap_size + data_csum_size;
|
||||||
|
if (je->size != required_size)
|
||||||
|
{
|
||||||
|
printf(
|
||||||
|
"Journal entry data has invalid size for small_write%s oid=%lx:%lx ver=%lu offset=%u len=%u - should be %u bytes but is %u bytes\n",
|
||||||
|
je->type == JE_SMALL_WRITE_INSTANT ? "_instant" : "",
|
||||||
|
je->small_write.oid.inode, je->small_write.oid.stripe, je->small_write.version,
|
||||||
|
je->small_write.offset, je->small_write.len,
|
||||||
|
required_size, je->size
|
||||||
|
);
|
||||||
|
data_csum_valid = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
int sd_num = 0;
|
int sd_num = 0;
|
||||||
size_t sd_pos = 0;
|
size_t sd_pos = 0;
|
||||||
|
uint32_t *block_csums = (uint32_t*)((uint8_t*)je + sizeof(journal_entry_small_write) + bs->dsk.clean_entry_bitmap_size);
|
||||||
for (uint32_t pos = start; pos <= end; pos++, block_csums++)
|
for (uint32_t pos = start; pos <= end; pos++, block_csums++)
|
||||||
{
|
{
|
||||||
size_t block_left = (pos == start
|
size_t block_left = (pos == start
|
||||||
|
@ -884,6 +901,7 @@ int blockstore_init_journal::handle_journal_part(void *buf, uint64_t done_pos, u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!data_csum_valid)
|
if (!data_csum_valid)
|
||||||
{
|
{
|
||||||
// journal entry is corrupt, stop here
|
// journal entry is corrupt, stop here
|
||||||
|
|
Loading…
Reference in New Issue