if (!ictx->image_watcher->is_lock_owner() &&
(m_expected_aio_restarts == 0 ||
m_aio_completion_restarts < m_expected_aio_restarts)) {
- EXPECT_EQ(0, ictx->image_watcher->request_lock(
+ ictx->image_watcher->request_lock(
boost::bind(&TestImageWatcher::handle_restart_aio, this, ictx, _1),
- aio_completion));
+ aio_completion);
} else {
{
Mutex::Locker l2(aio_completion->lock);
- aio_completion->complete();
+ aio_completion->complete(ictx->cct);
}
m_aio_completions.erase(aio_completion);
{
RWLock::WLocker l(ictx->owner_lock);
- ASSERT_EQ(0, ictx->image_watcher->request_lock(
+ ictx->image_watcher->request_lock(
boost::bind(&TestImageWatcher::handle_restart_aio, this, ictx, _1),
- create_aio_completion(*ictx)));
- ASSERT_EQ(0, ictx->image_watcher->request_lock(
+ create_aio_completion(*ictx));
+ ictx->image_watcher->request_lock(
boost::bind(&TestImageWatcher::handle_restart_aio, this, ictx, _1),
- create_aio_completion(*ictx)));
+ create_aio_completion(*ictx));
}
ASSERT_TRUE(wait_for_notifies(*ictx));
{
RWLock::WLocker l(ictx->owner_lock);
- ASSERT_EQ(0, ictx->image_watcher->request_lock(
+ ictx->image_watcher->request_lock(
boost::bind(&TestImageWatcher::handle_restart_aio, this, ictx, _1),
- create_aio_completion(*ictx)));
+ create_aio_completion(*ictx));
}
ASSERT_TRUE(wait_for_notifies(*ictx));
{
RWLock::WLocker l(ictx->owner_lock);
- ASSERT_EQ(0, ictx->image_watcher->request_lock(
+ ictx->image_watcher->request_lock(
boost::bind(&TestImageWatcher::handle_restart_aio, this, ictx, _1),
- create_aio_completion(*ictx)));
+ create_aio_completion(*ictx));
}
ASSERT_TRUE(wait_for_notifies(*ictx));
{
RWLock::WLocker l(ictx->owner_lock);
- ASSERT_EQ(0, ictx->image_watcher->request_lock(
+ ictx->image_watcher->request_lock(
boost::bind(&TestImageWatcher::handle_restart_aio, this, ictx, _1),
- create_aio_completion(*ictx)));
+ create_aio_completion(*ictx));
}
ASSERT_TRUE(wait_for_aio_completions(*ictx));
}
m_expected_aio_restarts = 1;
{
RWLock::WLocker l(ictx->owner_lock);
- ASSERT_EQ(0, ictx->image_watcher->request_lock(
+ ictx->image_watcher->request_lock(
boost::bind(&TestImageWatcher::handle_restart_aio, this, ictx, _1),
- create_aio_completion(*ictx)));
+ create_aio_completion(*ictx));
}
ASSERT_TRUE(wait_for_notifies(*ictx));
DummyContext *ctx = new DummyContext();
librbd::AioCompletion *c =
librbd::aio_create_completion_internal(ctx, librbd::rbd_ctx_cb);
- ASSERT_EQ(0, aio_write(ictx, 0, buffer.size(), buffer.c_str(), c, 0));
+ c->get();
+ aio_write(ictx, 0, buffer.size(), buffer.c_str(), c, 0);
bool is_owner;
ASSERT_EQ(0, librbd::is_exclusive_lock_owner(ictx, &is_owner));
ASSERT_FALSE(is_owner);
ASSERT_FALSE(c->is_complete());
+ c->put();
}
TEST_F(TestInternal, AioDiscardRequestsLock) {
DummyContext *ctx = new DummyContext();
librbd::AioCompletion *c =
librbd::aio_create_completion_internal(ctx, librbd::rbd_ctx_cb);
- ASSERT_EQ(0, aio_discard(ictx, 0, 256, c));
+ c->get();
+ aio_discard(ictx, 0, 256, c);
bool is_owner;
ASSERT_EQ(0, librbd::is_exclusive_lock_owner(ictx, &is_owner));
ASSERT_FALSE(is_owner);
ASSERT_FALSE(c->is_complete());
+ c->put();
}
TEST_F(TestInternal, CancelAsyncResize) {
ASSERT_EQ(10, rbd_write(image, info.size - 10, 100, test_data));
rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
- ASSERT_EQ(-EINVAL, rbd_aio_write(image, info.size, 1, test_data, comp));
- ASSERT_EQ(-EINVAL, rbd_aio_read(image, info.size, 1, test_data, comp));
+ ASSERT_EQ(0, rbd_aio_write(image, info.size, 1, test_data, comp));
+ ASSERT_EQ(0, rbd_aio_wait_for_complete(comp));
+ ASSERT_EQ(-EINVAL, rbd_aio_get_return_value(comp));
+ rbd_aio_release(comp);
+
+ rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
+ ASSERT_EQ(0, rbd_aio_read(image, info.size, 1, test_data, comp));
+ ASSERT_EQ(0, rbd_aio_wait_for_complete(comp));
+ ASSERT_EQ(-EINVAL, rbd_aio_get_return_value(comp));
+ rbd_aio_release(comp);
ASSERT_PASSED(validate_object_map, image);
ASSERT_EQ(0, rbd_close(image));
LIBRADOS_OP_FLAG_FADVISE_DONTNEED));
rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
- ASSERT_EQ(-EINVAL, rbd_aio_write(image, info.size, 1, test_data, comp));
- ASSERT_EQ(-EINVAL, rbd_aio_read2(image, info.size, 1, test_data, comp,
- LIBRADOS_OP_FLAG_FADVISE_DONTNEED));
+ ASSERT_EQ(0, rbd_aio_read2(image, info.size, 1, test_data, comp,
+ LIBRADOS_OP_FLAG_FADVISE_DONTNEED));
+ ASSERT_EQ(0, rbd_aio_wait_for_complete(comp));
+ ASSERT_EQ(-EINVAL, rbd_aio_get_return_value(comp));
+ rbd_aio_release(comp);
ASSERT_PASSED(validate_object_map, image);
ASSERT_EQ(0, rbd_close(image));
rados_ioctx_destroy(ioctx);
-
}
TEST_F(TestLibRBD, TestEmptyDiscard)