Support xxhash 32-bit checksums (data_csum_type=xxh3_32)
This commit is contained in:
@@ -1350,6 +1350,24 @@ jobs:
|
|||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
|
||||||
|
test_checksum_xxhash:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
container: ${{env.TEST_IMAGE}}:${{github.sha}}
|
||||||
|
steps:
|
||||||
|
- name: Run test
|
||||||
|
id: test
|
||||||
|
timeout-minutes: 3
|
||||||
|
run: TEST_NAME=xxhash OSD_ARGS="--data_csum_type xxh3_32" /root/vitastor/tests/test_checksum.sh
|
||||||
|
- name: Print logs
|
||||||
|
if: always() && steps.test.outcome == 'failure'
|
||||||
|
run: |
|
||||||
|
for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do
|
||||||
|
echo "-------- $i --------"
|
||||||
|
cat $i
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
test_old_checksum:
|
test_old_checksum:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build
|
needs: build
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ project(vitastor)
|
|||||||
|
|
||||||
# libvitastor_blk.a
|
# libvitastor_blk.a
|
||||||
add_library(vitastor_blk STATIC
|
add_library(vitastor_blk STATIC
|
||||||
../util/allocator.cpp ../util/crc32c.c ../util/ringloop.cpp
|
../util/allocator.cpp ../util/crc32c.c ../util/xxhash.c ../util/ringloop.cpp
|
||||||
multilist.cpp blockstore_heap.cpp blockstore_disk.cpp
|
multilist.cpp blockstore_heap.cpp blockstore_disk.cpp
|
||||||
blockstore.cpp blockstore_impl.cpp blockstore_init.cpp blockstore_open.cpp
|
blockstore.cpp blockstore_impl.cpp blockstore_init.cpp blockstore_open.cpp
|
||||||
blockstore_flush.cpp blockstore_read.cpp blockstore_stable.cpp blockstore_sync.cpp blockstore_write.cpp
|
blockstore_flush.cpp blockstore_read.cpp blockstore_stable.cpp blockstore_sync.cpp blockstore_write.cpp
|
||||||
|
|||||||
@@ -83,13 +83,17 @@ void blockstore_disk_t::parse_config(std::map<std::string, std::string> & config
|
|||||||
{
|
{
|
||||||
data_csum_type = BLOCKSTORE_CSUM_CRC32C;
|
data_csum_type = BLOCKSTORE_CSUM_CRC32C;
|
||||||
}
|
}
|
||||||
|
else if (config["data_csum_type"] == "xxh3_32")
|
||||||
|
{
|
||||||
|
data_csum_type = BLOCKSTORE_CSUM_XXH3_32;
|
||||||
|
}
|
||||||
else if (config["data_csum_type"] == "" || config["data_csum_type"] == "none")
|
else if (config["data_csum_type"] == "" || config["data_csum_type"] == "none")
|
||||||
{
|
{
|
||||||
data_csum_type = BLOCKSTORE_CSUM_NONE;
|
data_csum_type = BLOCKSTORE_CSUM_NONE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw std::runtime_error("data_csum_type="+config["data_csum_type"]+" is unsupported, only \"crc32c\" and \"none\" are supported");
|
throw std::runtime_error("data_csum_type="+config["data_csum_type"]+" is unsupported, only \"crc32c\", \"xxh3_32\" and \"none\" are supported");
|
||||||
}
|
}
|
||||||
csum_block_size = parse_size(config["csum_block_size"]);
|
csum_block_size = parse_size(config["csum_block_size"]);
|
||||||
discard_on_start = config.find("discard_on_start") != config.end() &&
|
discard_on_start = config.find("discard_on_start") != config.end() &&
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#define BLOCKSTORE_CSUM_NONE 0
|
#define BLOCKSTORE_CSUM_NONE 0
|
||||||
// Lower byte of checksum type is its length
|
// Lower byte of checksum type is its length
|
||||||
#define BLOCKSTORE_CSUM_CRC32C 0x104
|
#define BLOCKSTORE_CSUM_CRC32C 0x104
|
||||||
|
#define BLOCKSTORE_CSUM_XXH3_32 0x204
|
||||||
|
|
||||||
#define MOCK_DATA_FD 1000
|
#define MOCK_DATA_FD 1000
|
||||||
#define MOCK_META_FD 1001
|
#define MOCK_META_FD 1001
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "blockstore_heap.h"
|
#include "blockstore_heap.h"
|
||||||
#include "../util/allocator.h"
|
#include "../util/allocator.h"
|
||||||
#include "../util/crc32c.h"
|
#include "../util/crc32c.h"
|
||||||
|
#include "../util/xxhash.h"
|
||||||
#include "../util/malloc_or_die.h"
|
#include "../util/malloc_or_die.h"
|
||||||
|
|
||||||
#define BS_HEAP_FREE_MVCC 1
|
#define BS_HEAP_FREE_MVCC 1
|
||||||
@@ -217,15 +218,24 @@ void heap_entry_t::set_big_location(blockstore_heap_t *heap, uint64_t location)
|
|||||||
big().block_num = location / heap->dsk->data_block_size;
|
big().block_num = location / heap->dsk->data_block_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t heap_entry_t::calc_crc32c()
|
uint32_t heap_entry_t::calc_checksum(blockstore_disk_t *dsk)
|
||||||
{
|
{
|
||||||
auto old_crc32c = crc32c;
|
auto old_checksum = checksum;
|
||||||
crc32c = 0;
|
checksum = 0;
|
||||||
uint32_t res = ::crc32c(0, (uint8_t*)this, size);
|
uint32_t res = 0;
|
||||||
crc32c = old_crc32c;
|
if (dsk->data_csum_type == BLOCKSTORE_CSUM_XXH3_32)
|
||||||
|
res = (uint32_t)XXH3_64bits(this, size);
|
||||||
|
else
|
||||||
|
res = ::crc32c(0, (uint8_t*)this, size);
|
||||||
|
checksum = old_checksum;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t heap_entry_t::calc_checksum(blockstore_heap_t *heap)
|
||||||
|
{
|
||||||
|
return calc_checksum(heap->dsk);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t blockstore_heap_t::get_pg_id(inode_t inode, uint64_t stripe)
|
uint64_t blockstore_heap_t::get_pg_id(inode_t inode, uint64_t stripe)
|
||||||
{
|
{
|
||||||
uint64_t pg_num = 0;
|
uint64_t pg_num = 0;
|
||||||
@@ -380,12 +390,12 @@ corrupted_object:
|
|||||||
goto corrupted_object;
|
goto corrupted_object;
|
||||||
}
|
}
|
||||||
// Verify crc
|
// Verify crc
|
||||||
uint32_t expected_crc32c = wr->calc_crc32c();
|
uint32_t expected_checksum = wr->calc_checksum(this);
|
||||||
if (wr->crc32c != expected_crc32c)
|
if (wr->checksum != expected_checksum)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error: entry %jx:%jx v%ju l%ju in metadata block %u at %u is corrupt (crc32c mismatch: expected %08x, got %08x). ",
|
fprintf(stderr, "Error: entry %jx:%jx v%ju l%ju in metadata block %u at %u is corrupt (checksum mismatch: expected %08x, got %08x). ",
|
||||||
wr->inode, wr->stripe, wr->version, wr->lsn,
|
wr->inode, wr->stripe, wr->version, wr->lsn,
|
||||||
block_num, block_offset, expected_crc32c, wr->crc32c);
|
block_num, block_offset, expected_checksum, wr->checksum);
|
||||||
goto corrupted_object;
|
goto corrupted_object;
|
||||||
}
|
}
|
||||||
// Verify offset & len
|
// Verify offset & len
|
||||||
@@ -1083,7 +1093,11 @@ bool blockstore_heap_t::calc_checksums(heap_entry_t *wr, uint8_t *data, bool set
|
|||||||
len = wr->big_intent().len;
|
len = wr->big_intent().len;
|
||||||
else
|
else
|
||||||
assert(0);
|
assert(0);
|
||||||
uint32_t real_csum = crc32c(0, data, len);
|
uint32_t real_csum = 0;
|
||||||
|
if (dsk->data_csum_type == BLOCKSTORE_CSUM_XXH3_32)
|
||||||
|
real_csum = (uint32_t)XXH3_64bits(data, len);
|
||||||
|
else
|
||||||
|
real_csum = crc32c(0, data, len);
|
||||||
if (set)
|
if (set)
|
||||||
{
|
{
|
||||||
*wr_csum = real_csum;
|
*wr_csum = real_csum;
|
||||||
@@ -1133,11 +1147,26 @@ static uint32_t crc32c_iter(uint32_t prev_crc, const std::function<uint8_t*(uint
|
|||||||
return prev_crc;
|
return prev_crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void xxh3_iter(XXH3_state_t* xxh3_state, const std::function<uint8_t*(uint32_t start, uint32_t & len)> & next, uint32_t pos, uint32_t size)
|
||||||
|
{
|
||||||
|
uint32_t cur_len = 0;
|
||||||
|
while (size > 0)
|
||||||
|
{
|
||||||
|
uint8_t *data = next(pos, cur_len);
|
||||||
|
assert(data);
|
||||||
|
cur_len = (cur_len < size ? cur_len : size);
|
||||||
|
XXH3_64bits_update(xxh3_state, data, cur_len);
|
||||||
|
pos += cur_len;
|
||||||
|
size -= cur_len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool blockstore_heap_t::calc_block_checksums(uint32_t *block_csums, uint8_t *bitmap,
|
bool blockstore_heap_t::calc_block_checksums(uint32_t *block_csums, uint8_t *bitmap,
|
||||||
uint32_t start, uint32_t end, std::function<uint8_t*(uint32_t start, uint32_t & len)> next,
|
uint32_t start, uint32_t end, std::function<uint8_t*(uint32_t start, uint32_t & len)> next,
|
||||||
bool set, std::function<void(uint32_t, uint32_t, uint32_t)> bad_block_cb)
|
bool set, std::function<void(uint32_t, uint32_t, uint32_t)> bad_block_cb)
|
||||||
{
|
{
|
||||||
bool res = true;
|
bool res = true;
|
||||||
|
XXH3_state_t* xxh3_state = NULL;
|
||||||
uint32_t pos = start;
|
uint32_t pos = start;
|
||||||
uint32_t block_end = (start/dsk->csum_block_size + 1)*dsk->csum_block_size;
|
uint32_t block_end = (start/dsk->csum_block_size + 1)*dsk->csum_block_size;
|
||||||
uint32_t block_crc = 0;
|
uint32_t block_crc = 0;
|
||||||
@@ -1154,42 +1183,89 @@ bool blockstore_heap_t::calc_block_checksums(uint32_t *block_csums, uint8_t *bit
|
|||||||
pos += dsk->bitmap_granularity;
|
pos += dsk->bitmap_granularity;
|
||||||
// zero padding at the beginning or at the end of the block is not counted
|
// zero padding at the beginning or at the end of the block is not counted
|
||||||
if (pos > prev && prev > blk_start && pos < block_end)
|
if (pos > prev && prev > blk_start && pos < block_end)
|
||||||
block_crc = crc32c_pad(block_crc, NULL, 0, pos-prev, 0);
|
{
|
||||||
|
if (dsk->data_csum_type == BLOCKSTORE_CSUM_XXH3_32)
|
||||||
|
{
|
||||||
|
if (!xxh3_state)
|
||||||
|
{
|
||||||
|
xxh3_state = XXH3_createState();
|
||||||
|
XXH3_64bits_reset(xxh3_state);
|
||||||
|
}
|
||||||
|
uint32_t zeropad = pos-prev;
|
||||||
|
while (zeropad > 0)
|
||||||
|
{
|
||||||
|
uint32_t zerolen = zeropad > 4096 ? 4096 : zeropad;
|
||||||
|
XXH3_64bits_update(xxh3_state, zero_page, zerolen);
|
||||||
|
zeropad -= zerolen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
block_crc = crc32c_pad(block_crc, NULL, 0, pos-prev, 0);
|
||||||
|
}
|
||||||
prev = pos;
|
prev = pos;
|
||||||
while (pos < end && pos < block_end && (bitmap[pos/dsk->bitmap_granularity/8] & (1 << ((pos/dsk->bitmap_granularity) % 8))))
|
while (pos < end && pos < block_end && (bitmap[pos/dsk->bitmap_granularity/8] & (1 << ((pos/dsk->bitmap_granularity) % 8))))
|
||||||
pos += dsk->bitmap_granularity;
|
pos += dsk->bitmap_granularity;
|
||||||
if (pos > prev)
|
if (pos > prev)
|
||||||
{
|
{
|
||||||
isset = true;
|
isset = true;
|
||||||
block_crc = crc32c_iter(block_crc, next, prev, pos-prev);
|
if (dsk->data_csum_type == BLOCKSTORE_CSUM_XXH3_32)
|
||||||
|
{
|
||||||
|
if (!xxh3_state)
|
||||||
|
{
|
||||||
|
xxh3_state = XXH3_createState();
|
||||||
|
XXH3_64bits_reset(xxh3_state);
|
||||||
|
}
|
||||||
|
xxh3_iter(xxh3_state, next, prev, pos-prev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
block_crc = crc32c_iter(block_crc, next, prev, pos-prev);
|
||||||
}
|
}
|
||||||
prev = pos;
|
prev = pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
block_crc = crc32c_iter(block_crc, next, pos, (end > block_end ? block_end : end)-pos);
|
if (dsk->data_csum_type == BLOCKSTORE_CSUM_XXH3_32)
|
||||||
|
{
|
||||||
|
if (!xxh3_state)
|
||||||
|
{
|
||||||
|
xxh3_state = XXH3_createState();
|
||||||
|
XXH3_64bits_reset(xxh3_state);
|
||||||
|
}
|
||||||
|
xxh3_iter(xxh3_state, next, pos, (end > block_end ? block_end : end)-pos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
block_crc = crc32c_iter(block_crc, next, pos, (end > block_end ? block_end : end)-pos);
|
||||||
pos = (end > block_end ? block_end : end);
|
pos = (end > block_end ? block_end : end);
|
||||||
isset = true;
|
isset = true;
|
||||||
}
|
}
|
||||||
|
if (dsk->data_csum_type == BLOCKSTORE_CSUM_XXH3_32 && xxh3_state)
|
||||||
|
{
|
||||||
|
block_crc = (uint32_t)XXH3_64bits_digest(xxh3_state);
|
||||||
|
XXH3_64bits_reset(xxh3_state);
|
||||||
|
}
|
||||||
if (set)
|
if (set)
|
||||||
{
|
{
|
||||||
*block_csums = block_crc;
|
*block_csums = block_crc;
|
||||||
}
|
}
|
||||||
else if (isset && block_crc != *block_csums)
|
else if (isset && block_crc != *block_csums)
|
||||||
{
|
{
|
||||||
|
res = false;
|
||||||
if (bad_block_cb)
|
if (bad_block_cb)
|
||||||
{
|
|
||||||
bad_block_cb(blk_start, *block_csums, block_crc);
|
bad_block_cb(blk_start, *block_csums, block_crc);
|
||||||
res = false;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
block_end += dsk->csum_block_size;
|
block_end += dsk->csum_block_size;
|
||||||
block_crc = 0;
|
block_crc = 0;
|
||||||
block_csums++;
|
block_csums++;
|
||||||
}
|
}
|
||||||
|
if (dsk->data_csum_type == BLOCKSTORE_CSUM_XXH3_32 && xxh3_state)
|
||||||
|
{
|
||||||
|
block_crc = (uint32_t)XXH3_64bits_digest(xxh3_state);
|
||||||
|
XXH3_freeState(xxh3_state);
|
||||||
|
xxh3_state = NULL;
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1556,7 +1632,7 @@ int blockstore_heap_t::add_entry(uint32_t wr_size, uint32_t *modified_block,
|
|||||||
insert_list_items(&li, 1, false);
|
insert_list_items(&li, 1, false);
|
||||||
li->block_num = block_num;
|
li->block_num = block_num;
|
||||||
new_wr->size = wr_size;
|
new_wr->size = wr_size;
|
||||||
new_wr->crc32c = new_wr->calc_crc32c();
|
new_wr->checksum = new_wr->calc_checksum(this);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1761,7 +1837,7 @@ int blockstore_heap_t::punch_holes(heap_entry_t *wr, uint8_t *new_bitmap, uint8_
|
|||||||
*modified_block = block_num;
|
*modified_block = block_num;
|
||||||
memcpy(wr->get_int_bitmap(this), new_bitmap, dsk->clean_entry_bitmap_size);
|
memcpy(wr->get_int_bitmap(this), new_bitmap, dsk->clean_entry_bitmap_size);
|
||||||
memcpy(wr->get_checksums(this), new_csums, dsk->data_block_size/dsk->csum_block_size*(dsk->data_csum_type & 0xFF));
|
memcpy(wr->get_checksums(this), new_csums, dsk->data_block_size/dsk->csum_block_size*(dsk->data_csum_type & 0xFF));
|
||||||
wr->crc32c = wr->calc_crc32c();
|
wr->checksum = wr->calc_checksum(dsk);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ struct __attribute__((__packed__)) heap_entry_t
|
|||||||
{
|
{
|
||||||
uint16_t size;
|
uint16_t size;
|
||||||
uint16_t entry_type;
|
uint16_t entry_type;
|
||||||
uint32_t crc32c;
|
uint32_t checksum;
|
||||||
uint64_t lsn;
|
uint64_t lsn;
|
||||||
uint64_t inode;
|
uint64_t inode;
|
||||||
uint64_t stripe;
|
uint64_t stripe;
|
||||||
@@ -69,7 +69,8 @@ struct __attribute__((__packed__)) heap_entry_t
|
|||||||
uint32_t *get_checksum(blockstore_heap_t *heap);
|
uint32_t *get_checksum(blockstore_heap_t *heap);
|
||||||
uint64_t big_location(blockstore_heap_t *heap);
|
uint64_t big_location(blockstore_heap_t *heap);
|
||||||
void set_big_location(blockstore_heap_t *heap, uint64_t location);
|
void set_big_location(blockstore_heap_t *heap, uint64_t location);
|
||||||
uint32_t calc_crc32c();
|
uint32_t calc_checksum(blockstore_heap_t *heap);
|
||||||
|
uint32_t calc_checksum(blockstore_disk_t *dsk);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct __attribute__((__packed__)) heap_small_write_t
|
struct __attribute__((__packed__)) heap_small_write_t
|
||||||
@@ -80,7 +81,7 @@ struct __attribute__((__packed__)) heap_small_write_t
|
|||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
|
|
||||||
// Also includes 1 bitmap and 1 crc32c after the bitmap if checksums are disabled
|
// Also includes 1 bitmap and 1 checksum after the bitmap if block checksums are disabled
|
||||||
};
|
};
|
||||||
|
|
||||||
struct __attribute__((__packed__)) heap_big_write_t
|
struct __attribute__((__packed__)) heap_big_write_t
|
||||||
@@ -98,7 +99,7 @@ struct __attribute__((__packed__)) heap_big_intent_t
|
|||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
|
|
||||||
// Also includes 2 bitmaps and 1 crc32c if checksums are disabled
|
// Also includes 2 bitmaps and 1 checksums if block checksums are disabled
|
||||||
};
|
};
|
||||||
|
|
||||||
struct __attribute__((__packed__)) heap_list_item_t
|
struct __attribute__((__packed__)) heap_list_item_t
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ add_executable(vitastor-disk
|
|||||||
disk_tool.cpp disk_simple_offsets.cpp
|
disk_tool.cpp disk_simple_offsets.cpp
|
||||||
disk_tool_discard.cpp disk_tool_journal.cpp disk_tool_meta.cpp disk_tool_prepare.cpp disk_tool_resize.cpp
|
disk_tool_discard.cpp disk_tool_journal.cpp disk_tool_meta.cpp disk_tool_prepare.cpp disk_tool_resize.cpp
|
||||||
disk_tool_resize_auto.cpp disk_tool_udev.cpp disk_tool_utils.cpp disk_tool_upgrade.cpp
|
disk_tool_resize_auto.cpp disk_tool_udev.cpp disk_tool_utils.cpp disk_tool_upgrade.cpp
|
||||||
../util/crc32c.c ../util/str_util.cpp ../util/json_util.cpp ../../json11/json11.cpp ../util/rw_blocking.cpp ../util/allocator.cpp ../util/ringloop.cpp
|
../util/crc32c.c ../util/xxhash.c ../util/str_util.cpp ../util/json_util.cpp ../../json11/json11.cpp ../util/rw_blocking.cpp ../util/allocator.cpp ../util/ringloop.cpp
|
||||||
../blockstore/blockstore_disk.cpp ../blockstore/blockstore_heap.cpp ../blockstore/multilist.cpp
|
../blockstore/blockstore_disk.cpp ../blockstore/blockstore_heap.cpp ../blockstore/multilist.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(vitastor-disk
|
target_link_libraries(vitastor-disk
|
||||||
|
|||||||
@@ -135,8 +135,8 @@ struct disk_tool_t
|
|||||||
void choose_journal_block(uint32_t je_size);
|
void choose_journal_block(uint32_t je_size);
|
||||||
int resize_rebuild_journal();
|
int resize_rebuild_journal();
|
||||||
int resize_write_new_journal();
|
int resize_write_new_journal();
|
||||||
void remap_big_write(heap_entry_t *wr);
|
void remap_big_write(blockstore_heap_t *heap, heap_entry_t *wr);
|
||||||
void remap_small_write(heap_entry_t *wr);
|
void remap_small_write(blockstore_heap_t *heap, heap_entry_t *wr);
|
||||||
int resize_rebuild_meta();
|
int resize_rebuild_meta();
|
||||||
int resize_write_new_meta();
|
int resize_write_new_meta();
|
||||||
void free_new_meta();
|
void free_new_meta();
|
||||||
|
|||||||
@@ -765,7 +765,7 @@ close_err0:
|
|||||||
{
|
{
|
||||||
*wr->get_checksum(&heap) = sscanf_json("%jx", write_entry["data_crc32c"]);
|
*wr->get_checksum(&heap) = sscanf_json("%jx", write_entry["data_crc32c"]);
|
||||||
}
|
}
|
||||||
wr->crc32c = wr->calc_crc32c();
|
wr->checksum = wr->calc_checksum(&heap);
|
||||||
assert((uint8_t*)wr + wr->size == new_meta_buf + meta_offset + used_space);
|
assert((uint8_t*)wr + wr->size == new_meta_buf + meta_offset + used_space);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -808,7 +808,7 @@ close_err:
|
|||||||
fromhexstr(meta_entry["ext_bitmap"].string_value(), new_clean_entry_bitmap_size, wr->get_ext_bitmap(&heap));
|
fromhexstr(meta_entry["ext_bitmap"].string_value(), new_clean_entry_bitmap_size, wr->get_ext_bitmap(&heap));
|
||||||
if (new_data_csum_size)
|
if (new_data_csum_size)
|
||||||
fromhexstr(meta_entry["block_csums"].string_value(), new_data_csum_size, wr->get_checksums(&heap));
|
fromhexstr(meta_entry["block_csums"].string_value(), new_data_csum_size, wr->get_checksums(&heap));
|
||||||
wr->crc32c = wr->calc_crc32c();
|
wr->checksum = wr->calc_checksum(&heap);
|
||||||
assert((uint8_t*)wr + wr->size == new_meta_buf + meta_offset + used_space);
|
assert((uint8_t*)wr + wr->size == new_meta_buf + meta_offset + used_space);
|
||||||
auto j_it = journal_by_object.find(oid);
|
auto j_it = journal_by_object.find(oid);
|
||||||
if (j_it != journal_by_object.end())
|
if (j_it != journal_by_object.end())
|
||||||
@@ -874,7 +874,7 @@ close_err:
|
|||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
wr->size = wr->get_size(&heap);
|
wr->size = wr->get_size(&heap);
|
||||||
wr->crc32c = wr->calc_crc32c();
|
wr->checksum = wr->calc_checksum(&heap);
|
||||||
assert((uint8_t*)wr + wr->size == new_meta_buf + meta_offset + used_space);
|
assert((uint8_t*)wr + wr->size == new_meta_buf + meta_offset + used_space);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -526,7 +526,7 @@ int disk_tool_t::resize_write_new_journal()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void disk_tool_t::remap_big_write(heap_entry_t *wr)
|
void disk_tool_t::remap_big_write(blockstore_heap_t *heap, heap_entry_t *wr)
|
||||||
{
|
{
|
||||||
uint64_t block_num = wr->big().block_num;
|
uint64_t block_num = wr->big().block_num;
|
||||||
auto remap_it = data_remap.find(block_num);
|
auto remap_it = data_remap.find(block_num);
|
||||||
@@ -539,10 +539,10 @@ void disk_tool_t::remap_big_write(heap_entry_t *wr)
|
|||||||
}
|
}
|
||||||
block_num += data_idx_diff;
|
block_num += data_idx_diff;
|
||||||
wr->big().block_num = block_num;
|
wr->big().block_num = block_num;
|
||||||
wr->crc32c = wr->calc_crc32c();
|
wr->checksum = wr->calc_checksum(heap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void disk_tool_t::remap_small_write(heap_entry_t *wr)
|
void disk_tool_t::remap_small_write(blockstore_heap_t *heap, heap_entry_t *wr)
|
||||||
{
|
{
|
||||||
if (new_meta_format == BLOCKSTORE_META_FORMAT_HEAP && wr->small().len > 0)
|
if (new_meta_format == BLOCKSTORE_META_FORMAT_HEAP && wr->small().len > 0)
|
||||||
{
|
{
|
||||||
@@ -554,7 +554,7 @@ void disk_tool_t::remap_small_write(heap_entry_t *wr)
|
|||||||
memcpy(new_journal_ptr, buffer_area+wr->small().location, wr->small().len);
|
memcpy(new_journal_ptr, buffer_area+wr->small().location, wr->small().len);
|
||||||
wr->small().location = new_journal_ptr-new_journal_buf;
|
wr->small().location = new_journal_ptr-new_journal_buf;
|
||||||
new_journal_ptr += wr->small().len;
|
new_journal_ptr += wr->small().len;
|
||||||
wr->crc32c = wr->calc_crc32c();
|
wr->checksum = wr->calc_checksum(heap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -601,11 +601,11 @@ int disk_tool_t::resize_rebuild_meta()
|
|||||||
{
|
{
|
||||||
if (wr->type() == BS_HEAP_BIG_WRITE || wr->type() == BS_HEAP_BIG_INTENT)
|
if (wr->type() == BS_HEAP_BIG_WRITE || wr->type() == BS_HEAP_BIG_INTENT)
|
||||||
{
|
{
|
||||||
remap_big_write(wr);
|
remap_big_write(heap, wr);
|
||||||
}
|
}
|
||||||
else if (wr->type() == BS_HEAP_SMALL_WRITE)
|
else if (wr->type() == BS_HEAP_SMALL_WRITE)
|
||||||
{
|
{
|
||||||
remap_small_write(wr);
|
remap_small_write(heap, wr);
|
||||||
}
|
}
|
||||||
// New -> New
|
// New -> New
|
||||||
if ((new_meta_pos % dsk.meta_block_size) + wr->size > dsk.meta_block_size)
|
if ((new_meta_pos % dsk.meta_block_size) + wr->size > dsk.meta_block_size)
|
||||||
@@ -666,7 +666,7 @@ int disk_tool_t::resize_rebuild_meta()
|
|||||||
memcpy(((uint8_t*)wr) + sizeof(heap_big_write_t) + new_clean_entry_bitmap_size, bitmap+new_clean_entry_bitmap_size, new_clean_entry_bitmap_size);
|
memcpy(((uint8_t*)wr) + sizeof(heap_big_write_t) + new_clean_entry_bitmap_size, bitmap+new_clean_entry_bitmap_size, new_clean_entry_bitmap_size);
|
||||||
memcpy(((uint8_t*)wr) + sizeof(heap_big_write_t) + 2*new_clean_entry_bitmap_size, bitmap+2*new_clean_entry_bitmap_size, new_data_csum_size);
|
memcpy(((uint8_t*)wr) + sizeof(heap_big_write_t) + 2*new_clean_entry_bitmap_size, bitmap+2*new_clean_entry_bitmap_size, new_data_csum_size);
|
||||||
}
|
}
|
||||||
wr->crc32c = wr->calc_crc32c();
|
wr->checksum = wr->calc_checksum(&dsk);
|
||||||
new_meta_pos += wr->size;
|
new_meta_pos += wr->size;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ add_executable(test_heap
|
|||||||
../blockstore/multilist.cpp
|
../blockstore/multilist.cpp
|
||||||
../blockstore/blockstore_heap.cpp
|
../blockstore/blockstore_heap.cpp
|
||||||
../util/crc32c.c
|
../util/crc32c.c
|
||||||
|
../util/xxhash.c
|
||||||
../util/allocator.cpp
|
../util/allocator.cpp
|
||||||
../blockstore/blockstore_disk.cpp
|
../blockstore/blockstore_disk.cpp
|
||||||
../util/str_util.cpp
|
../util/str_util.cpp
|
||||||
|
|||||||
+17
-17
@@ -1358,7 +1358,7 @@ void test_corruption()
|
|||||||
blockstore_heap_t heap(&dsk, buffer_area.data());
|
blockstore_heap_t heap(&dsk, buffer_area.data());
|
||||||
auto entry = ((heap_entry_t*)tmp.data());
|
auto entry = ((heap_entry_t*)tmp.data());
|
||||||
entry->size++;
|
entry->size++;
|
||||||
entry->crc32c = entry->calc_crc32c();
|
entry->checksum = entry->calc_checksum(&heap);
|
||||||
uint64_t entries_loaded;
|
uint64_t entries_loaded;
|
||||||
assert(heap.load_blocks(0, dsk.meta_block_size, tmp.data(), false, entries_loaded) == EDOM);
|
assert(heap.load_blocks(0, dsk.meta_block_size, tmp.data(), false, entries_loaded) == EDOM);
|
||||||
}
|
}
|
||||||
@@ -2423,7 +2423,7 @@ void test_skip_double_claim()
|
|||||||
wr1->stripe = 0;
|
wr1->stripe = 0;
|
||||||
wr1->version = 1;
|
wr1->version = 1;
|
||||||
wr1->set_big_location(&heap, 0x40000); // <-- overwritten
|
wr1->set_big_location(&heap, 0x40000); // <-- overwritten
|
||||||
wr1->crc32c = wr1->calc_crc32c();
|
wr1->checksum = wr1->calc_checksum(&heap);
|
||||||
total_size += wr1->size;
|
total_size += wr1->size;
|
||||||
|
|
||||||
wr2 = (heap_entry_t*)(tmp.data() + total_size);
|
wr2 = (heap_entry_t*)(tmp.data() + total_size);
|
||||||
@@ -2434,7 +2434,7 @@ void test_skip_double_claim()
|
|||||||
wr2->stripe = 0;
|
wr2->stripe = 0;
|
||||||
wr2->version = 2;
|
wr2->version = 2;
|
||||||
wr2->set_big_location(&heap, 0); // <-- double claimed
|
wr2->set_big_location(&heap, 0); // <-- double claimed
|
||||||
wr2->crc32c = wr2->calc_crc32c();
|
wr2->checksum = wr2->calc_checksum(&heap);
|
||||||
total_size += wr2->size;
|
total_size += wr2->size;
|
||||||
|
|
||||||
wr3 = (heap_entry_t*)(tmp.data() + total_size);
|
wr3 = (heap_entry_t*)(tmp.data() + total_size);
|
||||||
@@ -2445,7 +2445,7 @@ void test_skip_double_claim()
|
|||||||
wr3->stripe = 0x20000;
|
wr3->stripe = 0x20000;
|
||||||
wr3->version = 1;
|
wr3->version = 1;
|
||||||
wr3->set_big_location(&heap, 0); // <-- double claimed
|
wr3->set_big_location(&heap, 0); // <-- double claimed
|
||||||
wr3->crc32c = wr3->calc_crc32c();
|
wr3->checksum = wr3->calc_checksum(&heap);
|
||||||
total_size += wr3->size;
|
total_size += wr3->size;
|
||||||
|
|
||||||
wr4 = (heap_entry_t*)(tmp.data() + total_size);
|
wr4 = (heap_entry_t*)(tmp.data() + total_size);
|
||||||
@@ -2456,7 +2456,7 @@ void test_skip_double_claim()
|
|||||||
wr4->stripe = 0x20000;
|
wr4->stripe = 0x20000;
|
||||||
wr4->version = 2;
|
wr4->version = 2;
|
||||||
wr4->set_big_location(&heap, 0x20000);
|
wr4->set_big_location(&heap, 0x20000);
|
||||||
wr4->crc32c = wr4->calc_crc32c();
|
wr4->checksum = wr4->calc_checksum(&heap);
|
||||||
total_size += wr4->size;
|
total_size += wr4->size;
|
||||||
|
|
||||||
*(uint16_t*)(tmp.data() + total_size) = dsk.meta_block_size - total_size;
|
*(uint16_t*)(tmp.data() + total_size) = dsk.meta_block_size - total_size;
|
||||||
@@ -2495,13 +2495,13 @@ void test_skip_double_claim()
|
|||||||
blockstore_heap_t heap(&dsk, buffer_area.data());
|
blockstore_heap_t heap(&dsk, buffer_area.data());
|
||||||
|
|
||||||
wr1->lsn = 1;
|
wr1->lsn = 1;
|
||||||
wr1->crc32c = wr1->calc_crc32c();
|
wr1->checksum = wr1->calc_checksum(&heap);
|
||||||
wr2->lsn = 3;
|
wr2->lsn = 3;
|
||||||
wr2->crc32c = wr2->calc_crc32c();
|
wr2->checksum = wr2->calc_checksum(&heap);
|
||||||
wr3->lsn = 2;
|
wr3->lsn = 2;
|
||||||
wr3->crc32c = wr3->calc_crc32c();
|
wr3->checksum = wr3->calc_checksum(&heap);
|
||||||
wr4->lsn = 4;
|
wr4->lsn = 4;
|
||||||
wr4->crc32c = wr4->calc_crc32c();
|
wr4->checksum = wr4->calc_checksum(&heap);
|
||||||
|
|
||||||
uint64_t entries_loaded;
|
uint64_t entries_loaded;
|
||||||
heap.load_blocks(0, dsk.meta_block_size, tmp.data(), false, entries_loaded);
|
heap.load_blocks(0, dsk.meta_block_size, tmp.data(), false, entries_loaded);
|
||||||
@@ -2538,13 +2538,13 @@ void test_skip_double_claim()
|
|||||||
// [3 4] [1 2] - should erase second
|
// [3 4] [1 2] - should erase second
|
||||||
|
|
||||||
wr1->lsn = 3;
|
wr1->lsn = 3;
|
||||||
wr1->crc32c = wr1->calc_crc32c();
|
wr1->checksum = wr1->calc_checksum(&heap);
|
||||||
wr2->lsn = 4;
|
wr2->lsn = 4;
|
||||||
wr2->crc32c = wr2->calc_crc32c();
|
wr2->checksum = wr2->calc_checksum(&heap);
|
||||||
wr3->lsn = 1;
|
wr3->lsn = 1;
|
||||||
wr3->crc32c = wr3->calc_crc32c();
|
wr3->checksum = wr3->calc_checksum(&heap);
|
||||||
wr4->lsn = 2;
|
wr4->lsn = 2;
|
||||||
wr4->crc32c = wr4->calc_crc32c();
|
wr4->checksum = wr4->calc_checksum(&heap);
|
||||||
|
|
||||||
uint64_t entries_loaded;
|
uint64_t entries_loaded;
|
||||||
heap.load_blocks(0, dsk.meta_block_size, tmp.data(), false, entries_loaded);
|
heap.load_blocks(0, dsk.meta_block_size, tmp.data(), false, entries_loaded);
|
||||||
@@ -2609,7 +2609,7 @@ void test_postpone_load()
|
|||||||
wr1->version = 1;
|
wr1->version = 1;
|
||||||
wr1->set_big_location(&heap, 0x20000);
|
wr1->set_big_location(&heap, 0x20000);
|
||||||
memset(wr1->get_ext_bitmap(&heap), 0xff, dsk.clean_entry_bitmap_size);
|
memset(wr1->get_ext_bitmap(&heap), 0xff, dsk.clean_entry_bitmap_size);
|
||||||
wr1->crc32c = wr1->calc_crc32c();
|
wr1->checksum = wr1->calc_checksum(&heap);
|
||||||
total_size += wr1->size;
|
total_size += wr1->size;
|
||||||
|
|
||||||
assert(total_size+heap.get_big_entry_size() <= dsk.meta_block_size);
|
assert(total_size+heap.get_big_entry_size() <= dsk.meta_block_size);
|
||||||
@@ -2622,7 +2622,7 @@ void test_postpone_load()
|
|||||||
wr1->version = 1;
|
wr1->version = 1;
|
||||||
wr1->set_big_location(&heap, 0x20000);
|
wr1->set_big_location(&heap, 0x20000);
|
||||||
memset(wr1->get_ext_bitmap(&heap), 0xff, dsk.clean_entry_bitmap_size);
|
memset(wr1->get_ext_bitmap(&heap), 0xff, dsk.clean_entry_bitmap_size);
|
||||||
wr1->crc32c = wr1->calc_crc32c();
|
wr1->checksum = wr1->calc_checksum(&heap);
|
||||||
total_size += wr1->size;
|
total_size += wr1->size;
|
||||||
|
|
||||||
uint32_t small_size = heap.get_small_entry_size(0, 4096);
|
uint32_t small_size = heap.get_small_entry_size(0, 4096);
|
||||||
@@ -2641,7 +2641,7 @@ void test_postpone_load()
|
|||||||
wr2->small().location = lsn*4096;
|
wr2->small().location = lsn*4096;
|
||||||
memset(wr2->get_ext_bitmap(&heap), 0xff, dsk.clean_entry_bitmap_size);
|
memset(wr2->get_ext_bitmap(&heap), 0xff, dsk.clean_entry_bitmap_size);
|
||||||
*((uint32_t*)wr2->get_checksum(&heap)) = crc32c(0, buffer_area.data()+wr2->small().location, 4096);
|
*((uint32_t*)wr2->get_checksum(&heap)) = crc32c(0, buffer_area.data()+wr2->small().location, 4096);
|
||||||
wr2->crc32c = wr2->calc_crc32c();
|
wr2->checksum = wr2->calc_checksum(&heap);
|
||||||
total_size += small_size;
|
total_size += small_size;
|
||||||
};
|
};
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
@@ -2661,7 +2661,7 @@ void test_postpone_load()
|
|||||||
wr1->version = 1;
|
wr1->version = 1;
|
||||||
wr1->set_big_location(&heap, 0x20000);
|
wr1->set_big_location(&heap, 0x20000);
|
||||||
memset(wr1->get_ext_bitmap(&heap), 0xff, dsk.clean_entry_bitmap_size);
|
memset(wr1->get_ext_bitmap(&heap), 0xff, dsk.clean_entry_bitmap_size);
|
||||||
wr1->crc32c = wr1->calc_crc32c();
|
wr1->checksum = wr1->calc_checksum(&heap);
|
||||||
total_size += wr1->size;
|
total_size += wr1->size;
|
||||||
|
|
||||||
*(uint16_t*)(tmp.data() + total_size) = dsk.meta_block_size - total_size;
|
*(uint16_t*)(tmp.data() + total_size) = dsk.meta_block_size - total_size;
|
||||||
|
|||||||
+1
-1
@@ -391,7 +391,7 @@ uint32_t crc32c(uint32_t crc, const void *buf, size_t len)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint8_t zero_page[4096] = {};
|
uint8_t zero_page[4096] = {};
|
||||||
|
|
||||||
uint32_t crc32c_pad(uint32_t prev_crc, const void *buf, size_t len, size_t left_pad, size_t right_pad)
|
uint32_t crc32c_pad(uint32_t prev_crc, const void *buf, size_t len, size_t left_pad, size_t right_pad)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ extern "C" {
|
|||||||
uint32_t crc32c(uint32_t crc, const void *buf, size_t len);
|
uint32_t crc32c(uint32_t crc, const void *buf, size_t len);
|
||||||
uint32_t crc32c_pad(uint32_t prev_crc, const void *buf, size_t len, size_t left_pad, size_t right_pad);
|
uint32_t crc32c_pad(uint32_t prev_crc, const void *buf, size_t len, size_t left_pad, size_t right_pad);
|
||||||
uint32_t crc32c_nopad(uint32_t prev_crc, const void *buf, size_t len, size_t left_pad, size_t right_pad);
|
uint32_t crc32c_nopad(uint32_t prev_crc, const void *buf, size_t len, size_t left_pad, size_t right_pad);
|
||||||
|
extern uint8_t zero_page[4096];
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+7492
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
|||||||
|
// 7.5k LOC header is not a header
|
||||||
|
// This is a real header for xxhash3
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(__cplusplus) && !defined(XXH_NO_EXTERNC_GUARD)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
XXH_OK = 0,
|
||||||
|
XXH_ERROR
|
||||||
|
} XXH_errorcode;
|
||||||
|
typedef uint64_t XXH64_hash_t;
|
||||||
|
XXH64_hash_t XXH3_64bits(const void* input, size_t length);
|
||||||
|
__attribute__((__pure__)) XXH64_hash_t XXH3_64bits( const void* input, size_t length);
|
||||||
|
__attribute__((__pure__)) XXH64_hash_t XXH3_64bits_withSeed( const void* input, size_t length, XXH64_hash_t seed);
|
||||||
|
__attribute__((__pure__)) XXH64_hash_t XXH3_64bits_withSecret( const void* data, size_t len, const void* secret, size_t secretSize);
|
||||||
|
typedef struct XXH3_state_s XXH3_state_t;
|
||||||
|
__attribute__((__malloc__)) XXH3_state_t* XXH3_createState(void);
|
||||||
|
XXH_errorcode XXH3_freeState(XXH3_state_t* statePtr);
|
||||||
|
void XXH3_copyState( XXH3_state_t* dst_state, const XXH3_state_t* src_state);
|
||||||
|
XXH_errorcode XXH3_64bits_reset( XXH3_state_t* statePtr);
|
||||||
|
XXH_errorcode XXH3_64bits_reset_withSeed( XXH3_state_t* statePtr, XXH64_hash_t seed);
|
||||||
|
XXH_errorcode XXH3_64bits_reset_withSecret( XXH3_state_t* statePtr, const void* secret, size_t secretSize);
|
||||||
|
XXH_errorcode XXH3_64bits_update ( XXH3_state_t* statePtr, const void* input, size_t length);
|
||||||
|
__attribute__((__pure__)) XXH64_hash_t XXH3_64bits_digest ( const XXH3_state_t* statePtr);
|
||||||
|
|
||||||
|
#if defined (__cplusplus) && !defined(XXH_NO_EXTERNC_GUARD)
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
+1
-1
@@ -120,7 +120,7 @@ wait_condition()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
VITASTOR_CFG='"etcd_address":"'$ETCD_URL'"'
|
VITASTOR_CFG='"etcd_address":"'$ETCD_URL'"'"$VITASTOR_CFG"
|
||||||
if [[ "$ETCD_SCHEME" = "https" ]]; then
|
if [[ "$ETCD_SCHEME" = "https" ]]; then
|
||||||
VITASTOR_CFG="$VITASTOR_CFG"',"etcd_ca":"'$(pwd)'/testdata/etcd.crt"'
|
VITASTOR_CFG="$VITASTOR_CFG"',"etcd_ca":"'$(pwd)'/testdata/etcd.crt"'
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ SCHEME=ec ./test_heal.sh
|
|||||||
ANTIETCD=1 ./test_heal.sh
|
ANTIETCD=1 ./test_heal.sh
|
||||||
|
|
||||||
./test_checksum.sh
|
./test_checksum.sh
|
||||||
|
TEST_NAME=xxhash OSD_ARGS="--data_csum_type xxh3_32" ./test_checksum.sh
|
||||||
OLD=1 ./test_checksum.sh
|
OLD=1 ./test_checksum.sh
|
||||||
./test_corrupt_all.sh
|
./test_corrupt_all.sh
|
||||||
OLD=1 ./test_corrupt_all.sh
|
OLD=1 ./test_corrupt_all.sh
|
||||||
|
|||||||
@@ -2,26 +2,24 @@
|
|||||||
|
|
||||||
OSD_ARGS="--data_csum_type crc32c --csum_block_size 32k --inmemory_journal false $OSD_ARGS"
|
OSD_ARGS="--data_csum_type crc32c --csum_block_size 32k --inmemory_journal false $OSD_ARGS"
|
||||||
OFFSET_ARGS="--data_csum_type crc32c --csum_block_size 32k --inmemory_journal false $OFFSET_ARGS"
|
OFFSET_ARGS="--data_csum_type crc32c --csum_block_size 32k --inmemory_journal false $OFFSET_ARGS"
|
||||||
PG_COUNT=${PG_COUNT:-64}
|
PG_COUNT=${PG_COUNT:-1}
|
||||||
. `dirname $0`/run_3osds.sh
|
. `dirname $0`/run_3osds.sh
|
||||||
check_qemu
|
check_qemu
|
||||||
|
|
||||||
IMG_SIZE=128
|
IMG_SIZE=128
|
||||||
|
|
||||||
|
PRIMARY=$($ETCDCTL get --print-value-only /vitastor/pg/config | jq -r '.items["1"]["1"].primary')
|
||||||
|
|
||||||
$ETCDCTL put /vitastor/config/inode/1/1 '{"name":"testimg","size":'$((IMG_SIZE*1024*1024))'}'
|
$ETCDCTL put /vitastor/config/inode/1/1 '{"name":"testimg","size":'$((IMG_SIZE*1024*1024))'}'
|
||||||
|
|
||||||
# Write
|
# Write
|
||||||
$VITASTOR_FIO -bs=1M -direct=1 -iodepth=4 \
|
$VITASTOR_FIO -bs=1M -direct=1 -iodepth=4 \
|
||||||
-mirror_file=./testdata/bin/mirror.bin -end_fsync=1 -rw=write -image=testimg -runtime=10
|
-mirror_file=./testdata/bin/mirror.bin -end_fsync=1 -rw=write -image=testimg -runtime=10
|
||||||
|
|
||||||
# Intentionally corrupt OSD data and restart it
|
# Intentionally corrupt primary OSD data
|
||||||
kill $OSD1_PID
|
|
||||||
data_offset=$(build/src/disk_tool/vitastor-disk simple-offsets ./testdata/bin/test_osd1.bin $OFFSET_ARGS | grep data_offset | awk '{print $2}')
|
data_offset=$(build/src/disk_tool/vitastor-disk simple-offsets ./testdata/bin/test_osd1.bin $OFFSET_ARGS | grep data_offset | awk '{print $2}')
|
||||||
truncate -s $data_offset ./testdata/bin/test_osd1.bin
|
truncate -s $data_offset ./testdata/bin/test_osd$PRIMARY.bin
|
||||||
dd if=/dev/zero of=./testdata/bin/test_osd1.bin bs=1024 count=1 seek=$((OSD_SIZE*1024-1))
|
dd if=/dev/zero of=./testdata/bin/test_osd$PRIMARY.bin bs=1024 count=1 seek=$((OSD_SIZE*1024-1))
|
||||||
start_osd 1
|
|
||||||
|
|
||||||
# FIXME: corrupt the journal WHEN OSD IS RUNNING and check reads too
|
|
||||||
|
|
||||||
# Wait until start
|
# Wait until start
|
||||||
wait_up 10
|
wait_up 10
|
||||||
|
|||||||
Reference in New Issue
Block a user