From 931ae6b8a06e7eabc230ebee9e7bcb1402be546f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 19 Apr 2014 22:06:48 -0700 Subject: [PATCH] osd/osd_types: pg_interval_t: include up_primary in pg_interval_t Nothing uses this, but it triggers a new interval, which makes it confusing when it is not recording in the interval itself. Let's add it now. Signed-off-by: Sage Weil --- src/osd/osd_types.cc | 13 +++++++++++-- src/osd/osd_types.h | 8 +++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index f153a35f452..d6d184edf0b 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -2102,19 +2102,20 @@ ostream &operator<<(ostream &lhs, const pg_notify_t ¬ify) void pg_interval_t::encode(bufferlist& bl) const { - ENCODE_START(3, 2, bl); + ENCODE_START(4, 2, bl); ::encode(first, bl); ::encode(last, bl); ::encode(up, bl); ::encode(acting, bl); ::encode(maybe_went_rw, bl); ::encode(primary, bl); + ::encode(up_primary, bl); ENCODE_FINISH(bl); } void pg_interval_t::decode(bufferlist::iterator& bl) { - DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl); + DECODE_START_LEGACY_COMPAT_LEN(4, 2, 2, bl); ::decode(first, bl); ::decode(last, bl); ::decode(up, bl); @@ -2126,6 +2127,12 @@ void pg_interval_t::decode(bufferlist::iterator& bl) if (acting.size()) primary = acting[0]; } + if (struct_v >= 4) { + ::decode(up_primary, bl); + } else { + if (up.size()) + up_primary = up[0]; + } DECODE_FINISH(bl); } @@ -2142,6 +2149,7 @@ void pg_interval_t::dump(Formatter *f) const for (vector::const_iterator p = acting.begin(); p != acting.end(); ++p) f->dump_int("osd", *p); f->dump_int("primary", primary); + f->dump_int("up_primary", up_primary); f->close_section(); } @@ -2194,6 +2202,7 @@ bool pg_interval_t::check_new_interval( i.acting = old_acting; i.up = old_up; i.primary = old_acting_primary; + i.up_primary = old_up_primary; if (!i.acting.empty() && i.primary != -1 && i.acting.size() >= diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index c8b7ff8675e..744b1c368e9 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -1683,8 +1683,14 @@ struct pg_interval_t { epoch_t first, last; bool maybe_went_rw; int primary; + int up_primary; - pg_interval_t() : first(0), last(0), maybe_went_rw(false), primary(-1) {} + pg_interval_t() + : first(0), last(0), + maybe_went_rw(false), + primary(-1), + up_primary(-1) + {} void encode(bufferlist& bl) const; void decode(bufferlist::iterator& bl);