]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include/librbd: Add metadata interface to librbd
authorHaomai Wang <haomaiwang@gmail.com>
Mon, 9 Mar 2015 02:55:54 +0000 (10:55 +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/include/rbd/librbd.h
src/include/rbd/librbd.hpp

index 625d472b537128cbd22c6e625d3d24624a5e40e7..016fd0cc5c392173c239d5e178db82e82ae2aae0 100644 (file)
@@ -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
index 569fc77db94ca8509f5e88288f40cc52f1fb95ac..136e20d08cacd8ab86e8947bdf3de7c790366cfc 100644 (file)
@@ -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<std::string, std::string> *pairs);
+
 private:
   friend class RBD;