]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/ECBackend: use an explicit backfill field on ECSubWrite
authorSamuel Just <sjust@redhat.com>
Wed, 19 Oct 2016 16:56:46 +0000 (09:56 -0700)
committerSamuel Just <sjust@redhat.com>
Thu, 17 Nov 2016 18:41:33 +0000 (10:41 -0800)
Previously, we used an empty transaction to indicate when we
were sending the op to a backfill peer which needs the logs,
but can't run the transaction.  I'd like to be able to send
and empty transaction for the rollforward side effect without
it causing the peer to think it missed a backfill op, so
instead, use an explicit flag.  Compatability is handled by
interpretting an old version encoding with an empty transaction
as having the backfill field filled.

Signed-off-by: Samuel Just <sjust@redhat.com>
src/osd/ECBackend.cc
src/osd/ECMsgTypes.cc
src/osd/ECMsgTypes.h
src/osd/PG.cc
src/osd/PG.h
src/osd/PGLog.h

index fe2260ae08607bf11ce3067c848d0c93f7476bca..8e709bc3882654ee25ccfdab6cf5c692692bea7a 100644 (file)
@@ -887,7 +887,7 @@ void ECBackend::handle_sub_write(
   if (!op.temp_added.empty()) {
     add_temp_objs(op.temp_added);
   }
-  if (op.t.empty()) {
+  if (op.backfill) {
     for (set<hobject_t, hobject_t::BitwiseComparator>::iterator i = op.temp_removed.begin();
         i != op.temp_removed.end();
         ++i) {
@@ -907,7 +907,7 @@ void ECBackend::handle_sub_write(
     op.updated_hit_set_history,
     op.trim_to,
     op.roll_forward_to,
-    !(op.t.empty()),
+    !op.backfill,
     localt);
 
   ReplicatedPG *_rPG = dynamic_cast<ReplicatedPG *>(get_parent());
@@ -1915,7 +1915,8 @@ bool ECBackend::try_reads_to_commit()
       op->log_entries,
       op->updated_hit_set_history,
       op->temp_added,
-      op->temp_cleared);
+      op->temp_cleared,
+      !should_send);
     if (*i == get_parent()->whoami_shard()) {
       handle_sub_write(
        get_parent()->whoami_shard(),
index a914f9f07c0846aa13585119ac850d0281be01be..2223e7f91a366524e604282448752d89487ef356 100644 (file)
@@ -16,7 +16,7 @@
 
 void ECSubWrite::encode(bufferlist &bl) const
 {
-  ENCODE_START(3, 1, bl);
+  ENCODE_START(4, 1, bl);
   ::encode(from, bl);
   ::encode(tid, bl);
   ::encode(reqid, bl);
@@ -30,12 +30,13 @@ void ECSubWrite::encode(bufferlist &bl) const
   ::encode(temp_removed, bl);
   ::encode(updated_hit_set_history, bl);
   ::encode(roll_forward_to, bl);
+  ::encode(backfill, bl);
   ENCODE_FINISH(bl);
 }
 
 void ECSubWrite::decode(bufferlist::iterator &bl)
 {
-  DECODE_START(3, bl);
+  DECODE_START(4, bl);
   ::decode(from, bl);
   ::decode(tid, bl);
   ::decode(reqid, bl);
@@ -55,6 +56,12 @@ void ECSubWrite::decode(bufferlist::iterator &bl)
   } else {
     roll_forward_to = trim_to;
   }
+  if (struct_v >= 4) {
+    ::decode(backfill, bl);
+  } else {
+    // The old protocol used an empty transaction to indicate backfill
+    backfill = t.empty();
+  }
   DECODE_FINISH(bl);
 }
 
@@ -68,6 +75,8 @@ std::ostream &operator<<(
       << ", roll_forward_to=" << rhs.roll_forward_to;
   if (rhs.updated_hit_set_history)
     lhs << ", has_updated_hit_set_history";
+  if (rhs.backfill)
+    lhs << ", backfill";
   return lhs <<  ")";
 }
 
@@ -80,6 +89,7 @@ void ECSubWrite::dump(Formatter *f) const
   f->dump_stream("roll_forward_to") << roll_forward_to;
   f->dump_bool("has_updated_hit_set_history",
       static_cast<bool>(updated_hit_set_history));
+  f->dump_bool("backfill", backfill);
 }
 
 void ECSubWrite::generate_test_instances(list<ECSubWrite*> &o)
index 80ea35d9e4d75916f0f0f6d4aa1990d5845f192d..d28b6efa7df22946e4adab29c812091c95e43b44 100644 (file)
@@ -34,6 +34,7 @@ struct ECSubWrite {
   set<hobject_t, hobject_t::BitwiseComparator> temp_added;
   set<hobject_t, hobject_t::BitwiseComparator> temp_removed;
   boost::optional<pg_hit_set_history_t> updated_hit_set_history;
+  bool backfill = false;
   ECSubWrite() : tid(0) {}
   ECSubWrite(
     pg_shard_t from,
@@ -48,7 +49,8 @@ struct ECSubWrite {
     vector<pg_log_entry_t> log_entries,
     boost::optional<pg_hit_set_history_t> updated_hit_set_history,
     const set<hobject_t, hobject_t::BitwiseComparator> &temp_added,
-    const set<hobject_t, hobject_t::BitwiseComparator> &temp_removed)
+    const set<hobject_t, hobject_t::BitwiseComparator> &temp_removed,
+    bool backfill)
     : from(from), tid(tid), reqid(reqid),
       soid(soid), stats(stats), t(t),
       at_version(at_version),
@@ -56,7 +58,9 @@ struct ECSubWrite {
       log_entries(log_entries),
       temp_added(temp_added),
       temp_removed(temp_removed),
-      updated_hit_set_history(updated_hit_set_history) {}
+      updated_hit_set_history(updated_hit_set_history),
+      backfill(backfill)
+    {}
   void claim(ECSubWrite &other) {
     from = other.from;
     tid = other.tid;
@@ -71,6 +75,7 @@ struct ECSubWrite {
     temp_added.swap(other.temp_added);
     temp_removed.swap(other.temp_removed);
     updated_hit_set_history = other.updated_hit_set_history;
+    backfill = other.backfill;
   }
   void encode(bufferlist &bl) const;
   void decode(bufferlist::iterator &bl);
index 030d4abce530190b2af758d892cb5bfa1a19bde8..7315c28b5b483d7f17dcde0fe64cc40b65af2d3f 100644 (file)
@@ -3012,7 +3012,7 @@ void PG::trim_peers()
   }
 }
 
-void PG::add_log_entry(const pg_log_entry_t& e)
+void PG::add_log_entry(const pg_log_entry_t& e, bool applied)
 {
   // raise last_complete only if we were previously up to date
   if (info.last_complete == info.last_update)
@@ -3028,7 +3028,7 @@ void PG::add_log_entry(const pg_log_entry_t& e)
     info.last_user_version = e.user_version;
 
   // log mutation
-  pg_log.add(e);
+  pg_log.add(e, applied);
   dout(10) << "add_log_entry " << e << dendl;
 }
 
index 517970cc68f267b7dda7f709e3417b2246f2f903..e98e5a61bab884455d81a449d097cf87153fb140 100644 (file)
@@ -2203,7 +2203,7 @@ public:
     return at_version;
   }
 
-  void add_log_entry(const pg_log_entry_t& e);
+  void add_log_entry(const pg_log_entry_t& e, bool applied);
   void append_log(
     const vector<pg_log_entry_t>& logv,
     eversion_t trim_to,
index 786dda6a29b753b1e9341d0570e2c6176347b2a4..eff487db2efa2ebb220e83dbcaa36acd34d0874e 100644 (file)
@@ -419,7 +419,11 @@ public:
     }
 
     // actors
-    void add(const pg_log_entry_t& e) {
+    void add(const pg_log_entry_t& e, bool applied = true) {
+      if (!applied) {
+       assert(get_can_rollback_to() == head);
+      }
+
       // add to log
       log.push_back(e);
 
@@ -449,6 +453,10 @@ public:
          extra_caller_ops.insert(make_pair(j->first, &(log.back())));
         }
       }
+
+      if (!applied) {
+       skip_can_rollback_to_to_head();
+      }
     }
 
     void trim(