Browse Source

Check result to be equal to iov_len

blocking-uring-test
Vitaliy Filippov 3 years ago
parent
commit
e40a71b2ce
  1. 14
      blockstore_flush.cpp
  2. 4
      blockstore_init.cpp
  3. 2
      blockstore_read.cpp
  4. 7
      blockstore_stable.cpp
  5. 7
      blockstore_sync.cpp
  6. 8
      blockstore_write.cpp

14
blockstore_flush.cpp

@ -24,9 +24,12 @@ journal_flusher_co::journal_flusher_co()
wait_state = 0;
simple_callback = [this](ring_data_t* data)
{
if (data->res < 0)
if (data->res != data->iov.iov_len)
{
throw std::runtime_error("write operation failed. in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111");
throw std::runtime_error(
"write operation failed ("+std::to_string(data->res)+" != "+std::to_string(data->iov.iov_len)+
"). in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111"
);
}
wait_count--;
};
@ -243,9 +246,12 @@ resume_0:
data->iov = (struct iovec){ meta_it->second.buf, 512 };
data->callback = [this](ring_data_t* data)
{
if (data->res < 0)
if (data->res != data->iov.iov_len)
{
throw std::runtime_error("write operation failed. in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111");
throw std::runtime_error(
"write operation failed ("+std::to_string(data->res)+" != "+std::to_string(data->iov.iov_len)+
"). in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111"
);
}
meta_it->second.state = 1;
wait_count--;

4
blockstore_init.cpp

@ -7,7 +7,7 @@ blockstore_init_meta::blockstore_init_meta(blockstore *bs)
void blockstore_init_meta::handle_event(ring_data_t *data)
{
if (data->res < 0)
if (data->res <= 0)
{
throw std::runtime_error(
std::string("read metadata failed at offset ") + std::to_string(metadata_read) +
@ -29,6 +29,8 @@ int blockstore_init_meta::loop()
if (!metadata_buffer)
{
metadata_buffer = (uint8_t*)memalign(512, 2*bs->metadata_buf_size);
if (!metadata_buffer)
throw std::bad_alloc();
}
if (!submitted)
{

2
blockstore_read.cpp

@ -144,7 +144,7 @@ int blockstore::dequeue_read(blockstore_operation *read_op)
void blockstore::handle_read_event(ring_data_t *data, blockstore_operation *op)
{
op->pending_ops--;
if (data->res < 0)
if (data->res != data->iov.iov_len)
{
// read error
op->retval = data->res;

7
blockstore_stable.cpp

@ -107,9 +107,12 @@ int blockstore::dequeue_stable(blockstore_operation *op)
void blockstore::handle_stable_event(ring_data_t *data, blockstore_operation *op)
{
if (data->res < 0)
if (data->res != data->iov.iov_len)
{
throw std::runtime_error("write operation failed. in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111");
throw std::runtime_error(
"write operation failed ("+std::to_string(data->res)+" != "+std::to_string(data->iov.iov_len)+
"). in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111"
);
}
op->pending_ops--;
if (op->pending_ops == 0)

7
blockstore_sync.cpp

@ -111,9 +111,12 @@ int blockstore::continue_sync(blockstore_operation *op)
void blockstore::handle_sync_event(ring_data_t *data, blockstore_operation *op)
{
if (data->res < 0)
if (data->res < data->iov.iov_len)
{
throw std::runtime_error("write operation failed. in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111");
throw std::runtime_error(
"write operation failed ("+std::to_string(data->res)+" != "+std::to_string(data->iov.iov_len)+
"). in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111"
);
}
op->pending_ops--;
if (op->pending_ops == 0)

8
blockstore_write.cpp

@ -96,6 +96,7 @@ int blockstore::dequeue_write(blockstore_operation *op)
vcnt = 1;
op->iov_zerofill[0] = (struct iovec){ op->buf, op->len };
}
data->iov.iov_len = op->len; // to check it in the callback
data->callback = cb;
my_uring_prep_writev(
sqe, data_fd, op->iov_zerofill, vcnt, data_offset + (loc << block_order)
@ -150,10 +151,13 @@ int blockstore::dequeue_write(blockstore_operation *op)
void blockstore::handle_write_event(ring_data_t *data, blockstore_operation *op)
{
if (data->res < 0)
if (data->res != data->iov.iov_len)
{
// FIXME: our state becomes corrupted after a write error. maybe do something better than just die
throw std::runtime_error("write operation failed. in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111");
throw std::runtime_error(
"write operation failed ("+std::to_string(data->res)+" != "+std::to_string(data->iov.iov_len)+
"). in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111"
);
}
op->pending_ops--;
if (op->pending_ops == 0)

Loading…
Cancel
Save