]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: add `inconsistent_obj_t` types
authorKefu Chai <kchai@redhat.com>
Sat, 30 Jan 2016 05:42:24 +0000 (13:42 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 25 Feb 2016 04:40:17 +0000 (12:40 +0800)
which present the inconsistent objects found in scrub

Fixes: #13505
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/include/rados/rados_types.hpp

index f70d521deb8030bd6d470ca1440903f94d4fc24d..3eab5e7d0b97a4171a4e553fe3358fd4862c0346 100644 (file)
@@ -1,11 +1,13 @@
 #ifndef CEPH_RADOS_TYPES_HPP
 #define CEPH_RADOS_TYPES_HPP
 
+#include <map>
 #include <utility>
 #include <vector>
 #include <stdint.h>
 #include <string>
 
+#include "buffer.h"
 #include "rados_types.h"
 
 namespace librados {
@@ -31,6 +33,91 @@ struct snap_set_t {
   snap_set_t() : seq(0) {}
 };
 
+struct object_id_t {
+  std::string name;
+  std::string nspace;
+  std::string locator;
+  snap_t snap = 0;
+  object_id_t() = default;
+  object_id_t(const std::string& name,
+              const std::string& nspace,
+              const std::string& locator,
+              snap_t snap)
+    : name(name),
+      nspace(nspace),
+      locator(locator),
+      snap(snap)
+  {}
+};
+
+struct err_t {
+  enum {
+    SHARD_MISSING        = 1 << 1,
+    SHARD_STAT_ERR       = 1 << 2,
+    SHARD_READ_ERR       = 1 << 3,
+    DATA_DIGEST_MISMATCH = 1 << 4,
+    OMAP_DIGEST_MISMATCH = 1 << 5,
+    SIZE_MISMATCH        = 1 << 6,
+    ATTR_MISMATCH        = 1 << 7,
+    SNAPSET_MISSING      = 1 << 8,
+    DATA_DIGEST_MISMATCH_OI = 1 << 9,
+    OMAP_DIGEST_MISMATCH_OI = 1 << 10,
+    SIZE_MISMATCH_OI        = 1 << 11,
+  };
+  uint64_t errors = 0;
+  bool has_shard_missing() const {
+    return errors & SHARD_MISSING;
+  }
+  bool has_stat_error() const {
+    return errors & SHARD_STAT_ERR;
+  }
+  bool has_read_error() const {
+    return errors & SHARD_READ_ERR;
+  }
+  bool has_data_digest_mismatch() const {
+    return errors & DATA_DIGEST_MISMATCH;
+  }
+  bool has_omap_digest_mismatch() const {
+    return errors & OMAP_DIGEST_MISMATCH;
+  }
+  // deep error
+  bool has_data_digest_mismatch_oi() const {
+    return errors & DATA_DIGEST_MISMATCH_OI;
+  }
+  // deep error
+  bool has_omap_digest_mismatch_oi() const {
+    return errors & OMAP_DIGEST_MISMATCH_OI;
+  }
+  bool has_size_mismatch() const {
+    return errors & SIZE_MISMATCH;
+  }
+  bool has_size_mismatch_oi() const {
+    return errors & SIZE_MISMATCH_OI;
+  }
+  bool has_attr_mismatch() const {
+    return errors & ATTR_MISMATCH;
+  }
+};
+
+struct shard_info_t : err_t {
+  std::map<std::string, bufferlist> attrs;
+  uint64_t size = -1;
+  bool omap_digest_present = false;
+  uint32_t omap_digest = 0;
+  bool data_digest_present = false;
+  uint32_t data_digest = 0;
+};
+
+struct inconsistent_obj_t : err_t {
+  inconsistent_obj_t() = default;
+  inconsistent_obj_t(const object_id_t& object)
+    : object{object}
+  {}
+  object_id_t object;
+  // osd => shard_info
+  std::map<int32_t, shard_info_t> shards;
+};
+
 /**
  * @var all_nspaces
  * Pass as nspace argument to IoCtx::set_namespace()