From b43d4809387f3396594724cfa80cd9ae91eb3ed1 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 30 Jan 2016 13:42:24 +0800 Subject: [PATCH] librados: add `inconsistent_obj_t` types which present the inconsistent objects found in scrub Fixes: #13505 Signed-off-by: Kefu Chai --- src/include/rados/rados_types.hpp | 87 +++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/src/include/rados/rados_types.hpp b/src/include/rados/rados_types.hpp index f70d521deb803..3eab5e7d0b97a 100644 --- a/src/include/rados/rados_types.hpp +++ b/src/include/rados/rados_types.hpp @@ -1,11 +1,13 @@ #ifndef CEPH_RADOS_TYPES_HPP #define CEPH_RADOS_TYPES_HPP +#include #include #include #include #include +#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 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 shards; +}; + /** * @var all_nspaces * Pass as nspace argument to IoCtx::set_namespace() -- 2.39.5