From: Haomai Wang Date: Mon, 9 Mar 2015 02:55:54 +0000 (+0800) Subject: include/librbd: Add metadata interface to librbd X-Git-Tag: v9.0.0~153^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=47d9cecb4bbd3f04888dc98fc48a46658ffe4a07;p=ceph.git include/librbd: Add metadata interface to librbd Signed-off-by: Haomai Wang --- diff --git a/src/include/rbd/librbd.h b/src/include/rbd/librbd.h index 625d472b5371..016fd0cc5c39 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 569fc77db94c..136e20d08cac 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;