From 75d1083cb6da140ca9d5155eba8a3799f89b89c4 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 19 May 2016 11:13:36 -0400 Subject: [PATCH] os/bluestore/bluestore_types: add poison offset to pextent_t 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 --- src/os/bluestore/bluestore_types.cc | 5 ++++- src/os/bluestore/bluestore_types.h | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/os/bluestore/bluestore_types.cc b/src/os/bluestore/bluestore_types.cc index d537b9e1b97a8..bb425352ed410 100644 --- a/src/os/bluestore/bluestore_types.cc +++ b/src/os/bluestore/bluestore_types.cc @@ -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& ls) diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index 9b54c6b0a39ae..580b5394350a5 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -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); -- 2.39.5