From: Guang Yang Date: Wed, 26 Nov 2014 11:06:55 +0000 (+0000) Subject: Move the sched_scrub to a new tick timer which does not need to hold the osd_lock. X-Git-Tag: v9.0.1~42^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e98b5a9ad107b743d25899d4543b124d20337c12;p=ceph.git Move the sched_scrub to a new tick timer which does not need to hold the osd_lock. Signed-off-by: Guang Yang --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index a6cbfd796de..3d0fa724c2d 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -148,6 +148,8 @@ static coll_t META_COLL("meta"); #undef dout_prefix #define dout_prefix _prefix(_dout, whoami, get_osdmap_epoch()) +const double OSD::OSD_TICK_INTERVAL = 1.0; + static ostream& _prefix(std::ostream* _dout, int whoami, epoch_t epoch) { return *_dout << "osd." << whoami << " " << epoch << " "; } @@ -1500,6 +1502,8 @@ OSD::OSD(CephContext *cct_, ObjectStore *store_, Dispatcher(cct_), osd_lock("OSD::osd_lock"), tick_timer(cct, osd_lock), + tick_timer_lock("OSD::tick_timer_lock"), + tick_timer_without_osd_lock(cct, tick_timer_lock), authorize_handler_cluster_registry(new AuthAuthorizeHandlerRegistry(cct, cct->_conf->auth_supported.length() ? cct->_conf->auth_supported : @@ -1758,6 +1762,7 @@ int OSD::init() return 0; tick_timer.init(); + tick_timer_without_osd_lock.init(); service.backfill_request_timer.init(); // mount. @@ -1896,6 +1901,10 @@ int OSD::init() // tick tick_timer.add_event_after(cct->_conf->osd_heartbeat_interval, new C_Tick(this)); + { + Mutex::Locker l(tick_timer_lock); + tick_timer_without_osd_lock.add_event_after(cct->_conf->osd_heartbeat_interval, new C_Tick_WithoutOSDLock(this)); + } service.init(); service.publish_map(osdmap); @@ -2324,6 +2333,11 @@ int OSD::shutdown() tick_timer.shutdown(); + { + Mutex::Locker l(tick_timer_lock); + tick_timer_without_osd_lock.shutdown(); + } + // note unmount epoch dout(10) << "noting clean unmount in epoch " << osdmap->get_epoch() << dendl; superblock.mounted = service.get_boot_epoch(); @@ -3898,10 +3912,6 @@ void OSD::tick() // periodically kick recovery work queue recovery_tp.wake(); - if (!scrub_random_backoff()) { - sched_scrub(); - } - check_replay_queue(); } @@ -3917,7 +3927,18 @@ void OSD::tick() check_ops_in_flight(); - tick_timer.add_event_after(1.0, new C_Tick(this)); + tick_timer.add_event_after(OSD_TICK_INTERVAL, new C_Tick(this)); +} + +void OSD::tick_without_osd_lock() +{ + assert(tick_timer_lock.is_locked()); + dout(5) << "tick_without_osd_lock" << dendl; + + if (!scrub_random_backoff()) { + sched_scrub(); + } + tick_timer_without_osd_lock.add_event_after(OSD_TICK_INTERVAL, new C_Tick_WithoutOSDLock(this)); } void OSD::check_ops_in_flight() @@ -5904,8 +5925,6 @@ bool OSD::scrub_should_schedule() void OSD::sched_scrub() { - assert(osd_lock.is_locked()); - bool load_is_low = scrub_should_schedule(); dout(20) << "sched_scrub load_is_low=" << (int)load_is_low << dendl; diff --git a/src/osd/OSD.h b/src/osd/OSD.h index fe281ea04a0..654fe0ea9e8 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -913,6 +913,12 @@ protected: Mutex osd_lock; // global lock SafeTimer tick_timer; // safe timer (osd_lock) + // Tick timer for those stuff that do not need osd_lock + Mutex tick_timer_lock; + SafeTimer tick_timer_without_osd_lock; + + static const double OSD_TICK_INTERVAL; // tick interval for tick_timer and tick_timer_without_osd_lock + AuthAuthorizeHandlerRegistry *authorize_handler_cluster_registry; AuthAuthorizeHandlerRegistry *authorize_handler_service_registry; @@ -939,12 +945,22 @@ protected: } }; + class C_Tick_WithoutOSDLock : public Context { + OSD *osd; + public: + C_Tick_WithoutOSDLock(OSD *o) : osd(o) {} + void finish(int r) { + osd->tick_without_osd_lock(); + } + }; + Cond dispatch_cond; int dispatch_running; void create_logger(); void create_recoverystate_perf(); void tick(); + void tick_without_osd_lock(); void _dispatch(Message *m); void dispatch_op(OpRequestRef op); bool dispatch_op_fast(OpRequestRef& op, OSDMapRef& osdmap);