From: Sage Weil Date: Fri, 17 Oct 2014 02:28:53 +0000 (-0700) Subject: osd/ReplicatedPG: handle PING and RECONNECT watch ops X-Git-Tag: v0.91~144 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d44bd2b0c84a57cf8067495826ce52ef85a4afd2;p=ceph.git osd/ReplicatedPG: handle PING and RECONNECT watch ops The ping will essentially assert that a watch is still valid. A reconnect will reestablish session state *only* if the watch is still persistent. If not, it will fail (and the client will know it may have missed something). Note that the only difference here is that a PING is a bit lighter weight; it will not reestablish the session state (which should already be established). We could use a single op here but the unique op code makes the messages easier to understand and simplifies the code path a bit for PING. Signed-off-by: Sage Weil --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index d9b29ff4c0e7..90fa1d53bfe8 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4312,6 +4312,20 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& ops) t->nop(); // make sure update the object_info on disk! } ctx->watch_connects.push_back(w); + } else if (op.watch.op == CEPH_OSD_WATCH_OP_RECONNECT) { + if (!oi.watchers.count(make_pair(cookie, entity))) { + result = -ENOTCONN; + break; + } + dout(10) << " found existing watch " << w << " by " << entity << dendl; + ctx->watch_connects.push_back(w); + } else if (op.watch.op == CEPH_OSD_WATCH_OP_PING) { + if (!oi.watchers.count(make_pair(cookie, entity))) { + result = -ENOTCONN; + break; + } + dout(10) << " found existing watch " << w << " by " << entity << dendl; + result = 0; } else if (op.watch.op == CEPH_OSD_WATCH_OP_UNWATCH) { map, watch_info_t>::iterator oi_iter = oi.watchers.find(make_pair(cookie, entity));