From 47d9cecb4bbd3f04888dc98fc48a46658ffe4a07 Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Mon, 9 Mar 2015 10:55:54 +0800 Subject: [PATCH] include/librbd: Add metadata interface to librbd Signed-off-by: Haomai Wang --- src/include/rbd/librbd.h | 24 ++++++++++++++++++++++++ src/include/rbd/librbd.hpp | 7 +++++++ 2 files changed, 31 insertions(+) diff --git a/src/include/rbd/librbd.h b/src/include/rbd/librbd.h index 625d472b53712..016fd0cc5c392 100644 --- a/src/include/rbd/librbd.h +++ b/src/include/rbd/librbd.h @@ -443,6 +443,30 @@ CEPH_RBD_API int rbd_aio_flush(rbd_image_t image, rbd_completion_t c); */ CEPH_RBD_API int rbd_invalidate_cache(rbd_image_t image); +CEPH_RBD_API int rbd_metadata_set(rbd_image_t image, const char *key, const char *value); +CEPH_RBD_API int rbd_metadata_remove(rbd_image_t image, const char *key); +/** + * List all metadatas associated with this image. + * + * This iterates over all metadatas, key_len and val_len are filled in + * with the number of bytes put into the keys and values buffers. + * + * If the provided buffers are too short, the required lengths are + * still filled in, but the data is not and -ERANGE is returned. + * Otherwise, the buffers are filled with the keys and values + * of the image, with a '\0' after each. + * + * @param image which image (and implicitly snapshot) to list clones of + * @param pools buffer in which to store pool names + * @param pools_len number of bytes in pools buffer + * @param images buffer in which to store image names + * @param images_len number of bytes in images buffer + * @returns number of children on success, negative error code on failure + * @returns -ERANGE if either buffer is too short + */ +CEPH_RBD_API int rbd_metadata_list(rbd_image_t image, char *key, size_t *key_len, char *value, size_t *val_len); + + #ifdef __cplusplus } #endif diff --git a/src/include/rbd/librbd.hpp b/src/include/rbd/librbd.hpp index 569fc77db94ca..136e20d08cacd 100644 --- a/src/include/rbd/librbd.hpp +++ b/src/include/rbd/librbd.hpp @@ -241,6 +241,13 @@ public: */ int invalidate_cache(); + int metadata_set(const std::string &key, const std::string &value); + int metadata_remove(const std::string &key); + /** + * Returns a pair of key/value for this image + */ + int metadata_list(std::map *pairs); + private: friend class RBD; -- 2.39.5