<< " oi.version=" << oi.version.version << " ctx->at_version=" << ctx->at_version << dendl;
dout(10) << "watch: oi.user_version=" << oi.user_version.version << dendl;
- watch_info_t w(cookie, 30); // FIXME: where does the timeout come from?
+ // FIXME: where does the timeout come from?
+ watch_info_t w(cookie, 30,
+ ctx->op->request->get_connection()->get_peer_addr());
if (do_watch) {
if (oi.watchers.count(make_pair(cookie, entity))) {
dout(10) << " found existing watch " << w << " by " << entity << dendl;
<< dendl;
watch = Watch::makeWatchRef(
this, osd, ctx->obc, i->timeout_seconds,
- i->cookie, entity);
+ i->cookie, entity, conn->get_peer_addr());
ctx->obc->watchers.insert(
make_pair(
watcher,
dout(10) << " unconnected watcher " << p->first << " will expire " << expire << dendl;
WatchRef watch(
Watch::makeWatchRef(
- this, osd, obc, p->second.timeout_seconds, p->first.first, p->first.second));
+ this, osd, obc, p->second.timeout_seconds, p->first.first,
+ p->first.second, p->second.addr));
watch->disconnect();
obc->watchers.insert(
make_pair(
ObjectContext *obc,
uint32_t timeout,
uint64_t cookie,
- entity_name_t entity)
+ entity_name_t entity,
+ entity_addr_t addr)
: cb(NULL),
osd(osd),
pg(pg),
obc(obc),
timeout(timeout),
cookie(cookie),
+ addr(addr),
entity(entity),
discarded(false) {
obc->get();
WatchRef Watch::makeWatchRef(
ReplicatedPG *pg, OSDService *osd,
- ObjectContext *obc, uint32_t timeout, uint64_t cookie, entity_name_t entity)
+ ObjectContext *obc, uint32_t timeout, uint64_t cookie, entity_name_t entity, entity_addr_t addr)
{
- WatchRef ret(new Watch(pg, osd, obc, timeout, cookie, entity));
+ WatchRef ret(new Watch(pg, osd, obc, timeout, cookie, entity, addr));
ret->set_self(ret);
return ret;
}
std::map<uint64_t, NotifyRef> in_progress_notifies;
+ // Could have watch_info_t here, but this file includes osd_types.h
uint32_t timeout;
uint64_t cookie;
+ entity_addr_t addr;
+
entity_name_t entity;
bool discarded;
Watch(
ReplicatedPG *pg, OSDService *osd,
ObjectContext *obc, uint32_t timeout,
- uint64_t cookie, entity_name_t entity);
+ uint64_t cookie, entity_name_t entity,
+ entity_addr_t addr);
/// Registers the timeout callback with watch_timer
void register_cb();
string gen_dbg_prefix();
static WatchRef makeWatchRef(
ReplicatedPG *pg, OSDService *osd,
- ObjectContext *obc, uint32_t timeout, uint64_t cookie, entity_name_t entity);
+ ObjectContext *obc, uint32_t timeout, uint64_t cookie, entity_name_t entity, entity_addr_t addr);
void set_self(WatchRef _self) {
self = _self;
}
ObjectContext *get_obc();
uint64_t get_cookie() const { return cookie; }
entity_name_t get_entity() const { return entity; }
+ entity_addr_t get_peer_addr() const { return addr; }
/// Generates context for use if watch timeout is delayed by scrub or recovery
Context *get_delayed_cb();
void watch_info_t::encode(bufferlist& bl) const
{
- ENCODE_START(3, 3, bl);
+ ENCODE_START(4, 3, bl);
::encode(cookie, bl);
::encode(timeout_seconds, bl);
+ ::encode(addr, bl);
ENCODE_FINISH(bl);
}
void watch_info_t::decode(bufferlist::iterator& bl)
{
- DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl);
+ DECODE_START_LEGACY_COMPAT_LEN(4, 3, 3, bl);
::decode(cookie, bl);
if (struct_v < 2) {
uint64_t ver;
::decode(ver, bl);
}
::decode(timeout_seconds, bl);
+ if (struct_v >= 4) {
+ ::decode(addr, bl);
+ }
DECODE_FINISH(bl);
}
{
f->dump_unsigned("cookie", cookie);
f->dump_unsigned("timeout_seconds", timeout_seconds);
+ f->open_object_section("addr");
+ addr.dump(f);
+ f->close_section();
}
void watch_info_t::generate_test_instances(list<watch_info_t*>& o)
o.push_back(new watch_info_t);
o.back()->cookie = 123;
o.back()->timeout_seconds = 99;
+ entity_addr_t ea;
+ ea.set_nonce(1);
+ ea.set_family(AF_INET);
+ ea.set_in4_quad(0, 127);
+ ea.set_in4_quad(1, 0);
+ ea.set_in4_quad(2, 1);
+ ea.set_in4_quad(3, 2);
+ ea.set_port(2);
+ o.back()->addr = ea;
}
struct watch_info_t {
uint64_t cookie;
uint32_t timeout_seconds;
+ entity_addr_t addr;
- watch_info_t(uint64_t c=0, uint32_t t=0) : cookie(c), timeout_seconds(t) {}
+ watch_info_t() : cookie(0), timeout_seconds(0) { }
+ watch_info_t(uint64_t c, uint32_t t, entity_addr_t a) : cookie(c), timeout_seconds(t), addr(a) {}
void encode(bufferlist& bl) const;
void decode(bufferlist::iterator& bl);
WRITE_CLASS_ENCODER(watch_info_t)
static inline bool operator==(const watch_info_t& l, const watch_info_t& r) {
- return l.cookie == r.cookie && l.timeout_seconds == r.timeout_seconds;
+ return l.cookie == r.cookie && l.timeout_seconds == r.timeout_seconds
+ && l.addr == r.addr;
}
static inline ostream& operator<<(ostream& out, const watch_info_t& w) {
- return out << "watch(cookie " << w.cookie << " " << w.timeout_seconds << "s)";
+ return out << "watch(cookie " << w.cookie << " " << w.timeout_seconds << "s"
+ << " " << w.addr << ")";
}
struct notify_info_t {