From 86b3e8aeb30fcab331be59e92e51a0f2c4220ee2 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Mon, 24 Sep 2012 11:37:07 -0700 Subject: [PATCH] OSD: add init and shutdown for OSDService Signed-off-by: Samuel Just --- src/osd/OSD.cc | 30 +++++++++++++++++++----------- src/osd/OSD.h | 3 +++ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 5add6750558..c6adf0d0b49 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -185,6 +185,21 @@ void OSDService::pg_stat_queue_dequeue(PG *pg) osd->pg_stat_queue_dequeue(pg); } +void OSDService::shutdown() +{ + watch_lock.Lock(); + watch_timer.shutdown(); + watch_lock.Unlock(); + + delete watch; +} + +void OSDService::init() +{ + watch_timer.init(); + watch = new Watch(); +} + ObjectStore *OSD::create_object_store(const std::string &dev, const std::string &jdev) { struct stat st; @@ -798,8 +813,6 @@ int OSD::init() Mutex::Locker lock(osd_lock); timer.init(); - service.watch_timer.init(); - service.watch = new Watch(); // mount. dout(2) << "mounting " << dev_path << " " @@ -833,7 +846,6 @@ int OSD::init() if (r < 0) return r; } - service.publish_superblock(superblock); class_handler = new ClassHandler(); cls_initialize(class_handler); @@ -845,8 +857,6 @@ int OSD::init() return -EINVAL; } osdmap = get_map(superblock.current_epoch); - service.publish_map(osdmap); - check_osdmap_features(); bind_epoch = osdmap->get_epoch(); @@ -922,6 +932,9 @@ int OSD::init() "show slowest recent ops"); assert(r == 0); + service.init(); + service.publish_map(osdmap); + service.publish_superblock(superblock); return 0; } @@ -1016,6 +1029,7 @@ void OSD::suicide(int exitcode) int OSD::shutdown() { + service.shutdown(); g_ceph_context->_conf->set_val("debug_osd", "100"); g_ceph_context->_conf->set_val("debug_journal", "100"); g_ceph_context->_conf->set_val("debug_filestore", "100"); @@ -1028,10 +1042,6 @@ int OSD::shutdown() timer.shutdown(); - service.watch_lock.Lock(); - service.watch_timer.shutdown(); - service.watch_lock.Unlock(); - heartbeat_lock.Lock(); heartbeat_stop = true; heartbeat_cond.Signal(); @@ -1133,8 +1143,6 @@ int OSD::shutdown() monc->shutdown(); - delete service.watch; - osd_lock.Unlock(); return r; } diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 9cf4c43df70..25daf495f81 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -315,6 +315,9 @@ public: void pg_stat_queue_enqueue(PG *pg); void pg_stat_queue_dequeue(PG *pg); + void init(); + void shutdown(); + OSDService(OSD *osd); }; class OSD : public Dispatcher {