From: Samuel Just Date: Tue, 12 Feb 2013 21:43:36 +0000 (-0800) Subject: ReplicatedPG: accept watch cookie value with notify ack X-Git-Tag: v0.59~160^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8ece91ff2132c50c58d924aa1b912544ff423704;p=ceph.git ReplicatedPG: accept watch cookie value with notify ack Signed-off-by: Samuel Just --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 2e4ea0286d08..5d1d3ab95421 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -2241,7 +2241,20 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& ops) case CEPH_OSD_OP_NOTIFY_ACK: { - ctx->notify_acks.push_back(op.watch.cookie); + try { + uint64_t notify_id = 0; + uint64_t watch_cookie = 0; + ::decode(notify_id, bp); + ::decode(watch_cookie, bp); + OpContext::NotifyAck ack(notify_id, watch_cookie); + ctx->notify_acks.push_back(ack); + } catch (const buffer::error &e) { + OpContext::NotifyAck ack( + // op.watch.cookie is actually the notify_id for historical reasons + op.watch.cookie + ); + ctx->notify_acks.push_back(ack); + } } break; @@ -3309,17 +3322,19 @@ void ReplicatedPG::do_osd_op_effects(OpContext *ctx) notif->init(); } - for (list::iterator p = ctx->notify_acks.begin(); + for (list::iterator p = ctx->notify_acks.begin(); p != ctx->notify_acks.end(); ++p) { - dout(10) << "notify_ack " << *p << dendl; + dout(10) << "notify_ack " << make_pair(p->watch_cookie, p->notify_id) << dendl; for (map, WatchRef>::iterator i = ctx->obc->watchers.begin(); i != ctx->obc->watchers.end(); ++i) { if (i->first.second != entity) continue; + if (p->watch_cookie && + p->watch_cookie.get() != i->first.first) continue; dout(10) << "acking notify on watch " << i->first << dendl; - i->second->notify_ack(*p); + i->second->notify_ack(p->notify_id); } } } diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 47ee76e5aa33..a33b86c85c7c 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -14,6 +14,9 @@ #ifndef CEPH_REPLICATEDPG_H #define CEPH_REPLICATEDPG_H +#include + +#include "include/assert.h" #include "PG.h" #include "OSD.h" @@ -260,7 +263,14 @@ public: bool watch_connect, watch_disconnect; watch_info_t watch_info; list notifies; - list notify_acks; + struct NotifyAck { + boost::optional watch_cookie; + uint64_t notify_id; + NotifyAck(uint64_t notify_id) : notify_id(notify_id) {} + NotifyAck(uint64_t notify_id, uint64_t cookie) + : watch_cookie(cookie), notify_id(notify_id) {} + }; + list notify_acks; uint64_t bytes_written, bytes_read;