summaryrefslogtreecommitdiffstats
path: root/src/test/librbd/image
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2022-09-04 12:40:36 +0200
committerIlya Dryomov <idryomov@gmail.com>2022-09-05 23:02:39 +0200
commit8570194b133462db6b7d4ab108383db0967b1cb9 (patch)
treed7309f0151cf57e0843829e9b921867dfb71cfd1 /src/test/librbd/image
parentlibrbd: fix a bunch of issues with restarting RefreshRequest (diff)
downloadceph-8570194b133462db6b7d4ab108383db0967b1cb9.tar.xz
ceph-8570194b133462db6b7d4ab108383db0967b1cb9.zip
librbd: limit the number of ENOENT retries in RefreshRequest
If the image header is corrupt, ENOENT error may be persistent. Avoid an infinite loop in that case. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'src/test/librbd/image')
-rw-r--r--src/test/librbd/image/test_mock_RefreshRequest.cc33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/test/librbd/image/test_mock_RefreshRequest.cc b/src/test/librbd/image/test_mock_RefreshRequest.cc
index 96b8fe30673..261604c4337 100644
--- a/src/test/librbd/image/test_mock_RefreshRequest.cc
+++ b/src/test/librbd/image/test_mock_RefreshRequest.cc
@@ -722,7 +722,6 @@ TEST_F(TestMockImageRefreshRequest, SuccessLegacySnapshotNoTimestampV2) {
ASSERT_EQ(0, ctx.wait());
}
-
TEST_F(TestMockImageRefreshRequest, SuccessSetSnapshotV2) {
REQUIRE_FORMAT_V2();
@@ -765,6 +764,38 @@ TEST_F(TestMockImageRefreshRequest, SuccessSetSnapshotV2) {
ASSERT_EQ(0, ctx.wait());
}
+TEST_F(TestMockImageRefreshRequest, SnapshotV2EnoentRetriesLimit) {
+ REQUIRE_FORMAT_V2();
+
+ librbd::ImageCtx *ictx;
+ ASSERT_EQ(0, open_image(m_image_name, &ictx));
+ ASSERT_EQ(0, snap_create(*ictx, "snap"));
+
+ MockRefreshImageCtx mock_image_ctx(*ictx);
+ MockGetMetadataRequest mock_get_metadata_request;
+ expect_op_work_queue(mock_image_ctx);
+ expect_test_features(mock_image_ctx);
+
+ InSequence seq;
+ for (int i = 0; i < RefreshRequest<>::MAX_ENOENT_RETRIES + 1; ++i) {
+ expect_get_mutable_metadata(mock_image_ctx, ictx->features, 0);
+ expect_get_parent(mock_image_ctx, 0);
+ expect_get_metadata(mock_image_ctx, mock_get_metadata_request,
+ mock_image_ctx.header_oid, {}, 0);
+ expect_get_metadata(mock_image_ctx, mock_get_metadata_request, RBD_INFO, {},
+ 0);
+ expect_apply_metadata(mock_image_ctx, 0);
+ expect_get_group(mock_image_ctx, 0);
+ expect_get_snapshots(mock_image_ctx, false, -ENOENT);
+ }
+
+ C_SaferCond ctx;
+ auto req = new MockRefreshRequest(mock_image_ctx, false, false, &ctx);
+ req->send();
+
+ ASSERT_EQ(-ENOENT, ctx.wait());
+}
+
TEST_F(TestMockImageRefreshRequest, SuccessChild) {
REQUIRE_FEATURE(RBD_FEATURE_LAYERING);