From 1521f822bc35236016b823d910e984ccbea0c6fb Mon Sep 17 00:00:00 2001 From: Or Ozeri Date: Thu, 24 Dec 2020 11:39:09 +0200 Subject: [PATCH] librbd: nit fixes This commit includes very small miscellaneous changes to librbd Signed-off-by: Or Ozeri --- src/librbd/crypto/CryptoObjectDispatch.cc | 9 ++++++--- src/librbd/io/ObjectRequest.cc | 3 +++ .../crypto/test_mock_CryptoObjectDispatch.cc | 20 +++++++++---------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/librbd/crypto/CryptoObjectDispatch.cc b/src/librbd/crypto/CryptoObjectDispatch.cc index d61c73afbdc82..5f6df63d88a0c 100644 --- a/src/librbd/crypto/CryptoObjectDispatch.cc +++ b/src/librbd/crypto/CryptoObjectDispatch.cc @@ -70,12 +70,13 @@ struct C_AlignedObjectReadRequest : public Context { } void finish(int r) override { + ldout(image_ctx->cct, 20) << "aligned read r=" << r << dendl; on_finish->complete(r); } void handle_read(int r) { auto cct = image_ctx->cct; - ldout(cct, 20) << "r=" << r << dendl; + ldout(cct, 20) << "aligned read r=" << r << dendl; if (r == 0) { for (auto& extent: *extents) { auto crypto_ret = crypto->decrypt_aligned_extent( @@ -171,7 +172,7 @@ struct C_UnalignedObjectReadRequest : public Context { } void finish(int r) override { - ldout(cct, 20) << "r=" << r << dendl; + ldout(cct, 20) << "unaligned read r=" << r << dendl; if (r >= 0) { remove_alignment_data(); @@ -342,7 +343,7 @@ struct C_UnalignedObjectWriteRequest : public Context { } void handle_read(int r) { - ldout(image_ctx->cct, 20) << "r=" << r << dendl; + ldout(image_ctx->cct, 20) << "unaligned write r=" << r << dendl; if (r == -ENOENT) { auto ctx = create_context_callback< @@ -397,6 +398,7 @@ struct C_UnalignedObjectWriteRequest : public Context { } void handle_write(int r) { + ldout(image_ctx->cct, 20) << "r=" << r << dendl; bool exclusive = write_flags & io::OBJECT_WRITE_FLAG_CREATE_EXCLUSIVE; bool restart = false; if (r == -ERANGE && !assert_version.has_value()) { @@ -413,6 +415,7 @@ struct C_UnalignedObjectWriteRequest : public Context { } void finish(int r) override { + ldout(image_ctx->cct, 20) << "unaligned write r=" << r << dendl; on_finish->complete(r); } }; diff --git a/src/librbd/io/ObjectRequest.cc b/src/librbd/io/ObjectRequest.cc index 00fea70d60934..ed420a5692502 100644 --- a/src/librbd/io/ObjectRequest.cc +++ b/src/librbd/io/ObjectRequest.cc @@ -258,6 +258,9 @@ template void ObjectReadRequest::handle_read_object(int r) { I *image_ctx = this->m_ictx; ldout(image_ctx->cct, 20) << "r=" << r << dendl; + if (m_version != nullptr) { + ldout(image_ctx->cct, 20) << "version=" << *m_version << dendl; + } if (r == -ENOENT) { read_parent(); diff --git a/src/test/librbd/crypto/test_mock_CryptoObjectDispatch.cc b/src/test/librbd/crypto/test_mock_CryptoObjectDispatch.cc index f3b9aef834053..2f6972217fdf0 100644 --- a/src/test/librbd/crypto/test_mock_CryptoObjectDispatch.cc +++ b/src/test/librbd/crypto/test_mock_CryptoObjectDispatch.cc @@ -387,7 +387,7 @@ TEST_F(TestMockCryptoCryptoObjectDispatch, UnalignedRead) { ASSERT_EQ(on_finish, &finished_cond); ASSERT_EQ(ETIMEDOUT, dispatched_cond.wait_for(0)); - dispatcher_ctx->complete(0); + dispatcher_ctx->complete(4096*8); ASSERT_EQ(3 + 4096 * 5 - 2, dispatched_cond.wait()); ASSERT_TRUE(extents[0].bl.to_str() == std::string("1")); ASSERT_TRUE(extents[1].bl.to_str() == std::string("2")); @@ -431,7 +431,7 @@ TEST_F(TestMockCryptoCryptoObjectDispatch, UnalignedWrite) { auto expected_data = std::string("2") + std::string(8192, '1') + std::string(4095, '3'); expect_object_write(0, expected_data, 0, std::make_optional(version)); - dispatcher_ctx->complete(0); // complete read + dispatcher_ctx->complete(8192); // complete read ASSERT_EQ(ETIMEDOUT, dispatched_cond.wait_for(0)); dispatcher_ctx->complete(0); // complete write ASSERT_EQ(0, dispatched_cond.wait()); @@ -492,7 +492,7 @@ TEST_F(TestMockCryptoCryptoObjectDispatch, UnalignedWriteFailCreate) { auto expected_data2 = std::string("2") + std::string(8192, '1') + std::string(4095, '3'); expect_object_write(0, expected_data2, 0, std::make_optional(version)); - dispatcher_ctx->complete(0); // complete read + dispatcher_ctx->complete(8192); // complete read ASSERT_EQ(ETIMEDOUT, dispatched_cond.wait_for(0)); dispatcher_ctx->complete(0); // complete write ASSERT_EQ(0, dispatched_cond.wait()); @@ -537,7 +537,7 @@ TEST_F(TestMockCryptoCryptoObjectDispatch, UnalignedWriteCopyup) { auto expected_data = std::string("2") + std::string(8192, '1') + std::string(4095, '3'); expect_object_write(0, expected_data, 0, std::make_optional(version)); - dispatcher_ctx->complete(0); // complete second read + dispatcher_ctx->complete(8192); // complete second read ASSERT_EQ(ETIMEDOUT, dispatched_cond.wait_for(0)); dispatcher_ctx->complete(0); // complete write ASSERT_EQ(0, dispatched_cond.wait()); @@ -561,7 +561,7 @@ TEST_F(TestMockCryptoCryptoObjectDispatch, UnalignedWriteFailVersionCheck) { auto expected_data = std::string("2") + std::string(8192, '1') + std::string(4095, '3'); expect_object_write(0, expected_data, 0, std::make_optional(version)); - dispatcher_ctx->complete(0); // complete read + dispatcher_ctx->complete(8192); // complete read ASSERT_EQ(ETIMEDOUT, dispatched_cond.wait_for(0)); version = 1235; @@ -572,7 +572,7 @@ TEST_F(TestMockCryptoCryptoObjectDispatch, UnalignedWriteFailVersionCheck) { ASSERT_EQ(ETIMEDOUT, dispatched_cond.wait_for(0)); expect_object_write(0, expected_data, 0, std::make_optional(version)); - dispatcher_ctx->complete(0); // complete read + dispatcher_ctx->complete(8192); // complete read ASSERT_EQ(ETIMEDOUT, dispatched_cond.wait_for(0)); dispatcher_ctx->complete(0); // complete write ASSERT_EQ(0, dispatched_cond.wait()); @@ -594,7 +594,7 @@ TEST_F(TestMockCryptoCryptoObjectDispatch, UnalignedWriteWithAssertVersion) { ASSERT_EQ(dispatch_result, io::DISPATCH_RESULT_COMPLETE); ASSERT_EQ(on_finish, &finished_cond); - dispatcher_ctx->complete(0); // complete read + dispatcher_ctx->complete(8192); // complete read ASSERT_EQ(-ERANGE, dispatched_cond.wait()); } @@ -612,7 +612,7 @@ TEST_F(TestMockCryptoCryptoObjectDispatch, UnalignedWriteWithExclusiveCreate) { ASSERT_EQ(dispatch_result, io::DISPATCH_RESULT_COMPLETE); ASSERT_EQ(on_finish, &finished_cond); - dispatcher_ctx->complete(0); // complete read + dispatcher_ctx->complete(8192); // complete read ASSERT_EQ(-EEXIST, dispatched_cond.wait()); } @@ -638,7 +638,7 @@ TEST_F(TestMockCryptoCryptoObjectDispatch, CompareAndWrite) { auto expected_data = std::string("2") + std::string(8192, '1') + std::string(4095, '3'); expect_object_write(0, expected_data, 0, std::make_optional(version)); - dispatcher_ctx->complete(0); // complete read + dispatcher_ctx->complete(4096*4); // complete read ASSERT_EQ(ETIMEDOUT, dispatched_cond.wait_for(0)); dispatcher_ctx->complete(0); // complete write ASSERT_EQ(0, dispatched_cond.wait()); @@ -664,7 +664,7 @@ TEST_F(TestMockCryptoCryptoObjectDispatch, CompareAndWriteFail) { ASSERT_EQ(dispatch_result, io::DISPATCH_RESULT_COMPLETE); ASSERT_EQ(on_finish, &finished_cond); - dispatcher_ctx->complete(0); // complete read + dispatcher_ctx->complete(4096*4); // complete read ASSERT_EQ(-EILSEQ, dispatched_cond.wait()); ASSERT_EQ(mismatch_offset, 4094); } -- 2.39.5