From 0f7a490876eeea8ad8457f0e529c63132c3a9e59 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Tue, 20 Sep 2011 10:50:07 -0700 Subject: [PATCH] ReplicatedPG: populate obc watchers on sub_op_push Previously, obc->unconnected_watchers did not get filled in during sub_op_push. Signed-off-by: Samuel Just --- src/osd/ReplicatedPG.cc | 31 +++++++++++++++++++------------ src/osd/ReplicatedPG.h | 2 ++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index f5cde506cddd3..0a8261bb6272a 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -3012,6 +3012,22 @@ void ReplicatedPG::repop_ack(RepGather *repop, int result, int ack_type, // ------------------------------------------------------- +void ReplicatedPG::populate_obc_watchers(ObjectContext *obc) +{ + if (!obc->obs.oi.watchers.empty()) { + // populate unconnected_watchers + utime_t now = ceph_clock_now(g_ceph_context); + for (map::iterator p = obc->obs.oi.watchers.begin(); + p != obc->obs.oi.watchers.end(); + p++) { + utime_t expire = now; + expire += p->second.timeout_seconds; + dout(10) << " unconnected watcher " << p->first << " will expire " << expire << dendl; + obc->unconnected_watchers[p->first] = expire; + } + } +} + ReplicatedPG::ObjectContext *ReplicatedPG::get_object_context(const hobject_t& soid, const object_locator_t& oloc, @@ -3056,18 +3072,7 @@ ReplicatedPG::ObjectContext *ReplicatedPG::get_object_context(const hobject_t& s obc->obs.oi.decode(bv); obc->obs.exists = true; - if (!obc->obs.oi.watchers.empty()) { - // populate unconnected_watchers - utime_t now = ceph_clock_now(g_ceph_context); - for (map::iterator p = obc->obs.oi.watchers.begin(); - p != obc->obs.oi.watchers.end(); - p++) { - utime_t expire = now; - expire += p->second.timeout_seconds; - dout(10) << " unconnected watcher " << p->first << " will expire " << expire << dendl; - obc->unconnected_watchers[p->first] = expire; - } - } + populate_obc_watchers(obc); } else { obc->obs.exists = false; } @@ -4263,6 +4268,8 @@ void ReplicatedPG::sub_op_push(MOSDSubOp *op) obc->obs.exists = true; obc->obs.oi.decode(oibl); + + populate_obc_watchers(obc); // suck in snapset context? SnapSetContext *ssc = obc->ssc; diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 3c847f4b7ae7e..a1fa6367c376a 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -485,6 +485,8 @@ protected: map object_contexts; map snapset_contexts; + void populate_obc_watchers(ObjectContext *obc); + ObjectContext *lookup_object_context(const hobject_t& soid) { if (object_contexts.count(soid)) { ObjectContext *obc = object_contexts[soid]; -- 2.39.5