From: Haomai Wang Date: Mon, 9 Mar 2015 02:57:49 +0000 (+0800) Subject: librbd/internal: Add internal implementation for metatdata ops X-Git-Tag: v9.0.0~153^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1b2904e206a15af25ae044907f1dab82b39fb795;p=ceph.git librbd/internal: Add internal implementation for metatdata ops Signed-off-by: Haomai Wang --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 40b6be03198..c8700fb9519 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -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 *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; diff --git a/src/librbd/internal.h b/src/librbd/internal.h index d164f02ff43..13a48a6964d 100644 --- a/src/librbd/internal.h +++ b/src/librbd/internal.h @@ -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 *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,