From ecb88dce6339b4dee52198f50bcd9968c9f5a1d4 Mon Sep 17 00:00:00 2001 From: letterwuyu Date: Mon, 6 May 2019 15:23:12 +0800 Subject: [PATCH] osd: change pg_missing_item encode and decode since luminous, recovery_deletes is always true, and octopus won't maintain compatibility with jewel OSDs Signed-off-by: lishuhao --- src/osd/osd_types.h | 68 ++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 41 deletions(-) diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index d48afd76f08..2fbb375eb0e 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -4220,59 +4220,43 @@ struct pg_missing_item { void encode(ceph::buffer::list& bl, uint64_t features) const { using ceph::encode; - // encoding a zeroed eversion_t to differentiate between OSD_RECOVERY_DELETES、 - // SERVER_OCTOPUS and legacy unversioned encoding - a need value of 0'0 is not - // possible. This can be replaced with the legacy encoding - - bool have_recovery_deletes = HAVE_FEATURE(features, OSD_RECOVERY_DELETES); - bool have_server_octopus = HAVE_FEATURE(features, SERVER_OCTOPUS); - - if (have_recovery_deletes) + if (HAVE_FEATURE(features, SERVER_OCTOPUS)) { + // encoding a zeroed eversion_t to differentiate between OSD_RECOVERY_DELETES、 + // SERVER_OCTOPUS and legacy unversioned encoding - a need value of 0'0 is not + // possible. This can be replaced with the legacy encoding encode(eversion_t(), bl); - if (have_server_octopus) encode(eversion_t(-1, -1), bl); - - encode(need, bl); - encode(have, bl); - - if (have_recovery_deletes) + encode(need, bl); + encode(have, bl); encode(static_cast(flags), bl); - if (have_server_octopus) encode(clean_regions, bl); + } else { + encode(eversion_t(), bl); + encode(need, bl); + encode(have, bl); + encode(static_cast(flags), bl); + } } void decode(ceph::buffer::list::const_iterator& bl) { using ceph::decode; - eversion_t e; + eversion_t e, l; decode(e, bl); - - if(e == eversion_t()) { - eversion_t l; - decode(l, bl); - if(l == eversion_t(-1, -1)) { - // support all - decode(need, bl); - decode(have, bl); - uint8_t f; - decode(f, bl); - flags = static_cast(f); - decode(clean_regions, bl); - } else { - // support OSD_RECOVERY_DELETES - need = l; - decode(have, bl); - uint8_t f; - decode(f, bl); - flags = static_cast(f); - } - } else if (e == eversion_t(-1, -1)) { - // support NAUTILUS + decode(l, bl); + if(l == eversion_t(-1, -1)) { + // support all decode(need, bl); decode(have, bl); + uint8_t f; + decode(f, bl); + flags = static_cast(f); decode(clean_regions, bl); - } else { - // legacy encoding - need = e; + } else { + // support OSD_RECOVERY_DELETES + need = l; decode(have, bl); + uint8_t f; + decode(f, bl); + flags = static_cast(f); } } @@ -4627,10 +4611,12 @@ public: } static void generate_test_instances(std::list& o) { o.push_back(new pg_missing_set); + o.back()->may_include_deletes = true; o.push_back(new pg_missing_set); o.back()->add( hobject_t(object_t("foo"), "foo", 123, 456, 0, ""), eversion_t(5, 6), eversion_t(5, 1), false); + o.back()->may_include_deletes = true; o.push_back(new pg_missing_set); o.back()->add( hobject_t(object_t("foo"), "foo", 123, 456, 0, ""), -- 2.39.5