]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/ReplicatedPG: handle PING and RECONNECT watch ops
authorSage Weil <sage@redhat.com>
Fri, 17 Oct 2014 02:28:53 +0000 (19:28 -0700)
committerSage Weil <sage@redhat.com>
Thu, 4 Dec 2014 18:32:37 +0000 (10:32 -0800)
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 <sage@redhat.com>
src/osd/ReplicatedPG.cc

index d9b29ff4c0e71f80769e80c24177ed694442124b..90fa1d53bfe807b22d4f2fc8179af14f8e878e87 100644 (file)
@@ -4312,6 +4312,20 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& 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<pair<uint64_t, entity_name_t>, watch_info_t>::iterator oi_iter =
            oi.watchers.find(make_pair(cookie, entity));