]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: move object map snapshot handling to ObjectMap class
authorJason Dillaman <dillaman@redhat.com>
Wed, 25 Mar 2015 16:05:41 +0000 (12:05 -0400)
committerJason Dillaman <dillaman@redhat.com>
Mon, 13 Apr 2015 19:24:14 +0000 (15:24 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/ObjectMap.cc
src/librbd/ObjectMap.h
src/librbd/internal.cc

index e75e2b2e9563e5c6472d4ae1f396c0da89f63673..f4d520f7003d71c3d2d7b10fac58c6697a0a614c 100644 (file)
@@ -278,7 +278,7 @@ void ObjectMap::rollback(uint64_t snap_id) {
   }
 }
 
-void ObjectMap::snapshot(uint64_t snap_id) {
+void ObjectMap::snapshot_add(uint64_t snap_id) {
   assert(m_image_ctx.snap_lock.is_wlocked());
   if ((m_image_ctx.features & RBD_FEATURE_OBJECT_MAP) == 0) {
     return;
@@ -310,6 +310,15 @@ void ObjectMap::snapshot(uint64_t snap_id) {
   }
 }
 
+int ObjectMap::snapshot_remove(uint64_t snap_id) {
+  std::string oid(object_map_name(m_image_ctx.id, snap_id));
+  int r = m_image_ctx.md_ctx.remove(oid);
+  if (r < 0 && r != -ENOENT) {
+    return r;
+  }
+  return 0;
+}
+
 void ObjectMap::aio_save(Context *on_finish)
 {
   assert(m_image_ctx.test_features(RBD_FEATURE_OBJECT_MAP));
index 03c260f625dbdb4cad08abdde23c7b783c9c7eb8..56b0c72f55177dc24e74b6acf4dfa61863048bdd 100644 (file)
@@ -48,7 +48,8 @@ public:
 
   void refresh(uint64_t snap_id);
   void rollback(uint64_t snap_id);
-  void snapshot(uint64_t snap_id);
+  void snapshot_add(uint64_t snap_id);
+  int snapshot_remove(uint64_t snap_id);
 
   bool enabled() const;
 
index ff5229fdceb454dca4e0abac99485abd64d536c7..af79d946586d5050d94200cd30a951b55ed6ed49 100644 (file)
@@ -708,8 +708,8 @@ int invoke_async_request(ImageCtx *ictx, const std::string& request_type,
       }
     }
 
-    r = ictx->md_ctx.remove(ObjectMap::object_map_name(ictx->id, snap_id));
-    if (r < 0 && r != -ENOENT) {
+    r = ictx->object_map.snapshot_remove(snap_id);
+    if (r < 0) {
       lderr(ictx->cct) << "snap_remove: failed to remove snapshot object map"
                       << dendl;
       return 0;
@@ -1971,7 +1971,7 @@ reprotect_and_return_err:
 
     RWLock::WLocker l(ictx->snap_lock);
     if (!ictx->old_format) {
-      ictx->object_map.snapshot(snap_id);
+      ictx->object_map.snapshot_add(snap_id);
       if (lock_owner) {
        // immediately start using the new snap context if we
        // own the exclusive lock