summaryrefslogtreecommitdiffstats
path: root/src/test/librbd/crypto
diff options
context:
space:
mode:
authorOr Ozeri <oro@il.ibm.com>2020-11-19 07:26:51 +0100
committerOr Ozeri <oro@il.ibm.com>2020-11-19 09:03:54 +0100
commitbb987178c1ed4833f4540d819d7203ded18966cf (patch)
treed3eddb432e58c4e3f31df8b20b23869efd4bf834 /src/test/librbd/crypto
parentMerge pull request #38001 from badone/wip-powertools-repo-name-change (diff)
downloadceph-bb987178c1ed4833f4540d819d7203ded18966cf.tar.xz
ceph-bb987178c1ed4833f4540d819d7203ded18966cf.zip
librbd: fix crypto prepare_copyup to use new remap_extents api
This commit changes the crypto prepare_copyup implementation to correctly translate object extents to image extents, via the remap_extents api. Additionally, we fix relevant unit tests that call this api to correctly expect these calls. Signed-off-by: Or Ozeri <oro@il.ibm.com>
Diffstat (limited to 'src/test/librbd/crypto')
-rw-r--r--src/test/librbd/crypto/test_mock_CryptoObjectDispatch.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/librbd/crypto/test_mock_CryptoObjectDispatch.cc b/src/test/librbd/crypto/test_mock_CryptoObjectDispatch.cc
index 104b44a1595..f3b9aef8340 100644
--- a/src/test/librbd/crypto/test_mock_CryptoObjectDispatch.cc
+++ b/src/test/librbd/crypto/test_mock_CryptoObjectDispatch.cc
@@ -101,6 +101,7 @@ namespace crypto {
using ::testing::_;
using ::testing::ElementsAre;
using ::testing::Invoke;
+using ::testing::InSequence;
using ::testing::Pair;
using ::testing::Return;
using ::testing::WithArg;
@@ -223,6 +224,12 @@ struct TestMockCryptoCryptoObjectDispatch : public TestMockFixture {
mock_image_ctx->layout.object_size));
}
+ void expect_remap_extents(uint64_t offset, uint64_t length) {
+ EXPECT_CALL(*mock_image_ctx->io_image_dispatcher, remap_extents(
+ ElementsAre(Pair(offset, length)),
+ io::IMAGE_EXTENTS_MAP_TYPE_PHYSICAL_TO_LOGICAL));
+ }
+
void expect_get_parent_overlap(uint64_t overlap) {
EXPECT_CALL(*mock_image_ctx, get_parent_overlap(_, _))
.WillOnce(WithArg<1>(Invoke([overlap](uint64_t *o) {
@@ -510,6 +517,7 @@ TEST_F(TestMockCryptoCryptoObjectDispatch, UnalignedWriteCopyup) {
expect_get_object_size();
expect_get_parent_overlap(mock_image_ctx->layout.object_size);
+ expect_remap_extents(0, mock_image_ctx->layout.object_size);
expect_prune_parent_extents(mock_image_ctx->layout.object_size);
EXPECT_CALL(mock_exclusive_lock, is_lock_owner()).WillRepeatedly(
Return(true));
@@ -698,6 +706,13 @@ TEST_F(TestMockCryptoCryptoObjectDispatch, PrepareCopyup) {
expect_get_object_size();
expect_encrypt(6);
+ InSequence seq;
+ expect_remap_extents(0, 4096);
+ expect_remap_extents(4096, 4096);
+ expect_remap_extents(8192, 4096);
+ expect_remap_extents(0, 4096);
+ expect_remap_extents(4096, 8192);
+ expect_remap_extents(16384, 4096);
ASSERT_EQ(0, mock_crypto_object_dispatch->prepare_copyup(
0, &snapshot_sparse_bufferlist));