]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: add HAS_REFMAP flag to bluestore_blob_t
authorIgor Fedotov <ifedotov@mirantis.com>
Tue, 28 Jun 2016 12:05:22 +0000 (15:05 +0300)
committerIgor Fedotov <ifedotov@mirantis.com>
Mon, 18 Jul 2016 16:06:35 +0000 (19:06 +0300)
Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
src/os/bluestore/bluestore_types.cc
src/os/bluestore/bluestore_types.h

index 0c8808ae7d3ef8215cf47bcb2fcdb3de5c245537..44262f7a533e8e8c05375215138c43f070c4437b 100644 (file)
@@ -423,6 +423,11 @@ string bluestore_blob_t::get_flags_string(unsigned flags)
       s += '+';
     s += "has_unused";
   }
+  if (flags & FLAG_HAS_REFMAP) {
+    if (s.length())
+      s += '+';
+    s += "has_refmap";
+  }
 
   return s;
 }
@@ -440,7 +445,9 @@ void bluestore_blob_t::encode(bufferlist& bl) const
     small_encode_varint(csum_chunk_order, bl);
     small_encode_buf_lowz(csum_data, bl);
   }
-  ::encode(ref_map, bl);
+  if (has_refmap()) {
+    ::encode(ref_map, bl);
+  }
   if (has_unused()) {
     ::encode( unused_uint_t(unused.to_ullong()), bl);
   }
@@ -465,7 +472,9 @@ void bluestore_blob_t::decode(bufferlist::iterator& p)
     csum_type = CSUM_NONE;
     csum_chunk_order = 0;
   }
-  ::decode(ref_map, p);
+  if (has_refmap()) {
+    ::decode(ref_map, p);
+  }
   if (has_unused()) {
     unused_uint_t val;
     ::decode(val, p);
@@ -532,12 +541,21 @@ ostream& operator<<(ostream& out, const bluestore_blob_t& o)
   return out;
 }
 
+void bluestore_blob_t::get_ref(
+  uint64_t offset,
+  uint64_t length)
+{
+  assert(has_refmap());
+  ref_map.get(offset, length);
+}
+
 void bluestore_blob_t::put_ref(
   uint64_t offset,
   uint64_t length,
   uint64_t min_release_size,
   vector<bluestore_pextent_t> *r)
 {
+  assert(has_refmap());
   vector<bluestore_pextent_t> logical;
   ref_map.put(offset, length, &logical);
 
index 9c079297c44d41febe148f556a71e853f107826f..03f36d321c6900ebaa42d9e757c6e89fa8093f73 100644 (file)
@@ -155,6 +155,7 @@ struct bluestore_blob_t {
     FLAG_COMPRESSED = 2,      ///< blob is compressed
     FLAG_CSUM = 4,            ///< blob has checksums
     FLAG_HAS_UNUSED = 8,      ///< blob has unused map
+    FLAG_HAS_REFMAP  = 16,    ///< blob has non-empty reference map
   };
   static string get_flags_string(unsigned flags);
 
@@ -235,7 +236,9 @@ struct bluestore_blob_t {
   typedef std::bitset<sizeof(unused_uint_t) * 8> unused_t;
   unused_t unused;                    ///< portion that has never been written to
 
-  bluestore_blob_t(uint32_t f = 0) : flags(f) {}
+  bluestore_blob_t(uint32_t f = 0) : flags(f) {
+    set_flag(FLAG_HAS_REFMAP);
+  }
 
   void encode(bufferlist& bl) const;
   void decode(bufferlist::iterator& p);
@@ -271,6 +274,9 @@ struct bluestore_blob_t {
   bool has_unused() const {
     return has_flag(FLAG_HAS_UNUSED);
   }
+  bool has_refmap() const {
+    return has_flag(FLAG_HAS_REFMAP);
+  }
 
   /// return chunk (i.e. min readable block) size for the blob
   uint64_t get_chunk_size(uint64_t dev_block_size) {
@@ -375,8 +381,10 @@ struct bluestore_blob_t {
     }
   }
 
+  /// get logical references
+  void get_ref(uint64_t offset, uint64_t length);
   /// put logical references, and get back any released extents
-  void put_ref(uint64_t offset, uint64_t length,  uint64_t min_alloc_size,
+  void put_ref(uint64_t offset, uint64_t length, uint64_t min_alloc_size,
               vector<bluestore_pextent_t> *r);
 
   void map(uint64_t x_off, uint64_t x_len,