]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: fix crash when opening nonexistent snapshot 22943/head
authorMykola Golub <mgolub@suse.com>
Fri, 22 Jun 2018 17:50:51 +0000 (20:50 +0300)
committerPrashant D <pdhange@redhat.com>
Mon, 9 Jul 2018 01:19:16 +0000 (21:19 -0400)
Fixes: http://tracker.ceph.com/issues/24637
Signed-off-by: Mykola Golub <mgolub@suse.com>
(cherry picked from commit 70936c3bb5c281eed1c0bb5e26337efdedfa1e06)

src/librbd/image/OpenRequest.cc
src/test/librbd/test_internal.cc

index 26e909f89242517ece6f76f1b8bc9dd007a42346..547e59d81c337ade0b788b41fdff1611f2f2f9c5 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);