]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/bluestore_types: add poison offset to pextent_t
authorSage Weil <sage@redhat.com>
Thu, 19 May 2016 15:13:36 +0000 (11:13 -0400)
committerSage Weil <sage@redhat.com>
Wed, 1 Jun 2016 15:38:52 +0000 (11:38 -0400)
This is a "magic" offset that we can use to indicate an invalid extent
(vs, say, an extent at offset 0 that might clobber real data if it were
used).

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/bluestore_types.cc
src/os/bluestore/bluestore_types.h

index d537b9e1b97a8310880e5df163f5089bc66fb977..bb425352ed410090d1cd8ab022a1a6b86c05c34c 100644 (file)
@@ -420,7 +420,10 @@ void bluestore_pextent_t::dump(Formatter *f) const
 }
 
 ostream& operator<<(ostream& out, const bluestore_pextent_t& o) {
-  return out << "0x" << std::hex << o.offset << "~0x" << o.length << std::dec;
+  if (o.is_valid())
+    return out << "0x" << std::hex << o.offset << "~0x" << o.length << std::dec;
+  else
+    return out << "!~0x" << std::hex << o.length << std::dec;
 }
 
 void bluestore_pextent_t::generate_test_instances(list<bluestore_pextent_t*>& ls)
index 9b54c6b0a39ae09c7a10101f878f954e944dba76..580b5394350a56c2fdfe700e72545677f384b160 100644 (file)
@@ -102,6 +102,8 @@ ostream& operator<<(ostream& out, const bluestore_extent_t& bp);
 
 /// pextent: physical extent
 struct bluestore_pextent_t {
+  const static uint64_t INVALID_OFFSET = ~0ull;
+
   uint64_t offset, length;    ///< location on device
 
   bluestore_pextent_t() : offset(0), length(0) {}
@@ -111,6 +113,10 @@ struct bluestore_pextent_t {
     return offset + length;
   }
 
+  bool is_valid() const {
+    return offset != INVALID_OFFSET;
+  }
+
   void encode(bufferlist& bl) const {
     ::encode(offset, bl);
     ::encode(length, bl);