From d5cc673214ea0a760306868252b97590056eb8d9 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 26 Oct 2010 15:20:45 -0700 Subject: [PATCH] osd: some notify related cleanups --- src/osd/OSD.cc | 14 ++++++++++---- src/osd/OSD.h | 2 ++ src/osd/ReplicatedPG.cc | 17 +++++++++++------ src/osd/ReplicatedPG.h | 2 ++ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 8e7051e6b3b3c..63693b11daa76 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1605,11 +1605,17 @@ void OSD::ms_handle_connect(Connection *con) } } -void OSD::put_object_context(void *_obc, ceph_object_layout& layout) +ReplicatedPG *OSD::get_pg(void *_obc, ceph_object_layout& layout) { - ReplicatedPG::ObjectContext *obc = (ReplicatedPG::ObjectContext *)_obc; pg_t pgid = osdmap->raw_pg_to_pg(pg_t(layout.ol_pgid)); ReplicatedPG *pg = (ReplicatedPG *)lookup_lock_pg(pgid); + return pg; +} + +void OSD::put_object_context(void *_obc, ceph_object_layout& layout) +{ + ReplicatedPG::ObjectContext *obc = (ReplicatedPG::ObjectContext *)_obc; + ReplicatedPG *pg = get_pg(_obc, layout); pg->put_object_context(obc); pg->unlock(); } @@ -1689,9 +1695,9 @@ void OSD::handle_notify_timeout(void *_notif) obc->lock.Unlock(); watch_lock.Unlock(); /* put_object_context takes osd->lock */ - client_messenger->send_message(notif->reply, notif->session->con); + ReplicatedPG *pg = get_pg(obc, notif->layout); put_object_context(obc, notif->layout); - delete notif; + pg->do_complete_notify(notif); watch_lock.Lock(); diff --git a/src/osd/OSD.h b/src/osd/OSD.h index a9921428090e2..efb8d0f62ceda 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -102,6 +102,7 @@ class MOSDPGMissing; class Watch; class Notification; class ObjectContext; +class ReplicatedPG; extern const coll_t meta_coll; @@ -984,6 +985,7 @@ public: void init_op_flags(MOSDOp *op); PG *lookup_lock_pg(pg_t pgid); + ReplicatedPG *get_pg(void *_obc, ceph_object_layout& layout); void put_object_context(void *_obc, ceph_object_layout& layout); Mutex watch_lock; SafeTimer watch_timer; diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index bd2da61ccced9..7434077d83e5e 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -780,6 +780,15 @@ int ReplicatedPG::do_xattr_cmp_str(int op, string& v1s, bufferlist& xattr) } } +void ReplicatedPG::do_complete_notify(Watch::Notification *notif) +{ + osd->client_messenger->send_message(notif->reply, notif->session->con); + notif->session->put(); + osd->watch->remove_notification(notif); + delete notif; +} + + // ======================================================================== // low level osd ops @@ -1129,16 +1138,12 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& ops, } } - MWatchNotify *reply = new MWatchNotify(op.watch.cookie, op.watch.ver, notif->id, WATCH_NOTIFY_COMPLETE); + notif->reply = new MWatchNotify(op.watch.cookie, op.watch.ver, notif->id, WATCH_NOTIFY_COMPLETE); if (notif->watchers.empty()) { - osd->client_messenger->send_message(reply, notif->session->con); - notif->session->put(); - osd->watch->remove_notification(notif); - delete notif; + do_complete_notify(notif); } else { obc->ref++; notif->obc = obc; - notif->reply = reply; notif->timeout = new Watch::C_NotifyTimeout(osd, notif); osd->watch_timer.add_event_after(5.0, notif->timeout); } diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 3d8d39810f42b..4cf34eb07abe5 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -522,6 +522,8 @@ protected: int recover_primary(int max); int recover_replicas(int max); + void do_complete_notify(Watch::Notification *notif); + struct RepModify { ReplicatedPG *pg; MOSDSubOp *op; -- 2.39.5