]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: fix error path cleanup for opening an image
authorJosh Durgin <josh.durgin@inktank.com>
Mon, 11 Aug 2014 23:41:26 +0000 (16:41 -0700)
committerSage Weil <sage@redhat.com>
Tue, 12 Aug 2014 21:57:59 +0000 (14:57 -0700)
If the image doesn't exist and caching is enabled, the ObjectCacher
was not being shutdown, and the ImageCtx was leaked. The IoCtx could
later be closed while the ObjectCacher was still running, resulting in
a segfault. Simply use the usual cleanup path in open_image(), which
works fine here.

Fixes: #8912
Backport: dumpling, firefly
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
(cherry picked from commit 3dfa72d5b9a1f54934dc8289592556d30430959d)

src/librbd/internal.cc
src/test/pybind/test_rbd.py

index 36cddf80616d8d5ad4761607bf78f71f46d50202..9fc1cc3671ce96d623774bcf4d15068e8cb5bc44 100644 (file)
@@ -2075,7 +2075,7 @@ reprotect_and_return_err:
                         << ictx->snap_name << "'" << dendl;
     int r = ictx->init();
     if (r < 0)
-      return r;
+      goto err_close;
 
     if (!ictx->read_only) {
       r = ictx->register_watch();
index 11591820641d5c3e5ec4903760c8b28a43aeddde..bb53081d794518394b3b2862a8bc7435394809d2 100644 (file)
@@ -189,6 +189,16 @@ def test_open_read_only():
             RBD().remove(ioctx, IMG_NAME)
             eq(data, read)
 
+def test_open_dne():
+    for i in xrange(100):
+        assert_raises(ImageNotFound, Image, ioctx, IMG_NAME + 'dne')
+        assert_raises(ImageNotFound, Image, ioctx, IMG_NAME, 'snap')
+
+def test_open_readonly_dne():
+    for i in xrange(100):
+        assert_raises(ImageNotFound, Image, ioctx, IMG_NAME + 'dne', read_only=True)
+        assert_raises(ImageNotFound, Image, ioctx, IMG_NAME, 'snap', read_only=True)
+
 def test_remove_dne():
     assert_raises(ImageNotFound, remove_image)