]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/internal: Add internal implementation for metatdata ops
authorHaomai Wang <haomaiwang@gmail.com>
Mon, 9 Mar 2015 02:57:49 +0000 (10:57 +0800)
committerHaomai Wang <haomaiwang@gmail.com>
Fri, 13 Mar 2015 14:51:34 +0000 (22:51 +0800)
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/librbd/internal.cc
src/librbd/internal.h

index 40b6be03198def0b76ced3cb374192fd934a3429..c8700fb9519c20d47a82fadb223756ad084b8950 100644 (file)
@@ -3356,6 +3356,45 @@ reprotect_and_return_err:
     return r;
   }
 
+  int metadata_set(ImageCtx *ictx, const string &key, const string &value)
+  {
+    CephContext *cct = ictx->cct;
+    ldout(cct, 20) << "metadata_set " << ictx << " key=" << key << " value=" << value << dendl;
+
+    int r = ictx_check(ictx);
+    if (r < 0) {
+      return r;
+    }
+
+    return cls_client::metadata_set(&ictx->md_ctx, ictx->header_oid, key, value);
+  }
+
+  int metadata_remove(ImageCtx *ictx, const string &key)
+  {
+    CephContext *cct = ictx->cct;
+    ldout(cct, 20) << "metadata_remove " << ictx << " key=" << key << dendl;
+
+    int r = ictx_check(ictx);
+    if (r < 0) {
+      return r;
+    }
+
+    return cls_client::metadata_remove(&ictx->md_ctx, ictx->header_oid, key);
+  }
+
+  int metadata_list(ImageCtx *ictx, map<string, string> *pairs)
+  {
+    CephContext *cct = ictx->cct;
+    ldout(cct, 20) << "metadata_list " << ictx << dendl;
+
+    int r = ictx_check(ictx);
+    if (r < 0) {
+      return r;
+    }
+
+    return cls_client::metadata_list(&ictx->md_ctx, ictx->header_oid, pairs);
+  }
+  
   int aio_discard(ImageCtx *ictx, uint64_t off, uint64_t len, AioCompletion *c)
   {
     CephContext *cct = ictx->cct;
index d164f02ff439a7100f7102947084d5f063120f9a..13a48a6964d804922190fd4dff30f3f9b2c0e7b2 100644 (file)
@@ -207,6 +207,9 @@ namespace librbd {
   int flush(ImageCtx *ictx);
   int _flush(ImageCtx *ictx);
   int invalidate_cache(ImageCtx *ictx);
+  int metadata_list(ImageCtx *ictx, map<string, string> *pairs);
+  int metadata_set(ImageCtx *ictx, const std::string &key, const std::string &value);
+  int metadata_remove(ImageCtx *ictx, const std::string &key);
 
   ssize_t handle_sparse_read(CephContext *cct,
                             ceph::bufferlist data_bl,