Add a test for parallel reads with block checksums
This commit is contained in:
@@ -410,7 +410,7 @@ void journal_flusher_co::iterate_checksum_holes(std::function<void(int, uint32_t
|
||||
uint32_t blk_begin = (prev_begin - prev_begin%bs->dsk.csum_block_size);
|
||||
if (blk_begin < big_start)
|
||||
blk_begin = big_start;
|
||||
cb(pos, blk_begin, prev_begin);
|
||||
cb(pos++, blk_begin, prev_begin);
|
||||
r++;
|
||||
}
|
||||
if ((prev_end % bs->dsk.csum_block_size) && prev_end < big_end)
|
||||
@@ -418,7 +418,7 @@ void journal_flusher_co::iterate_checksum_holes(std::function<void(int, uint32_t
|
||||
uint32_t blk_end = prev_end - (prev_end % bs->dsk.csum_block_size) + bs->dsk.csum_block_size;
|
||||
if (blk_end > big_end)
|
||||
blk_end = big_end;
|
||||
cb(i, prev_end, blk_end);
|
||||
cb(++pos, prev_end, blk_end);
|
||||
r++;
|
||||
}
|
||||
return r;
|
||||
@@ -430,10 +430,12 @@ void journal_flusher_co::fill_partial_checksum_blocks()
|
||||
iterate_checksum_holes([&](int vec_pos, uint32_t hole_start, uint32_t hole_end)
|
||||
{
|
||||
read_to_fill_incomplete = true;
|
||||
// bs->prepare_read(read_vec, cur_obj, end_wr, hole_start, hole_end);
|
||||
uint32_t blk_begin = (hole_start - hole_start % bs->dsk.csum_block_size);
|
||||
bs->prepare_disk_read(read_vec, read_vec.size(), cur_obj, end_wr,
|
||||
hole_start - hole_start % bs->dsk.csum_block_size, hole_start - hole_start % bs->dsk.csum_block_size + bs->dsk.csum_block_size,
|
||||
hole_start - hole_start % bs->dsk.csum_block_size, hole_start - hole_start % bs->dsk.csum_block_size + bs->dsk.csum_block_size,
|
||||
blk_begin < big_start ? big_start : blk_begin,
|
||||
(blk_begin + bs->dsk.csum_block_size) > big_end ? big_end : (blk_begin + bs->dsk.csum_block_size),
|
||||
blk_begin < big_start ? big_start : blk_begin,
|
||||
(blk_begin + bs->dsk.csum_block_size) > big_end ? big_end : (blk_begin + bs->dsk.csum_block_size),
|
||||
COPY_BUF_CSUM_FILL | (bs->perfect_csum_update ? 0 : COPY_BUF_SKIP_CSUM));
|
||||
auto & vec = read_vec[read_vec.size()-1];
|
||||
if (!vec.buf)
|
||||
@@ -469,7 +471,7 @@ int journal_flusher_co::check_and_punch_checksums()
|
||||
return 0;
|
||||
}
|
||||
// Verify data checksums
|
||||
cur_obj = bs->heap->read_locked_entry(cur_oid, copy_id); // FIXME locks can be removed from flusher
|
||||
cur_obj = bs->heap->read_locked_entry(cur_oid, copy_id);
|
||||
bool csum_ok = true;
|
||||
for (int i = 0; i < read_vec.size(); i++)
|
||||
{
|
||||
@@ -507,8 +509,7 @@ int journal_flusher_co::check_and_punch_checksums()
|
||||
// Nothing to do
|
||||
return 0;
|
||||
}
|
||||
// FIXME: Do it before read_buffered?
|
||||
cur_obj = bs->heap->read_entry(cur_oid, &modified_block, true);
|
||||
cur_obj = bs->heap->read_entry(cur_oid, &modified_block);
|
||||
if (!cur_obj)
|
||||
{
|
||||
// Object is deleted, abort compaction
|
||||
|
||||
@@ -160,6 +160,7 @@ public:
|
||||
uint32_t blk_start, uint32_t blk_end, uint32_t start, uint32_t end, uint32_t copy_flags);
|
||||
void find_holes(std::vector<copy_buffer_t> & read_vec, uint32_t item_start, uint32_t item_end,
|
||||
std::function<void(int&, uint32_t, uint32_t)> callback);
|
||||
void free_read_buffers(std::vector<copy_buffer_t> & rv);
|
||||
void handle_read_event(ring_data_t *data, blockstore_op_t *op);
|
||||
bool verify_read_checksums(blockstore_op_t *op);
|
||||
|
||||
|
||||
@@ -54,17 +54,7 @@ int blockstore_impl_t::dequeue_read(blockstore_op_t *op)
|
||||
{
|
||||
// Need to wait. undo added requests, unlock lsn
|
||||
heap->unlock_entry(op->oid, PRIV(op)->lsn);
|
||||
if (dsk.csum_block_size > dsk.bitmap_granularity)
|
||||
{
|
||||
for (auto & vec: rv)
|
||||
{
|
||||
if (!(vec.copy_flags & COPY_BUF_COALESCED) && vec.buf)
|
||||
{
|
||||
free(vec.buf);
|
||||
vec.buf = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
free_read_buffers(rv);
|
||||
rv.clear();
|
||||
return 0;
|
||||
}
|
||||
@@ -73,6 +63,7 @@ int blockstore_impl_t::dequeue_read(blockstore_op_t *op)
|
||||
{
|
||||
// everything is fulfilled from memory
|
||||
op->retval = op->len;
|
||||
free_read_buffers(rv);
|
||||
FINISH_OP(op);
|
||||
return 2;
|
||||
}
|
||||
@@ -305,6 +296,21 @@ void blockstore_impl_t::find_holes(std::vector<copy_buffer_t> & read_vec,
|
||||
}
|
||||
}
|
||||
|
||||
void blockstore_impl_t::free_read_buffers(std::vector<copy_buffer_t> & rv)
|
||||
{
|
||||
if (dsk.csum_block_size > dsk.bitmap_granularity)
|
||||
{
|
||||
for (auto & vec: rv)
|
||||
{
|
||||
if (!(vec.copy_flags & COPY_BUF_COALESCED) && vec.buf)
|
||||
{
|
||||
free(vec.buf);
|
||||
vec.buf = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void blockstore_impl_t::handle_read_event(ring_data_t *data, blockstore_op_t *op)
|
||||
{
|
||||
live = true;
|
||||
@@ -322,6 +328,7 @@ void blockstore_impl_t::handle_read_event(ring_data_t *data, blockstore_op_t *op
|
||||
else if (op->retval == 0)
|
||||
op->retval = op->len;
|
||||
heap->unlock_entry(op->oid, PRIV(op)->lsn);
|
||||
free_read_buffers(PRIV(op)->read_vec);
|
||||
FINISH_OP(op);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user