]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/include/rbd/librbd.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / include / rbd / librbd.hpp
index 7220514e05cf0e521ae1273138a11fd0545afe52..4aaffd116f6f3f63d96c5a273bb92681d006a1c6 100644 (file)
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -15,7 +15,6 @@
 #ifndef __LIBRBD_HPP
 #define __LIBRBD_HPP
 
-#include <stdbool.h>
 #include <string>
 #include <list>
 #include <map>
@@ -30,16 +29,45 @@ namespace librbd {
 
   class Image;
   class ImageOptions;
+  class PoolStats;
   typedef void *image_ctx_t;
   typedef void *completion_t;
   typedef void (*callback_t)(completion_t cb, void *arg);
 
+  typedef struct {
+    std::string id;
+    std::string name;
+  } image_spec_t;
+
+  typedef struct {
+    int64_t pool_id;
+    std::string pool_name;
+    std::string pool_namespace;
+    std::string image_id;
+    std::string image_name;
+    bool trash;
+  } linked_image_spec_t;
+
+  typedef rbd_snap_namespace_type_t snap_namespace_type_t;
+
+  typedef struct {
+    uint64_t id;
+    snap_namespace_type_t namespace_type;
+    std::string name;
+  } snap_spec_t;
+
   typedef struct {
     uint64_t id;
     uint64_t size;
     std::string name;
   } snap_info_t;
 
+  typedef struct {
+    int64_t group_pool;
+    std::string group_name;
+    std::string group_snap_name;
+  } snap_group_namespace_t;
+
   typedef struct {
     std::string client;
     std::string cookie;
@@ -71,6 +99,26 @@ namespace librbd {
     bool up;
   } mirror_image_status_t;
 
+  typedef rbd_group_image_state_t group_image_state_t;
+
+  typedef struct {
+    std::string name;
+    int64_t pool;
+    group_image_state_t state;
+  } group_image_info_t;
+
+  typedef struct {
+    std::string name;
+    int64_t pool;
+  } group_info_t;
+
+  typedef rbd_group_snap_state_t group_snap_state_t;
+
+  typedef struct {
+    std::string name;
+    group_snap_state_t state;
+  } group_snap_info_t;
+
   typedef rbd_image_info_t image_info_t;
 
   class CEPH_RBD_API ProgressContext
@@ -88,6 +136,42 @@ namespace librbd {
     time_t deferment_end_time;
   } trash_image_info_t;
 
+  typedef struct {
+    std::string pool_name;
+    std::string image_name;
+    std::string image_id;
+    bool trash;
+  } child_info_t;
+
+  typedef struct {
+    std::string addr;
+    int64_t id;
+    uint64_t cookie;
+  } image_watcher_t;
+
+  typedef rbd_image_migration_state_t image_migration_state_t;
+
+  typedef struct {
+    int64_t source_pool_id;
+    std::string source_pool_namespace;
+    std::string source_image_name;
+    std::string source_image_id;
+    int64_t dest_pool_id;
+    std::string dest_pool_namespace;
+    std::string dest_image_name;
+    std::string dest_image_id;
+    image_migration_state_t state;
+    std::string state_description;
+  } image_migration_status_t;
+
+  typedef rbd_config_source_t config_source_t;
+
+  typedef struct {
+    std::string name;
+    std::string value;
+    config_source_t source;
+  } config_option_t;
+
 class CEPH_RBD_API RBD
 {
 public:
@@ -126,7 +210,11 @@ public:
                         const char *snapname, RBD::AioCompletion *c);
   int aio_open_by_id_read_only(IoCtx& io_ctx, Image& image, const char *id,
                                const char *snapname, RBD::AioCompletion *c);
-  int list(IoCtx& io_ctx, std::vector<std::string>& names);
+
+  int list(IoCtx& io_ctx, std::vector<std::string>& names)
+    __attribute__((deprecated));
+  int list2(IoCtx& io_ctx, std::vector<image_spec_t>* images);
+
   int create(IoCtx& io_ctx, const char *name, uint64_t size, int *order);
   int create2(IoCtx& io_ctx, const char *name, uint64_t size,
              uint64_t features, int *order);
@@ -150,11 +238,30 @@ public:
   int trash_move(IoCtx &io_ctx, const char *name, uint64_t delay);
   int trash_get(IoCtx &io_ctx, const char *id, trash_image_info_t *info);
   int trash_list(IoCtx &io_ctx, std::vector<trash_image_info_t> &entries);
+  int trash_purge(IoCtx &io_ctx, time_t expire_ts, float threshold);
+  int trash_purge_with_progress(IoCtx &io_ctx, time_t expire_ts, float threshold,
+                                ProgressContext &pctx);
   int trash_remove(IoCtx &io_ctx, const char *image_id, bool force);
   int trash_remove_with_progress(IoCtx &io_ctx, const char *image_id,
                                  bool force, ProgressContext &pctx);
   int trash_restore(IoCtx &io_ctx, const char *id, const char *name);
 
+  // Migration
+  int migration_prepare(IoCtx& io_ctx, const char *image_name,
+                        IoCtx& dest_io_ctx, const char *dest_image_name,
+                        ImageOptions& opts);
+  int migration_execute(IoCtx& io_ctx, const char *image_name);
+  int migration_execute_with_progress(IoCtx& io_ctx, const char *image_name,
+                                      ProgressContext &prog_ctx);
+  int migration_abort(IoCtx& io_ctx, const char *image_name);
+  int migration_abort_with_progress(IoCtx& io_ctx, const char *image_name,
+                                    ProgressContext &prog_ctx);
+  int migration_commit(IoCtx& io_ctx, const char *image_name);
+  int migration_commit_with_progress(IoCtx& io_ctx, const char *image_name,
+                                     ProgressContext &prog_ctx);
+  int migration_status(IoCtx& io_ctx, const char *image_name,
+                       image_migration_status_t *status, size_t status_size);
+
   // RBD pool mirroring support functions
   int mirror_mode_get(IoCtx& io_ctx, rbd_mirror_mode_t *mirror_mode);
   int mirror_mode_set(IoCtx& io_ctx, rbd_mirror_mode_t mirror_mode);
@@ -167,10 +274,69 @@ public:
                              const std::string &client_name);
   int mirror_peer_set_cluster(IoCtx& io_ctx, const std::string &uuid,
                               const std::string &cluster_name);
+  int mirror_peer_get_attributes(
+      IoCtx& io_ctx, const std::string &uuid,
+      std::map<std::string, std::string> *key_vals);
+  int mirror_peer_set_attributes(
+      IoCtx& io_ctx, const std::string &uuid,
+      const std::map<std::string, std::string>& key_vals);
+
   int mirror_image_status_list(IoCtx& io_ctx, const std::string &start_id,
       size_t max, std::map<std::string, mirror_image_status_t> *images);
   int mirror_image_status_summary(IoCtx& io_ctx,
       std::map<mirror_image_status_state_t, int> *states);
+  int mirror_image_instance_id_list(IoCtx& io_ctx, const std::string &start_id,
+      size_t max, std::map<std::string, std::string> *sevice_ids);
+
+  // RBD groups support functions
+  int group_create(IoCtx& io_ctx, const char *group_name);
+  int group_remove(IoCtx& io_ctx, const char *group_name);
+  int group_list(IoCtx& io_ctx, std::vector<std::string> *names);
+  int group_rename(IoCtx& io_ctx, const char *src_group_name,
+                   const char *dest_group_name);
+
+  int group_image_add(IoCtx& io_ctx, const char *group_name,
+                     IoCtx& image_io_ctx, const char *image_name);
+  int group_image_remove(IoCtx& io_ctx, const char *group_name,
+                        IoCtx& image_io_ctx, const char *image_name);
+  int group_image_remove_by_id(IoCtx& io_ctx, const char *group_name,
+                               IoCtx& image_io_ctx, const char *image_id);
+  int group_image_list(IoCtx& io_ctx, const char *group_name,
+                       std::vector<group_image_info_t> *images,
+                       size_t group_image_info_size);
+
+  int group_snap_create(IoCtx& io_ctx, const char *group_name,
+                       const char *snap_name);
+  int group_snap_remove(IoCtx& io_ctx, const char *group_name,
+                       const char *snap_name);
+  int group_snap_rename(IoCtx& group_ioctx, const char *group_name,
+                        const char *old_snap_name, const char *new_snap_name);
+  int group_snap_list(IoCtx& group_ioctx, const char *group_name,
+                      std::vector<group_snap_info_t> *snaps,
+                      size_t group_snap_info_size);
+  int group_snap_rollback(IoCtx& io_ctx, const char *group_name,
+                          const char *snap_name);
+  int group_snap_rollback_with_progress(IoCtx& io_ctx, const char *group_name,
+                                        const char *snap_name,
+                                        ProgressContext& pctx);
+
+  int namespace_create(IoCtx& ioctx, const char *namespace_name);
+  int namespace_remove(IoCtx& ioctx, const char *namespace_name);
+  int namespace_list(IoCtx& io_ctx, std::vector<std::string>* namespace_names);
+  int namespace_exists(IoCtx& io_ctx, const char *namespace_name, bool *exists);
+
+  int pool_init(IoCtx& io_ctx, bool force);
+  int pool_stats_get(IoCtx& io_ctx, PoolStats *pool_stats);
+
+  int pool_metadata_get(IoCtx &io_ctx, const std::string &key,
+                        std::string *value);
+  int pool_metadata_set(IoCtx &io_ctx, const std::string &key,
+                        const std::string &value);
+  int pool_metadata_remove(IoCtx &io_ctx, const std::string &key);
+  int pool_metadata_list(IoCtx &io_ctx, const std::string &start, uint64_t max,
+                         std::map<std::string, ceph::bufferlist> *pairs);
+
+  int config_list(IoCtx& io_ctx, std::vector<config_option_t> *options);
 
 private:
   /* We don't allow assignment or copying */
@@ -201,6 +367,22 @@ private:
   rbd_image_options_t opts;
 };
 
+class CEPH_RBD_API PoolStats {
+public:
+  PoolStats();
+  ~PoolStats();
+
+  PoolStats(const PoolStats&) = delete;
+  PoolStats& operator=(const PoolStats&) = delete;
+
+  int add(rbd_pool_stat_option_t option, uint64_t* opt_val);
+
+private:
+  friend class RBD;
+
+  rbd_pool_stats_t pool_stats;
+};
+
 class CEPH_RBD_API UpdateWatchCtx {
 public:
   virtual ~UpdateWatchCtx() {}
@@ -223,17 +405,24 @@ public:
   int resize2(uint64_t size, bool allow_shrink, ProgressContext& pctx);
   int resize_with_progress(uint64_t size, ProgressContext& pctx);
   int stat(image_info_t &info, size_t infosize);
+  int get_name(std::string *name);
   int get_id(std::string *id);
   std::string get_block_name_prefix();
   int64_t get_data_pool_id();
   int parent_info(std::string *parent_poolname, std::string *parent_name,
-                 std::string *parent_snapname);
+                 std::string *parent_snapname)
+      __attribute__((deprecated));
   int parent_info2(std::string *parent_poolname, std::string *parent_name,
-                   std::string *parent_id, std::string *parent_snapname);
+                   std::string *parent_id, std::string *parent_snapname)
+      __attribute__((deprecated));
+  int get_parent(linked_image_spec_t *parent_image, snap_spec_t *parent_snap);
+
   int old_format(uint8_t *old);
   int size(uint64_t *size);
+  int get_group(group_info_t *group_info, size_t group_info_size);
   int features(uint64_t *features);
   int update_features(uint64_t features, bool enabled);
+  int get_op_features(uint64_t *op_features);
   int overlap(uint64_t *overlap);
   int get_flags(uint64_t *flags);
   int set_image_notification(int fd, int type);
@@ -265,19 +454,38 @@ public:
                          ImageOptions& opts, ProgressContext &prog_ctx,
                          size_t sparse_size);
 
+  /* deep copy */
+  int deep_copy(IoCtx& dest_io_ctx, const char *destname, ImageOptions& opts);
+  int deep_copy_with_progress(IoCtx& dest_io_ctx, const char *destname,
+                              ImageOptions& opts, ProgressContext &prog_ctx);
+
   /* striping */
   uint64_t get_stripe_unit() const;
   uint64_t get_stripe_count() const;
 
   int get_create_timestamp(struct timespec *timestamp);
+  int get_access_timestamp(struct timespec *timestamp);
+  int get_modify_timestamp(struct timespec *timestamp);
 
   int flatten();
   int flatten_with_progress(ProgressContext &prog_ctx);
+
+  int sparsify(size_t sparse_size);
+  int sparsify_with_progress(size_t sparse_size, ProgressContext &prog_ctx);
   /**
    * Returns a pair of poolname, imagename for each clone
    * of this image at the currently set snapshot.
    */
-  int list_children(std::set<std::pair<std::string, std::string> > *children);
+  int list_children(std::set<std::pair<std::string, std::string> > *children)
+      __attribute__((deprecated));
+  /**
+  * Returns a structure of poolname, imagename, imageid and trash flag
+  * for each clone of this image at the currently set snapshot.
+  */
+  int list_children2(std::vector<librbd::child_info_t> *children)
+      __attribute__((deprecated));
+  int list_children3(std::vector<linked_image_spec_t> *images);
+  int list_descendants(std::vector<linked_image_spec_t> *images);
 
   /* advisory locking (see librbd.h for details) */
   int list_lockers(std::list<locker_t> *lockers,
@@ -295,16 +503,24 @@ public:
   int snap_create(const char *snapname);
   int snap_remove(const char *snapname);
   int snap_remove2(const char *snapname, uint32_t flags, ProgressContext& pctx);
+  int snap_remove_by_id(uint64_t snap_id);
   int snap_rollback(const char *snap_name);
   int snap_rollback_with_progress(const char *snap_name, ProgressContext& pctx);
   int snap_protect(const char *snap_name);
   int snap_unprotect(const char *snap_name);
   int snap_is_protected(const char *snap_name, bool *is_protected);
   int snap_set(const char *snap_name);
+  int snap_set_by_id(uint64_t snap_id);
   int snap_rename(const char *srcname, const char *dstname);
   int snap_get_limit(uint64_t *limit);
   int snap_set_limit(uint64_t limit);
   int snap_get_timestamp(uint64_t snap_id, struct timespec *timestamp);
+  int snap_get_namespace_type(uint64_t snap_id,
+                              snap_namespace_type_t *namespace_type);
+  int snap_get_group_namespace(uint64_t snap_id,
+                               snap_group_namespace_t *group_namespace,
+                               size_t snap_group_namespace_size);
+  int snap_get_trash_namespace(uint64_t snap_id, std::string* original_name);
 
   /* I/O */
   ssize_t read(uint64_t ofs, size_t len, ceph::bufferlist& bl);
@@ -421,6 +637,7 @@ public:
                             size_t info_size);
   int mirror_image_get_status(mirror_image_status_t *mirror_image_status,
                              size_t status_size);
+  int mirror_image_get_instance_id(std::string *instance_id);
   int aio_mirror_image_promote(bool force, RBD::AioCompletion *c);
   int aio_mirror_image_demote(RBD::AioCompletion *c);
   int aio_mirror_image_get_info(mirror_image_info_t *mirror_image_info,
@@ -431,6 +648,10 @@ public:
   int update_watch(UpdateWatchCtx *ctx, uint64_t *handle);
   int update_unwatch(uint64_t handle);
 
+  int list_watchers(std::list<image_watcher_t> &watchers);
+
+  int config_list(std::vector<config_option_t> *options);
+
 private:
   friend class RBD;