From: Mykola Golub Date: Mon, 26 Feb 2018 11:20:55 +0000 (+0200) Subject: librbd: leaking image close if remove failed due to operations disabled X-Git-Tag: v13.0.2~120^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=82b8f7b86a6232a0d1f28fd98d9d90ea198b1dc9;p=ceph.git librbd: leaking image close if remove failed due to operations disabled Signed-off-by: Mykola Golub --- diff --git a/src/librbd/image/RemoveRequest.cc b/src/librbd/image/RemoveRequest.cc index 91243f55d5281..738d7dce0c8cb 100644 --- a/src/librbd/image/RemoveRequest.cc +++ b/src/librbd/image/RemoveRequest.cc @@ -109,7 +109,7 @@ template void RemoveRequest::check_exclusive_lock() { if (m_image_ctx->operations_disabled) { lderr(m_cct) << "image operations disabled due to unsupported op features" << dendl; - finish(-EROFS); + send_close_image(-EROFS); return; } diff --git a/src/test/librbd/image/test_mock_RemoveRequest.cc b/src/test/librbd/image/test_mock_RemoveRequest.cc index a35d53c3c0934..b6ce675175de7 100644 --- a/src/test/librbd/image/test_mock_RemoveRequest.cc +++ b/src/test/librbd/image/test_mock_RemoveRequest.cc @@ -480,6 +480,23 @@ TEST_F(TestMockImageRemoveRequest, NotExistsV2) { ASSERT_EQ(-ENOENT, ctx.wait()); } +TEST_F(TestMockImageRemoveRequest, OperationsDisabled) { + m_mock_imctx->operations_disabled = true; + + InSequence seq; + expect_state_open(*m_mock_imctx, 0); + expect_state_close(*m_mock_imctx); + + C_SaferCond ctx; + librbd::NoOpProgressContext no_op; + ContextWQ op_work_queue; + MockRemoveRequest *req = MockRemoveRequest::create( + m_ioctx, m_image_name, "", true, false, no_op, &op_work_queue, &ctx); + req->send(); + + ASSERT_EQ(-EROFS, ctx.wait()); +} + TEST_F(TestMockImageRemoveRequest, Snapshots) { m_mock_imctx->snap_info = { {123, {"snap1", {cls::rbd::UserSnapshotNamespace{}}, {}, {}, {}, {}, {}}}};