]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: fix crash when opening nonexistent snapshot 22676/head
authorMykola Golub <mgolub@suse.com>
Fri, 22 Jun 2018 17:50:51 +0000 (20:50 +0300)
committerMykola Golub <mgolub@suse.com>
Fri, 22 Jun 2018 18:01:43 +0000 (21:01 +0300)
Fixes: http://tracker.ceph.com/issues/24637
Signed-off-by: Mykola Golub <mgolub@suse.com>
src/librbd/image/OpenRequest.cc
src/test/librbd/test_internal.cc

index 33642f12c1d47b0a1bc32cb07c4fe42fb6537ce9..a3baa89a3fc97a0c8ea721d45a3e13603fe9cbf7 100644 (file)
@@ -515,8 +515,9 @@ Context *OpenRequest<I>::send_set_snap(int *result) {
                                        m_image_ctx->snap_name);
   }
   if (snap_id == CEPH_NOSNAP) {
-    *result = -ENOENT;
-    return m_on_finish;
+    lderr(cct) << "failed to find snapshot " << m_image_ctx->snap_name << dendl;
+    send_close_image(-ENOENT);
+    return nullptr;
   }
 
   using klass = OpenRequest<I>;
index 2952abfeec197d81e0ec2b53076f230e20bba982..a3f2630c9b1f0027b745327ebdb2ca6bd556be8d 100644 (file)
@@ -142,6 +142,14 @@ TEST_F(TestInternal, OpenByID) {
    close_image(ictx);
 }
 
+TEST_F(TestInternal, OpenSnapDNE) {
+   librbd::ImageCtx *ictx;
+   ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+   ictx = new librbd::ImageCtx(m_image_name, "", "unknown_snap", m_ioctx, true);
+   ASSERT_EQ(-ENOENT, ictx->state->open(true));
+}
+
 TEST_F(TestInternal, IsExclusiveLockOwner) {
   REQUIRE_FEATURE(RBD_FEATURE_EXCLUSIVE_LOCK);