]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/rbd.pyx: add rebuild_object_map method
authorJason Dillaman <dillaman@redhat.com>
Wed, 13 Jan 2016 23:07:01 +0000 (18:07 -0500)
committerJason Dillaman <dillaman@redhat.com>
Wed, 13 Jan 2016 23:07:01 +0000 (18:07 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/pybind/rbd.pyx

index 931899747f3c2e09e3dcb1354690b35a5102cb72..6be015c75008b53cc7fe87ca99b246e1b1f43d11 100644 (file)
@@ -30,6 +30,8 @@ cdef extern from "Python.h":
     char* PyBytes_AsString(PyObject *string) except NULL
     int _PyBytes_Resize(PyObject **string, Py_ssize_t newsize) except -1
 
+ctypedef int (*librbd_progress_fn_t)(uint64_t offset, uint64_t total, void* ptr)
+
 cdef extern from "rbd/librbd.h" nogil:
     enum:
         _RBD_FEATURE_LAYERING "RBD_FEATURE_LAYERING"
@@ -76,7 +78,6 @@ cdef extern from "rbd/librbd.h" nogil:
         uint64_t size
         char *name
 
-
     void rbd_version(int *major, int *minor, int *extra)
 
     void rbd_image_options_create(rbd_image_options_t* opts)
@@ -146,6 +147,8 @@ cdef extern from "rbd/librbd.h" nogil:
                               int *is_protected)
     int rbd_snap_set(rbd_image_t image, const char *snapname)
     int rbd_flatten(rbd_image_t image)
+    int rbd_rebuild_object_map(rbd_image_t image, librbd_progress_fn_t cb,
+                               void *cbdata);
     ssize_t rbd_list_children(rbd_image_t image, char *pools, size_t *pools_len,
                               char *images, size_t *images_len)
     ssize_t rbd_list_lockers(rbd_image_t image, int *exclusive,
@@ -296,6 +299,9 @@ cdef make_ex(ret, msg):
 cdef rados_ioctx_t convert_ioctx(ioctx) except? NULL:
     return <rados_ioctx_t><uintptr_t>ioctx.io.value
 
+cdef int no_op_progress_callback(uint64_t offset, uint64_t total, void* ptr):
+    return 0
+
 def cstr(val, name, encoding="utf-8", opt=False):
     """
     Create a byte string from a Python string
@@ -1236,6 +1242,16 @@ written." % (self.name, ret, length))
         if ret < 0:
             raise make_ex(ret, "error flattening %s" % self.name)
 
+    def rebuild_object_map(self):
+        """
+        Rebuilds the object map for the image HEAD or currently set snapshot
+        """
+        cdef librbd_progress_fn_t prog_cb = &no_op_progress_callback
+        with nogil:
+            ret = rbd_rebuild_object_map(self.image, prog_cb, NULL)
+        if ret < 0:
+            raise make_ex(ret, "error rebuilding object map %s" % self.name)
+
     def list_children(self):
         """
         List children of the currently set snapshot (set via set_snap()).