]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: leaking image close if remove failed due to operations disabled
authorMykola Golub <mgolub@suse.com>
Mon, 26 Feb 2018 11:20:55 +0000 (13:20 +0200)
committerMykola Golub <mgolub@suse.com>
Tue, 27 Feb 2018 14:54:13 +0000 (16:54 +0200)
Signed-off-by: Mykola Golub <mgolub@suse.com>
src/librbd/image/RemoveRequest.cc
src/test/librbd/image/test_mock_RemoveRequest.cc

index 91243f55d5281f9450b91b6e1897a430f83adebf..738d7dce0c8cbc6de8b080fa830dc14cb431712b 100644 (file)
@@ -109,7 +109,7 @@ template<typename I>
 void RemoveRequest<I>::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;
   }
 
index a35d53c3c0934ea24c59cf9eb37581fe0dc16c37..b6ce675175de7e8b4eefc3db4ec1140b59af7803 100644 (file)
@@ -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{}}, {}, {}, {}, {}, {}}}};