]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/ImageCtx: accessors
authorSage Weil <sage@inktank.com>
Wed, 3 Oct 2012 22:09:25 +0000 (15:09 -0700)
committerSage Weil <sage@inktank.com>
Mon, 15 Oct 2012 22:34:04 +0000 (15:34 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h

index 50845524e6bbd00b02f909a6d2bfa6c534eaf1b8..1b673e18ac40ffebf0ae6e49a5e4779b85091af1 100644 (file)
@@ -256,6 +256,16 @@ namespace librbd {
     return -ENOENT;
   }
 
+  uint64_t ImageCtx::get_size() const
+  {
+    return size;
+  }
+
+  uint64_t ImageCtx::get_object_size() const
+  {
+    return 1ull << order;
+  }
+
   uint64_t ImageCtx::get_stripe_unit() const
   {
     return stripe_unit;
@@ -266,6 +276,18 @@ namespace librbd {
     return stripe_count;
   }
 
+  uint64_t ImageCtx::get_stripe_period() const
+  {
+    return stripe_count * (1ull << order);
+  }
+
+  uint64_t ImageCtx::get_num_objects() const
+  {
+    uint64_t period = get_stripe_period();
+    uint64_t num_periods = (size + period - 1) / period;
+    return num_periods * stripe_count;
+  }
+
   int ImageCtx::is_snap_protected(string in_snap_name, bool *is_protected) const
   {
     assert(snap_lock.is_locked());
index 0e2f4b3780f2ef64b5b183b352e0192620b95af3..f952ef621defcf89e23e494845c576629705c440 100644 (file)
@@ -103,8 +103,14 @@ namespace librbd {
     int get_parent_spec(snapid_t snap_id, parent_spec *pspec);
     int get_snap_size(std::string in_snap_name, uint64_t *out_size) const;
     int is_snap_protected(string in_snap_name, bool *is_protected) const;
+
+    uint64_t get_size() const;
+    uint64_t get_object_size() const;
+    uint64_t get_num_objects() const;
     uint64_t get_stripe_unit() const;
     uint64_t get_stripe_count() const;
+    uint64_t get_stripe_period() const;
+
     void add_snap(std::string in_snap_name, librados::snap_t id,
                  uint64_t in_size, uint64_t features,
                  parent_info parent, uint8_t protection_status);