From: Adam C. Emerson Date: Tue, 6 Dec 2016 22:24:12 +0000 (-0500) Subject: osd: Remove g_conf and g_ceph_context X-Git-Tag: v12.0.0~384^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1d5e967a05ddbcceb10efe3b57e242b3b6b7eb8c;p=ceph.git osd: Remove g_conf and g_ceph_context So begins the ruthless annihilation of g_ceph_context. Signed-off-by: Adam C. Emerson --- diff --git a/src/objclass/objclass.h b/src/objclass/objclass.h index 7cdb25b9678e..a2418798f320 100644 --- a/src/objclass/objclass.h +++ b/src/objclass/objclass.h @@ -117,6 +117,7 @@ typedef int (*cls_method_cxx_call_t)(cls_method_context_t ctx, class buffer::list *inbl, class buffer::list *outbl); class PGLSFilter { + CephContext* cct; protected: string xattr; public: diff --git a/src/osd/ClassHandler.cc b/src/osd/ClassHandler.cc index 4ee75d8490ba..a77acbaeccb2 100644 --- a/src/osd/ClassHandler.cc +++ b/src/osd/ClassHandler.cc @@ -17,7 +17,6 @@ #include "common/config.h" #include "common/debug.h" -#define dout_context g_ceph_context #define dout_subsys ceph_subsys_osd #undef dout_prefix #define dout_prefix *_dout @@ -52,7 +51,7 @@ int ClassHandler::open_class(const string& cname, ClassData **pcls) int ClassHandler::open_all_classes() { - dout(10) << __func__ << dendl; + ldout(cct, 10) << __func__ << dendl; DIR *dir = ::opendir(cct->_conf->osd_class_dir.c_str()); if (!dir) return -errno; @@ -68,7 +67,7 @@ int ClassHandler::open_all_classes() char cname[PATH_MAX + 1]; strncpy(cname, pde->d_name + sizeof(CLS_PREFIX) - 1, sizeof(cname) -1); cname[strlen(cname) - (sizeof(CLS_SUFFIX) - 1)] = '\0'; - dout(10) << __func__ << " found " << cname << dendl; + ldout(cct, 10) << __func__ << " found " << cname << dendl; ClassData *cls; // skip classes that aren't in 'osd class load list' r = open_class(cname, &cls); @@ -123,11 +122,11 @@ ClassHandler::ClassData *ClassHandler::_get_class(const string& cname, cls = &iter->second; } else { if (check_allowed && !in_class_list(cname, cct->_conf->osd_class_load_list)) { - dout(0) << "_get_class not permitted to load " << cname << dendl; + ldout(cct, 0) << "_get_class not permitted to load " << cname << dendl; return NULL; } cls = &classes[cname]; - dout(10) << "_get_class adding new class name " << cname << " " << cls << dendl; + ldout(cct, 10) << "_get_class adding new class name " << cname << " " << cls << dendl; cls->name = cname; cls->handler = this; cls->whitelisted = in_class_list(cname, cct->_conf->osd_class_default_list); @@ -147,7 +146,7 @@ int ClassHandler::_load_class(ClassData *cls) snprintf(fname, sizeof(fname), "%s/" CLS_PREFIX "%s" CLS_SUFFIX, cct->_conf->osd_class_dir.c_str(), cls->name.c_str()); - dout(10) << "_load_class " << cls->name << " from " << fname << dendl; + ldout(cct, 10) << "_load_class " << cls->name << " from " << fname << dendl; cls->handle = dlopen(fname, RTLD_NOW); if (!cls->handle) { @@ -155,12 +154,12 @@ int ClassHandler::_load_class(ClassData *cls) int r = ::stat(fname, &st); if (r < 0) { r = -errno; - dout(0) << __func__ << " could not stat class " << fname - << ": " << cpp_strerror(r) << dendl; + ldout(cct, 0) << __func__ << " could not stat class " << fname + << ": " << cpp_strerror(r) << dendl; } else { - dout(0) << "_load_class could not open class " << fname - << " (dlopen failed): " << dlerror() << dendl; - r = -EIO; + ldout(cct, 0) << "_load_class could not open class " << fname + << " (dlopen failed): " << dlerror() << dendl; + r = -EIO; } cls->status = ClassData::CLASS_MISSING; return r; @@ -191,19 +190,19 @@ int ClassHandler::_load_class(ClassData *cls) cls->status = ClassData::CLASS_MISSING_DEPS; return r; } - - dout(10) << "_load_class " << cls->name << " satisfied dependency " << dc->name << dendl; + + ldout(cct, 10) << "_load_class " << cls->name << " satisfied dependency " << dc->name << dendl; cls->missing_dependencies.erase(p++); } - + // initialize void (*cls_init)() = (void (*)())dlsym(cls->handle, "__cls_init"); if (cls_init) { cls->status = ClassData::CLASS_INITIALIZING; cls_init(); } - - dout(10) << "_load_class " << cls->name << " success" << dendl; + + ldout(cct, 10) << "_load_class " << cls->name << " success" << dendl; cls->status = ClassData::CLASS_OPEN; return 0; } @@ -215,10 +214,10 @@ ClassHandler::ClassData *ClassHandler::register_class(const char *cname) assert(mutex.is_locked()); ClassData *cls = _get_class(cname, false); - dout(10) << "register_class " << cname << " status " << cls->status << dendl; + ldout(cct, 10) << "register_class " << cname << " status " << cls->status << dendl; if (cls->status != ClassData::CLASS_INITIALIZING) { - dout(0) << "class " << cname << " isn't loaded; is the class registering under the wrong name?" << dendl; + ldout(cct, 0) << "class " << cname << " isn't loaded; is the class registering under the wrong name?" << dendl; return NULL; } return cls; @@ -235,11 +234,12 @@ ClassHandler::ClassMethod *ClassHandler::ClassData::register_method(const char * { /* no need for locking, called under the class_init mutex */ if (!flags) { - derr << "register_method " << name << "." << mname << " flags " << flags << " " << (void*)func - << " FAILED -- flags must be non-zero" << dendl; + lderr(handler->cct) << "register_method " << name << "." << mname + << " flags " << flags << " " << (void*)func + << " FAILED -- flags must be non-zero" << dendl; return NULL; } - dout(10) << "register_method " << name << "." << mname << " flags " << flags << " " << (void*)func << dendl; + ldout(handler->cct, 10) << "register_method " << name << "." << mname << " flags " << flags << " " << (void*)func << dendl; ClassMethod& method = methods_map[mname]; method.func = func; method.name = mname; @@ -253,7 +253,7 @@ ClassHandler::ClassMethod *ClassHandler::ClassData::register_cxx_method(const ch cls_method_cxx_call_t func) { /* no need for locking, called under the class_init mutex */ - dout(10) << "register_cxx_method " << name << "." << mname << " flags " << flags << " " << (void*)func << dendl; + ldout(handler->cct, 10) << "register_cxx_method " << name << "." << mname << " flags " << flags << " " << (void*)func << dendl; ClassMethod& method = methods_map[mname]; method.cxx_func = func; method.name = mname; diff --git a/src/osd/ClassHandler.h b/src/osd/ClassHandler.h index 9b71e97a47ac..0e1991afbecb 100644 --- a/src/osd/ClassHandler.h +++ b/src/osd/ClassHandler.h @@ -1,3 +1,5 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab #ifndef CEPH_CLASSHANDLER_H #define CEPH_CLASSHANDLER_H diff --git a/src/osd/ECBackend.cc b/src/osd/ECBackend.cc index 4789dc519d91..2d04e0773ef9 100644 --- a/src/osd/ECBackend.cc +++ b/src/osd/ECBackend.cc @@ -26,7 +26,7 @@ #include "PrimaryLogPG.h" -#define dout_context g_ceph_context +#define dout_context cct #define dout_subsys ceph_subsys_osd #define DOUT_PREFIX_ARGS this #undef dout_prefix @@ -197,8 +197,7 @@ ECBackend::ECBackend( CephContext *cct, ErasureCodeInterfaceRef ec_impl, uint64_t stripe_width) - : PGBackend(pg, store, coll, ch), - cct(cct), + : PGBackend(cct, pg, store, coll, ch), ec_impl(ec_impl), sinfo(ec_impl->get_data_chunk_count(), stripe_width) { assert((ec_impl->get_data_chunk_count() * diff --git a/src/osd/ECBackend.h b/src/osd/ECBackend.h index 7058a9ae0dc1..471cd4f745da 100644 --- a/src/osd/ECBackend.h +++ b/src/osd/ECBackend.h @@ -559,7 +559,6 @@ public: bool try_finish_rmw(); void check_ops(); - CephContext *cct; ErasureCodeInterfaceRef ec_impl; diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index c9de4531dd1f..f4d33494b692 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -149,7 +149,7 @@ #define tracepoint(...) #endif -#define dout_context g_ceph_context +#define dout_context cct #define dout_subsys ceph_subsys_osd #undef dout_prefix #define dout_prefix _prefix(_dout, whoami, get_osdmap_epoch()) @@ -549,14 +549,14 @@ void OSDService::agent_entry() << ", top is " << level << " with pgs " << top.size() << ", ops " << agent_ops << "/" - << g_conf->osd_agent_max_ops + << cct->_conf->osd_agent_max_ops << (agent_active ? " active" : " NOT ACTIVE") << dendl; dout(20) << __func__ << " oids " << agent_oids << dendl; - int max = g_conf->osd_agent_max_ops - agent_ops; + int max = cct->_conf->osd_agent_max_ops - agent_ops; int agent_flush_quota = max; if (!flush_mode_high_count) - agent_flush_quota = g_conf->osd_agent_max_low_ops - agent_ops; + agent_flush_quota = cct->_conf->osd_agent_max_low_ops - agent_ops; if (agent_flush_quota <= 0 || top.empty() || !agent_active) { agent_cond.Wait(agent_lock); continue; @@ -573,14 +573,14 @@ void OSDService::agent_entry() agent_lock.Unlock(); if (!pg->agent_work(max, agent_flush_quota)) { dout(10) << __func__ << " " << pg->get_pgid() - << " no agent_work, delay for " << g_conf->osd_agent_delay_time + << " no agent_work, delay for " << cct->_conf->osd_agent_delay_time << " seconds" << dendl; osd->logger->inc(l_osd_tier_delay); // Queue a timer to call agent_choose_mode for this pg in 5 seconds agent_timer_lock.Lock(); Context *cb = new AgentTimeoutCB(pg); - agent_timer.add_event_after(g_conf->osd_agent_delay_time, cb); + agent_timer.add_event_after(cct->_conf->osd_agent_delay_time, cb); agent_timer_lock.Unlock(); } agent_lock.Lock(); @@ -618,8 +618,8 @@ void OSDService::promote_throttle_recalibrate() last_recalibrate = now; unsigned prob = promote_probability_millis; - uint64_t target_obj_sec = g_conf->osd_tier_promote_max_objects_sec; - uint64_t target_bytes_sec = g_conf->osd_tier_promote_max_bytes_sec; + uint64_t target_obj_sec = cct->_conf->osd_tier_promote_max_objects_sec; + uint64_t target_bytes_sec = cct->_conf->osd_tier_promote_max_bytes_sec; unsigned min_prob = 1; @@ -1494,7 +1494,7 @@ int OSD::mkfs(CephContext *cct, ObjectStore *store, const string &dev, goto free_store; } - store->set_cache_shards(g_conf->osd_op_num_shards); + store->set_cache_shards(cct->_conf->osd_op_num_shards); ret = store->mount(); if (ret) { @@ -1718,6 +1718,7 @@ OSD::OSD(CephContext *cct_, ObjectStore *store_, &command_tp), replay_queue_lock("OSD::replay_queue_lock"), remove_wq( + cct, store, cct->_conf->osd_remove_thread_timeout, cct->_conf->osd_remove_thread_suicide_timeout, @@ -1984,8 +1985,8 @@ int OSD::enable_disable_fuse(bool stop) { #ifdef HAVE_LIBFUSE int r; - string mntpath = g_conf->osd_data + "/fuse"; - if (fuse_store && (stop || !g_conf->osd_objectstore_fuse)) { + string mntpath = cct->_conf->osd_data + "/fuse"; + if (fuse_store && (stop || !cct->_conf->osd_objectstore_fuse)) { dout(1) << __func__ << " disabling" << dendl; fuse_store->stop(); delete fuse_store; @@ -1999,7 +2000,7 @@ int OSD::enable_disable_fuse(bool stop) } return 0; } - if (!fuse_store && g_conf->osd_objectstore_fuse) { + if (!fuse_store && cct->_conf->osd_objectstore_fuse) { dout(1) << __func__ << " enabling" << dendl; r = ::mkdir(mntpath.c_str(), 0700); if (r < 0) @@ -2038,7 +2039,7 @@ int OSD::init() << (journal_path.empty() ? "(no journal)" : journal_path) << dendl; assert(store); // call pre_init() first! - store->set_cache_shards(g_conf->osd_op_num_shards); + store->set_cache_shards(cct->_conf->osd_op_num_shards); int r = store->mount(); if (r < 0) { @@ -2065,19 +2066,19 @@ int OSD::init() // sanity check long object name handling { hobject_t l; - l.oid.name = string(g_conf->osd_max_object_name_len, 'n'); - l.set_key(string(g_conf->osd_max_object_name_len, 'k')); - l.nspace = string(g_conf->osd_max_object_namespace_len, 's'); + l.oid.name = string(cct->_conf->osd_max_object_name_len, 'n'); + l.set_key(string(cct->_conf->osd_max_object_name_len, 'k')); + l.nspace = string(cct->_conf->osd_max_object_namespace_len, 's'); r = store->validate_hobject_key(l); if (r < 0) { derr << "backend (" << store->get_type() << ") is unable to support max " << "object name[space] len" << dendl; derr << " osd max object name len = " - << g_conf->osd_max_object_name_len << dendl; + << cct->_conf->osd_max_object_name_len << dendl; derr << " osd max object namespace len = " - << g_conf->osd_max_object_namespace_len << dendl; + << cct->_conf->osd_max_object_namespace_len << dendl; derr << cpp_strerror(r) << dendl; - if (g_conf->osd_check_max_object_name_len_on_startup) { + if (cct->_conf->osd_check_max_object_name_len_on_startup) { goto out; } derr << "osd_check_max_object_name_len_on_startup = false, starting anyway" @@ -2832,7 +2833,7 @@ int OSD::shutdown() dout(10) << "syncing store" << dendl; enable_disable_fuse(true); - if (g_conf->osd_journal_flush_on_shutdown) { + if (cct->_conf->osd_journal_flush_on_shutdown) { dout(10) << "flushing journal" << dendl; store->flush_journal(); } @@ -2865,14 +2866,14 @@ int OSD::shutdown() int OSD::update_crush_location() { - if (!g_conf->osd_crush_update_on_start) { + if (!cct->_conf->osd_crush_update_on_start) { dout(10) << __func__ << " osd_crush_update_on_start = false" << dendl; return 0; } char weight[32]; - if (g_conf->osd_crush_initial_weight >= 0) { - snprintf(weight, sizeof(weight), "%.4lf", g_conf->osd_crush_initial_weight); + if (cct->_conf->osd_crush_initial_weight >= 0) { + snprintf(weight, sizeof(weight), "%.4lf", cct->_conf->osd_crush_initial_weight); } else { struct store_statfs_t st; int r = store->statfs(&st); @@ -3023,7 +3024,9 @@ void OSD::clear_temp_objects() } } -void OSD::recursive_remove_collection(ObjectStore *store, spg_t pgid, coll_t tmp) +void OSD::recursive_remove_collection(CephContext* cct, + ObjectStore *store, spg_t pgid, + coll_t tmp) { OSDriver driver( store, @@ -3033,7 +3036,7 @@ void OSD::recursive_remove_collection(ObjectStore *store, spg_t pgid, coll_t tmp ceph::shared_ptr osr (std::make_shared< ObjectStore::Sequencer>("rm")); ObjectStore::Transaction t; - SnapMapper mapper(&driver, 0, 0, 0, pgid.shard); + SnapMapper mapper(cct, &driver, 0, 0, 0, pgid.shard); vector objects; store->collection_list(tmp, ghobject_t(), ghobject_t::get_max(), true, @@ -3049,7 +3052,7 @@ void OSD::recursive_remove_collection(ObjectStore *store, spg_t pgid, coll_t tmp if (r != 0 && r != -ENOENT) ceph_abort(); t.remove(tmp, *p); - if (removed > g_conf->osd_target_transaction_size) { + if (removed > cct->_conf->osd_target_transaction_size) { int r = store->apply_transaction(osr.get(), std::move(t)); assert(r == 0); t = ObjectStore::Transaction(); @@ -3078,7 +3081,7 @@ PGPool OSD::_get_pool(int id, OSDMapRef createmap) ceph_abort(); } - PGPool p = PGPool(createmap, id); + PGPool p = PGPool(cct, createmap, id); dout(10) << "_get_pool " << p.id << dendl; return p; @@ -3310,7 +3313,7 @@ void OSD::load_pgs() if (it->is_temp(&pgid) || (it->is_pg(&pgid) && PG::_has_removal_flag(store, pgid))) { dout(10) << "load_pgs " << *it << " clearing temp" << dendl; - recursive_remove_collection(store, pgid, *it); + recursive_remove_collection(cct, store, pgid, *it); continue; } @@ -4422,7 +4425,7 @@ void OSD::tick_without_osd_lock() bool report = false; utime_t now = ceph_clock_now(); pg_stat_queue_lock.Lock(); - double backoff = stats_ack_timeout / g_conf->osd_mon_ack_timeout; + double backoff = stats_ack_timeout / cct->_conf->osd_mon_ack_timeout; double adjusted_min = cct->_conf->osd_mon_report_interval_min * backoff; // note: we shouldn't adjust max because it must remain < the // mon's mon_osd_report_timeout (which defaults to 1.5x our @@ -4437,8 +4440,8 @@ void OSD::tick_without_osd_lock() last_pg_stats_ack = now; // reset clock last_pg_stats_sent = utime_t(); stats_ack_timeout = - MAX(g_conf->osd_mon_ack_timeout, - stats_ack_timeout * g_conf->osd_stats_ack_timeout_factor); + MAX(cct->_conf->osd_mon_ack_timeout, + stats_ack_timeout * cct->_conf->osd_stats_ack_timeout_factor); outstanding_pg_stats.clear(); } if (now - last_pg_stats_sent > max) { @@ -4790,7 +4793,7 @@ void OSD::RemoveWQ::_process( ObjectStore::Transaction t; PGLog::clear_info_log(pg->info.pgid, &t); - if (g_conf->osd_inject_failure_on_pg_removal) { + if (cct->_conf->osd_inject_failure_on_pg_removal) { generic_derr << "osd_inject_failure_on_pg_removal" << dendl; exit(1); } @@ -5109,10 +5112,10 @@ void OSD::_collect_metadata(map *pm) (*pm)["hb_back_addr"] = stringify(hb_back_server_messenger->get_myaddr()); // backend - (*pm)["osd_objectstore"] = g_conf->osd_objectstore; + (*pm)["osd_objectstore"] = cct->_conf->osd_objectstore; store->collect_metadata(pm); - collect_sys_info(pm, g_ceph_context); + collect_sys_info(pm, cct); dout(10) << __func__ << " " << *pm << dendl; } @@ -5319,8 +5322,8 @@ void OSD::handle_pg_stats_ack(MPGStatsAck *ack) // decay timeout slowly (analogous to TCP) stats_ack_timeout = - MAX(g_conf->osd_mon_ack_timeout, - stats_ack_timeout * g_conf->osd_stats_ack_timeout_decay); + MAX(cct->_conf->osd_mon_ack_timeout, + stats_ack_timeout * cct->_conf->osd_stats_ack_timeout_decay); dout(20) << __func__ << " timeout now " << stats_ack_timeout << dendl; if (ack->get_tid() > pg_stat_tid_flushed) { @@ -5671,14 +5674,14 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector& cmd, buffe ceph::shared_ptr osr (std::make_shared< ObjectStore::Sequencer>("bench")); - uint32_t duration = g_conf->osd_bench_duration; + uint32_t duration = cct->_conf->osd_bench_duration; - if (bsize > (int64_t) g_conf->osd_bench_max_block_size) { + if (bsize > (int64_t) cct->_conf->osd_bench_max_block_size) { // let us limit the block size because the next checks rely on it // having a sane value. If we allow any block size to be set things // can still go sideways. ss << "block 'size' values are capped at " - << prettybyte_t(g_conf->osd_bench_max_block_size) << ". If you wish to use" + << prettybyte_t(cct->_conf->osd_bench_max_block_size) << ". If you wish to use" << " a higher value, please adjust 'osd_bench_max_block_size'"; r = -EINVAL; goto out; @@ -5688,11 +5691,11 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector& cmd, buffe // IOPS and duration, so that the OSD doesn't get hung up on this, // preventing timeouts from going off int64_t max_count = - bsize * duration * g_conf->osd_bench_small_size_max_iops; + bsize * duration * cct->_conf->osd_bench_small_size_max_iops; if (count > max_count) { ss << "'count' values greater than " << max_count << " for a block size of " << prettybyte_t(bsize) << ", assuming " - << g_conf->osd_bench_small_size_max_iops << " IOPS," + << cct->_conf->osd_bench_small_size_max_iops << " IOPS," << " for " << duration << " seconds," << " can cause ill effects on osd. " << " Please adjust 'osd_bench_small_size_max_iops' with a higher" @@ -5711,11 +5714,11 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector& cmd, buffe // way too big. Given we already check how big the block size // is, it's safe to assume everything will check out. int64_t max_count = - g_conf->osd_bench_large_size_max_throughput * duration; + cct->_conf->osd_bench_large_size_max_throughput * duration; if (count > max_count) { ss << "'count' values greater than " << max_count << " for a block size of " << prettybyte_t(bsize) << ", assuming " - << prettybyte_t(g_conf->osd_bench_large_size_max_throughput) << "/s," + << prettybyte_t(cct->_conf->osd_bench_large_size_max_throughput) << "/s," << " for " << duration << " seconds," << " can cause ill effects on osd. " << " Please adjust 'osd_bench_large_size_max_throughput'" @@ -6524,24 +6527,26 @@ bool OSD::scrub_random_backoff() return false; } -OSDService::ScrubJob::ScrubJob(const spg_t& pg, const utime_t& timestamp, +OSDService::ScrubJob::ScrubJob(CephContext* cct, + const spg_t& pg, const utime_t& timestamp, double pool_scrub_min_interval, double pool_scrub_max_interval, bool must) - : pgid(pg), + : cct(cct), + pgid(pg), sched_time(timestamp), deadline(timestamp) { // if not explicitly requested, postpone the scrub with a random delay if (!must) { double scrub_min_interval = pool_scrub_min_interval > 0 ? - pool_scrub_min_interval : g_conf->osd_scrub_min_interval; + pool_scrub_min_interval : cct->_conf->osd_scrub_min_interval; double scrub_max_interval = pool_scrub_max_interval > 0 ? - pool_scrub_max_interval : g_conf->osd_scrub_max_interval; + pool_scrub_max_interval : cct->_conf->osd_scrub_max_interval; sched_time += scrub_min_interval; double r = rand() / (double)RAND_MAX; sched_time += - scrub_min_interval * g_conf->osd_scrub_interval_randomize_ratio * r; + scrub_min_interval * cct->_conf->osd_scrub_interval_randomize_ratio * r; deadline += scrub_max_interval; } } @@ -6925,8 +6930,8 @@ void OSD::handle_osd_map(MOSDMap *m) o->encode(fbl, inc.encode_features | CEPH_FEATURE_RESERVED); bool injected_failure = false; - if (g_conf->osd_inject_bad_map_crc_probability > 0 && - (rand() % 10000) < g_conf->osd_inject_bad_map_crc_probability*10000.0) { + if (cct->_conf->osd_inject_bad_map_crc_probability > 0 && + (rand() % 10000) < cct->_conf->osd_inject_bad_map_crc_probability*10000.0) { derr << __func__ << " injecting map crc failure" << dendl; injected_failure = true; } @@ -7153,17 +7158,17 @@ void OSD::_committed_osd_maps(epoch_t first, epoch_t last, MOSDMap *m) //add markdown log utime_t now = ceph_clock_now(); - utime_t grace = utime_t(g_conf->osd_max_markdown_period, 0); + utime_t grace = utime_t(cct->_conf->osd_max_markdown_period, 0); osd_markdown_log.push_back(now); //clear all out-of-date log while (!osd_markdown_log.empty() && osd_markdown_log.front() + grace < now) osd_markdown_log.pop_front(); - if ((int)osd_markdown_log.size() > g_conf->osd_max_markdown_count) { + if ((int)osd_markdown_log.size() > cct->_conf->osd_max_markdown_count) { dout(0) << __func__ << " marked down " << osd_markdown_log.size() << " > osd_max_markdown_count " - << g_conf->osd_max_markdown_count + << cct->_conf->osd_max_markdown_count << " in last " << grace << " seconds, shutting down" << dendl; do_restart = false; @@ -7339,9 +7344,9 @@ bool OSD::advance_pg( epoch_t min_epoch = service.get_min_pg_epoch(); epoch_t max; if (min_epoch) { - max = min_epoch + g_conf->osd_map_max_advance; + max = min_epoch + cct->_conf->osd_map_max_advance; } else { - max = next_epoch + g_conf->osd_map_max_advance; + max = next_epoch + cct->_conf->osd_map_max_advance; } for (; @@ -7352,7 +7357,7 @@ bool OSD::advance_pg( dout(20) << __func__ << " missing map " << next_epoch << dendl; // make sure max is bumped up so that we can get past any // gap in maps - max = MAX(max, next_epoch + g_conf->osd_map_max_advance); + max = MAX(max, next_epoch + cct->_conf->osd_map_max_advance); continue; } @@ -8532,11 +8537,11 @@ void OSD::do_recovery( ThreadPool::TPHandle &handle) { uint64_t started = 0; - if (g_conf->osd_recovery_sleep > 0) { + if (cct->_conf->osd_recovery_sleep > 0) { handle.suspend_tp_timeout(); pg->unlock(); utime_t t; - t.set_from_double(g_conf->osd_recovery_sleep); + t.set_from_double(cct->_conf->osd_recovery_sleep); t.sleep(); dout(20) << __func__ << " slept for " << t << dendl; pg->lock(); @@ -8762,7 +8767,7 @@ void OSD::handle_op(OpRequestRef& op, OSDMapRef& osdmap) } // ok, we didn't have the PG. - if (!g_conf->osd_debug_misdirected_ops) { + if (!cct->_conf->osd_debug_misdirected_ops) { return; } // let's see if it's our fault or the client's. note that this might @@ -9255,7 +9260,7 @@ void OSD::update_log_config() uuid_d fsid; string host; - if (parse_log_client_options(g_ceph_context, log_to_monitors, log_to_syslog, + if (parse_log_client_options(cct, log_to_monitors, log_to_syslog, log_channel, log_prio, log_to_graylog, log_to_graylog_host, log_to_graylog_port, fsid, host) == 0) @@ -9269,15 +9274,15 @@ void OSD::update_log_config() void OSD::check_config() { // some sanity checks - if (g_conf->osd_map_cache_size <= g_conf->osd_map_max_advance + 2) { - clog->warn() << "osd_map_cache_size (" << g_conf->osd_map_cache_size << ")" + if (cct->_conf->osd_map_cache_size <= cct->_conf->osd_map_max_advance + 2) { + clog->warn() << "osd_map_cache_size (" << cct->_conf->osd_map_cache_size << ")" << " is not > osd_map_max_advance (" - << g_conf->osd_map_max_advance << ")"; + << cct->_conf->osd_map_max_advance << ")"; } - if (g_conf->osd_map_cache_size <= (int)g_conf->osd_pg_epoch_persisted_max_stale + 2) { - clog->warn() << "osd_map_cache_size (" << g_conf->osd_map_cache_size << ")" - << " is not > osd_pg_epoch_persisted_max_stale (" - << g_conf->osd_pg_epoch_persisted_max_stale << ")"; + if (cct->_conf->osd_map_cache_size <= (int)cct->_conf->osd_pg_epoch_persisted_max_stale + 2) { + clog->warn() << "osd_map_cache_size (" << cct->_conf->osd_map_cache_size << ")" + << " is not > osd_pg_epoch_persisted_max_stale (" + << cct->_conf->osd_pg_epoch_persisted_max_stale << ")"; } } diff --git a/src/osd/OSD.h b/src/osd/OSD.h index d5c19ff3b457..7e089c9868be 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -632,6 +632,7 @@ private: public: struct ScrubJob { + CephContext* cct; /// pg to be scrubbed spg_t pgid; /// a time scheduled for scrub. but the scrub could be delayed if system @@ -640,7 +641,8 @@ public: /// the hard upper bound of scrub time utime_t deadline; ScrubJob() {} - explicit ScrubJob(const spg_t& pg, const utime_t& timestamp, + explicit ScrubJob(CephContext* cct, const spg_t& pg, + const utime_t& timestamp, double pool_scrub_min_interval = 0, double pool_scrub_max_interval = 0, bool must = true); /// order the jobs by sched_time @@ -651,7 +653,7 @@ public: /// @returns the scrub_reg_stamp used for unregister the scrub job utime_t reg_pg_scrub(spg_t pgid, utime_t t, double pool_scrub_min_interval, double pool_scrub_max_interval, bool must) { - ScrubJob scrub(pgid, t, pool_scrub_min_interval, pool_scrub_max_interval, + ScrubJob scrub(cct, pgid, t, pool_scrub_min_interval, pool_scrub_max_interval, must); Mutex::Locker l(sched_scrub_lock); sched_scrub_pg.insert(scrub); @@ -659,7 +661,7 @@ public: } void unreg_pg_scrub(spg_t pgid, utime_t t) { Mutex::Locker l(sched_scrub_lock); - size_t removed = sched_scrub_pg.erase(ScrubJob(pgid, t)); + size_t removed = sched_scrub_pg.erase(ScrubJob(cct, pgid, t)); assert(removed); } bool first_scrub_stamp(ScrubJob *out) { @@ -1273,7 +1275,8 @@ public: hobject_t oid(sobject_t("infos", CEPH_NOSNAP)); return ghobject_t(oid); } - static void recursive_remove_collection(ObjectStore *store, + static void recursive_remove_collection(CephContext* cct, + ObjectStore *store, spg_t pgid, coll_t tmp); @@ -1425,7 +1428,7 @@ public: explicit Session(CephContext *cct) : RefCountedObject(cct), - auid(-1), con(0), + auid(-1), con(0), wstate(cct), session_dispatch_lock("Session::session_dispatch_lock"), last_sent_epoch(0), received_map_epoch(0) {} @@ -2324,12 +2327,13 @@ protected: // -- removing -- struct RemoveWQ : public ThreadPool::WorkQueueVal > { + CephContext* cct; ObjectStore *&store; list > remove_queue; - RemoveWQ(ObjectStore *&o, time_t ti, time_t si, ThreadPool *tp) + RemoveWQ(CephContext* cct, ObjectStore *&o, time_t ti, time_t si, + ThreadPool *tp) : ThreadPool::WorkQueueVal >( - "OSD::RemoveWQ", ti, si, tp), - store(o) {} + "OSD::RemoveWQ", ti, si, tp), cct(cct), store(o) {} bool _empty() override { return remove_queue.empty(); diff --git a/src/osd/PG.cc b/src/osd/PG.cc index c55844f5ab57..f0e10133649e 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -65,7 +65,7 @@ #include -#define dout_context g_ceph_context +#define dout_context cct #define dout_subsys ceph_subsys_osd #undef dout_prefix #define dout_prefix _prefix(_dout, this) @@ -175,7 +175,7 @@ void PGPool::update(OSDMapRef map) newly_removed_snaps.subtract(cached_removed_snaps); cached_removed_snaps.union_of(newly_removed_snaps); } else { - lgeneric_subdout(g_ceph_context, osd, 0) << __func__ + lgeneric_subdout(cct, osd, 0) << __func__ << " cached_removed_snaps shrank from " << cached_removed_snaps << " to " << newly_removed_snaps << dendl; cached_removed_snaps = newly_removed_snaps; @@ -196,7 +196,7 @@ void PGPool::update(OSDMapRef map) newly_removed_snaps.clear(); } cached_epoch = map->get_epoch(); - lgeneric_subdout(g_ceph_context, osd, 20) + lgeneric_subdout(cct, osd, 20) << "PGPool::update cached_removed_snaps " << cached_removed_snaps << " newly_removed_snaps " @@ -212,6 +212,7 @@ PG::PG(OSDService *o, OSDMapRef curmap, cct(o->cct), osdriver(osd->store, coll_t(), OSD::make_snapmapper_oid()), snap_mapper( + cct, &osdriver, p.ps(), p.get_split_bits(curmap->get_pg_num(_pool.id)), @@ -498,7 +499,7 @@ bool PG::MissingLoc::readable_with_acting( auto missing_loc_entry = missing_loc.find(hoid); if (missing_loc_entry == missing_loc.end()) return false; const set &locs = missing_loc_entry->second; - dout(10) << __func__ << ": locs:" << locs << dendl; + ldout(pg->cct, 10) << __func__ << ": locs:" << locs << dendl; set have_acting; for (set::const_iterator i = locs.begin(); i != locs.end(); @@ -512,12 +513,13 @@ bool PG::MissingLoc::readable_with_acting( void PG::MissingLoc::add_batch_sources_info( const set &sources, ThreadPool::TPHandle* handle) { - dout(10) << __func__ << ": adding sources in batch " << sources.size() << dendl; + ldout(pg->cct, 10) << __func__ << ": adding sources in batch " + << sources.size() << dendl; unsigned loop = 0; for (map::const_iterator i = needs_recovery_map.begin(); i != needs_recovery_map.end(); ++i) { - if (handle && ++loop >= g_conf->osd_loop_before_reset_tphandle) { + if (handle && ++loop >= pg->cct->_conf->osd_loop_before_reset_tphandle) { handle->reset_tp_timeout(); loop = 0; } @@ -541,52 +543,53 @@ bool PG::MissingLoc::add_source_info( ++p) { const hobject_t &soid(p->first); eversion_t need = p->second.need; - if (handle && ++loop >= g_conf->osd_loop_before_reset_tphandle) { + if (handle && ++loop >= pg->cct->_conf->osd_loop_before_reset_tphandle) { handle->reset_tp_timeout(); loop = 0; } if (oinfo.last_update < need) { - dout(10) << "search_for_missing " << soid << " " << need - << " also missing on osd." << fromosd - << " (last_update " << oinfo.last_update << " < needed " << need << ")" - << dendl; + ldout(pg->cct, 10) << "search_for_missing " << soid << " " << need + << " also missing on osd." << fromosd + << " (last_update " << oinfo.last_update + << " < needed " << need << ")" << dendl; continue; } if (!oinfo.last_backfill.is_max() && oinfo.last_backfill_bitwise != sort_bitwise) { - dout(10) << "search_for_missing " << soid << " " << need - << " also missing on osd." << fromosd - << " (last_backfill " << oinfo.last_backfill - << " but with wrong sort order)" - << dendl; + ldout(pg->cct, 10) << "search_for_missing " << soid << " " << need + << " also missing on osd." << fromosd + << " (last_backfill " << oinfo.last_backfill + << " but with wrong sort order)" + << dendl; continue; } if (cmp(p->first, oinfo.last_backfill, sort_bitwise) >= 0) { // FIXME: this is _probably_ true, although it could conceivably // be in the undefined region! Hmm! - dout(10) << "search_for_missing " << soid << " " << need - << " also missing on osd." << fromosd - << " (past last_backfill " << oinfo.last_backfill << ")" - << dendl; + ldout(pg->cct, 10) << "search_for_missing " << soid << " " << need + << " also missing on osd." << fromosd + << " (past last_backfill " << oinfo.last_backfill + << ")" << dendl; continue; } if (oinfo.last_complete < need) { if (omissing.is_missing(soid)) { - dout(10) << "search_for_missing " << soid << " " << need - << " also missing on osd." << fromosd << dendl; + ldout(pg->cct, 10) << "search_for_missing " << soid << " " << need + << " also missing on osd." << fromosd << dendl; continue; } } - dout(10) << "search_for_missing " << soid << " " << need - << " is on osd." << fromosd << dendl; + ldout(pg->cct, 10) << "search_for_missing " << soid << " " << need + << " is on osd." << fromosd << dendl; missing_loc[soid].insert(fromosd); missing_loc_sources.insert(fromosd); found_missing = true; } - dout(20) << "needs_recovery_map missing " << needs_recovery_map << dendl; + ldout(pg->cct, 20) << "needs_recovery_map missing " << needs_recovery_map + << dendl; return found_missing; } @@ -911,6 +914,7 @@ void PG::build_prior(std::unique_ptr &prior_set) } prior_set.reset( new PriorSet( + cct, pool.info.ec_pool(), get_pgbackend()->get_is_recoverable_predicate(), *get_osdmap(), @@ -2626,7 +2630,7 @@ void PG::_update_blocked_by() { // set a max on the number of blocking peers we report. if we go // over, report a random subset. keep the result sorted. - unsigned keep = MIN(blocked_by.size(), g_conf->osd_max_pg_blocked_by); + unsigned keep = MIN(blocked_by.size(), cct->_conf->osd_max_pg_blocked_by); unsigned skip = blocked_by.size() - keep; info.stats.blocked_by.clear(); info.stats.blocked_by.resize(keep); @@ -2672,7 +2676,7 @@ void PG::publish_stats_to_osd() bool publish = false; utime_t cutoff = now; - cutoff -= g_conf->osd_pg_stat_report_interval_max; + cutoff -= cct->_conf->osd_pg_stat_report_interval_max; if (pg_stats_publish_valid && info.stats == pg_stats_publish && info.stats.last_fresh > cutoff) { dout(15) << "publish_stats_to_osd " << pg_stats_publish.reported_epoch @@ -2834,7 +2838,8 @@ void PG::upgrade(ObjectStore *store) #pragma GCC diagnostic pop #pragma GCC diagnostic warning "-Wpragmas" -int PG::_prepare_write_info(map *km, +int PG::_prepare_write_info(CephContext* cct, + map *km, epoch_t epoch, pg_info_t &info, pg_info_t &last_written_info, map &past_intervals, @@ -2933,12 +2938,12 @@ void PG::prepare_write_info(map *km) unstable_stats.clear(); bool need_update_epoch = last_epoch < get_osdmap()->get_epoch(); - int ret = _prepare_write_info(km, get_osdmap()->get_epoch(), + int ret = _prepare_write_info(cct, km, get_osdmap()->get_epoch(), info, last_written_info, past_intervals, dirty_big_info, need_update_epoch, - g_conf->osd_fast_info, + cct->_conf->osd_fast_info, osd->logger); assert(ret == 0); if (need_update_epoch) @@ -3114,7 +3119,7 @@ void PG::append_log( auto last = logv.rbegin(); if (is_primary() && last != logv.rend()) { projected_log.skip_can_rollback_to_to_head(); - projected_log.trim(last->version, nullptr); + projected_log.trim(cct, last->version, nullptr); } if (transaction_applied && roll_forward_to > pg_log.get_can_rollback_to()) { @@ -3535,7 +3540,7 @@ void PG::reg_next_scrub() utime_t reg_stamp; if (scrubber.must_scrub || - (info.stats.stats_invalid && g_conf->osd_scrub_invalid_stats)) { + (info.stats.stats_invalid && cct->_conf->osd_scrub_invalid_stats)) { reg_stamp = ceph_clock_now(); } else { reg_stamp = info.history.last_scrub_stamp; @@ -4028,13 +4033,13 @@ void PG::replica_scrub( */ void PG::scrub(epoch_t queued, ThreadPool::TPHandle &handle) { - if (g_conf->osd_scrub_sleep > 0 && + if (cct->_conf->osd_scrub_sleep > 0 && (scrubber.state == PG::Scrubber::NEW_CHUNK || scrubber.state == PG::Scrubber::INACTIVE)) { dout(20) << __func__ << " state is INACTIVE|NEW_CHUNK, sleeping" << dendl; unlock(); utime_t t; - t.set_from_double(g_conf->osd_scrub_sleep); + t.set_from_double(cct->_conf->osd_scrub_sleep); handle.suspend_tp_timeout(); t.sleep(); handle.reset_tp_timeout(); @@ -5267,7 +5272,7 @@ void PG::on_new_interval() do_sort_bitwise = osdmap->test_flag(CEPH_OSDMAP_SORTBITWISE); if (do_sort_bitwise) { assert(get_min_upacting_features() & CEPH_FEATURE_OSD_BITWISE_HOBJ_SORT); - if (g_conf->osd_debug_randomize_hobject_sort_order) { + if (cct->_conf->osd_debug_randomize_hobject_sort_order) { // randomly use a nibblewise sort (when we otherwise might have // done bitwise) based on some *deterministic* function such that // all peers/osds will agree. @@ -5410,7 +5415,7 @@ ostream& operator<<(ostream& out, const PG& pg) bool PG::can_discard_op(OpRequestRef& op) { MOSDOp *m = static_cast(op->get_req()); - if (g_conf->osd_discard_disconnected_ops && OSD::op_is_discardable(m)) { + if (cct->_conf->osd_discard_disconnected_ops && OSD::op_is_discardable(m)) { dout(20) << " discard " << *m << dendl; return true; } @@ -5863,7 +5868,8 @@ PG::RecoveryState::Started::Started(my_context ctx) boost::statechart::result PG::RecoveryState::Started::react(const IntervalFlush&) { - dout(10) << "Ending blocked outgoing recovery messages" << dendl; + PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 10) << "Ending blocked outgoing recovery messages" << dendl; context< RecoveryMachine >().pg->recovery_state.end_block_outgoing(); return discard_event(); } @@ -5880,8 +5886,8 @@ PG::RecoveryState::Started::react(const FlushedEvt&) boost::statechart::result PG::RecoveryState::Started::react(const AdvMap& advmap) { - dout(10) << "Started advmap" << dendl; PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 10) << "Started advmap" << dendl; pg->check_full_transition(advmap.lastmap, advmap.osdmap); if (pg->should_restart_peering( advmap.up_primary, @@ -5890,7 +5896,8 @@ boost::statechart::result PG::RecoveryState::Started::react(const AdvMap& advmap advmap.newacting, advmap.lastmap, advmap.osdmap)) { - dout(10) << "should_restart_peering, transitioning to Reset" << dendl; + ldout(pg->cct, 10) << "should_restart_peering, transitioning to Reset" + << dendl; post_event(advmap); return transit< Reset >(); } @@ -5938,7 +5945,8 @@ PG::RecoveryState::Reset::react(const FlushedEvt&) boost::statechart::result PG::RecoveryState::Reset::react(const IntervalFlush&) { - dout(10) << "Ending blocked outgoing recovery messages" << dendl; + PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 10) << "Ending blocked outgoing recovery messages" << dendl; context< RecoveryMachine >().pg->recovery_state.end_block_outgoing(); return discard_event(); } @@ -5946,7 +5954,7 @@ PG::RecoveryState::Reset::react(const IntervalFlush&) boost::statechart::result PG::RecoveryState::Reset::react(const AdvMap& advmap) { PG *pg = context< RecoveryMachine >().pg; - dout(10) << "Reset advmap" << dendl; + ldout(pg->cct, 10) << "Reset advmap" << dendl; // make sure we have past_intervals filled in. hopefully this will happen // _before_ we are active. @@ -5961,8 +5969,8 @@ boost::statechart::result PG::RecoveryState::Reset::react(const AdvMap& advmap) advmap.newacting, advmap.lastmap, advmap.osdmap)) { - dout(10) << "should restart peering, calling start_peering_interval again" - << dendl; + ldout(pg->cct, 10) << "should restart peering, calling start_peering_interval again" + << dendl; pg->start_peering_interval( advmap.lastmap, advmap.newup, advmap.up_primary, @@ -6019,10 +6027,10 @@ PG::RecoveryState::Start::Start(my_context ctx) PG *pg = context< RecoveryMachine >().pg; if (pg->is_primary()) { - dout(1) << "transitioning to Primary" << dendl; + ldout(pg->cct, 1) << "transitioning to Primary" << dendl; post_event(MakePrimary()); } else { //is_stray - dout(1) << "transitioning to Stray" << dendl; + ldout(pg->cct, 1) << "transitioning to Stray" << dendl; post_event(MakeStray()); } } @@ -6066,12 +6074,12 @@ PG::RecoveryState::Primary::Primary(my_context ctx) boost::statechart::result PG::RecoveryState::Primary::react(const MNotifyRec& notevt) { - dout(7) << "handle_pg_notify from osd." << notevt.from << dendl; PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 7) << "handle_pg_notify from osd." << notevt.from << dendl; if (pg->peer_info.count(notevt.from) && pg->peer_info[notevt.from].last_update == notevt.notify.info.last_update) { - dout(10) << *pg << " got dup osd." << notevt.from << " info " << notevt.notify.info - << ", identical to ours" << dendl; + ldout(pg->cct, 10) << *pg << " got dup osd." << notevt.from << " info " + << notevt.notify.info << ", identical to ours" << dendl; } else { pg->proc_replica_info( notevt.from, notevt.notify.info, notevt.notify.epoch_sent); @@ -6081,8 +6089,8 @@ boost::statechart::result PG::RecoveryState::Primary::react(const MNotifyRec& no boost::statechart::result PG::RecoveryState::Primary::react(const ActMap&) { - dout(7) << "handle ActMap primary" << dendl; PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 7) << "handle ActMap primary" << dendl; pg->publish_stats_to_osd(); pg->take_waiters(); return discard_event(); @@ -6117,9 +6125,9 @@ PG::RecoveryState::Peering::Peering(my_context ctx) boost::statechart::result PG::RecoveryState::Peering::react(const AdvMap& advmap) { PG *pg = context< RecoveryMachine >().pg; - dout(10) << "Peering advmap" << dendl; + ldout(pg->cct, 10) << "Peering advmap" << dendl; if (prior_set.get()->affected_by_map(advmap.osdmap, pg)) { - dout(1) << "Peering, affected_by_map, going to Reset" << dendl; + ldout(pg->cct, 1) << "Peering, affected_by_map, going to Reset" << dendl; post_event(advmap); return transit< Reset >(); } @@ -6190,9 +6198,9 @@ boost::statechart::result PG::RecoveryState::Peering::react(const QueryState& q) void PG::RecoveryState::Peering::exit() { - dout(10) << "Leaving Peering" << dendl; - context< RecoveryMachine >().log_exit(state_name, enter_time); PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 10) << "Leaving Peering" << dendl; + context< RecoveryMachine >().log_exit(state_name, enter_time); pg->state_clear(PG_STATE_PEERING); pg->clear_probe_targets(); @@ -6451,21 +6459,22 @@ PG::RecoveryState::RepWaitBackfillReserved::RepWaitBackfillReserved(my_context c context< RecoveryMachine >().log_enter(state_name); } -boost::statechart::result +boost::statechart::result PG::RecoveryState::RepNotRecovering::react(const RequestBackfillPrio &evt) { PG *pg = context< RecoveryMachine >().pg; double ratio, max_ratio; - if (g_conf->osd_debug_reject_backfill_probability > 0 && - (rand()%1000 < (g_conf->osd_debug_reject_backfill_probability*1000.0))) { - dout(10) << "backfill reservation rejected: failure injection" << dendl; + if (pg->cct->_conf->osd_debug_reject_backfill_probability > 0 && + (rand()%1000 < (pg->cct->_conf->osd_debug_reject_backfill_probability*1000.0))) { + ldout(pg->cct, 10) << "backfill reservation rejected: failure injection" + << dendl; post_event(RemoteReservationRejected()); } else if (pg->osd->too_full_for_backfill(&ratio, &max_ratio) && !pg->cct->_conf->osd_debug_skip_full_check_in_backfill_reservation) { - dout(10) << "backfill reservation rejected: full ratio is " - << ratio << ", which is greater than max allowed ratio " - << max_ratio << dendl; + ldout(pg->cct, 10) << "backfill reservation rejected: full ratio is " + << ratio << ", which is greater than max allowed ratio " + << max_ratio << dendl; post_event(RemoteReservationRejected()); } else { pg->osd->remote_reserver.request_reservation( @@ -6491,18 +6500,18 @@ PG::RecoveryState::RepWaitBackfillReserved::react(const RemoteBackfillReserved & PG *pg = context< RecoveryMachine >().pg; double ratio, max_ratio; - if (g_conf->osd_debug_reject_backfill_probability > 0 && - (rand()%1000 < (g_conf->osd_debug_reject_backfill_probability*1000.0))) { - dout(10) << "backfill reservation rejected after reservation: " - << "failure injection" << dendl; + if (pg->cct->_conf->osd_debug_reject_backfill_probability > 0 && + (rand()%1000 < (pg->cct->_conf->osd_debug_reject_backfill_probability*1000.0))) { + ldout(pg->cct, 10) << "backfill reservation rejected after reservation: " + << "failure injection" << dendl; pg->osd->remote_reserver.cancel_reservation(pg->info.pgid); post_event(RemoteReservationRejected()); return discard_event(); } else if (pg->osd->too_full_for_backfill(&ratio, &max_ratio) && !pg->cct->_conf->osd_debug_skip_full_check_in_backfill_reservation) { - dout(10) << "backfill reservation rejected after reservation: full ratio is " - << ratio << ", which is greater than max allowed ratio " - << max_ratio << dendl; + ldout(pg->cct, 10) << "backfill reservation rejected after reservation: full ratio is " + << ratio << ", which is greater than max allowed ratio " + << max_ratio << dendl; pg->osd->remote_reserver.cancel_reservation(pg->info.pgid); post_event(RemoteReservationRejected()); return discard_event(); @@ -6798,7 +6807,7 @@ PG::RecoveryState::Active::Active(my_context ctx) assert(!pg->backfill_reserving); assert(!pg->backfill_reserved); assert(pg->is_primary()); - dout(10) << "In Active, about to call activate" << dendl; + ldout(pg->cct, 10) << "In Active, about to call activate" << dendl; pg->start_flush( context< RecoveryMachine >().get_cur_transaction(), context< RecoveryMachine >().get_on_applied_context_list(), @@ -6820,16 +6829,16 @@ PG::RecoveryState::Active::Active(my_context ctx) } } pg->publish_stats_to_osd(); - dout(10) << "Activate Finished" << dendl; + ldout(pg->cct, 10) << "Activate Finished" << dendl; } boost::statechart::result PG::RecoveryState::Active::react(const AdvMap& advmap) { PG *pg = context< RecoveryMachine >().pg; - dout(10) << "Active advmap" << dendl; + ldout(pg->cct, 10) << "Active advmap" << dendl; if (!pg->pool.newly_removed_snaps.empty()) { pg->snap_trimq.union_of(pg->pool.newly_removed_snaps); - dout(10) << *pg << " snap_trimq now " << pg->snap_trimq << dendl; + ldout(pg->cct, 10) << *pg << " snap_trimq now " << pg->snap_trimq << dendl; pg->dirty_info = true; pg->dirty_big_info = true; } @@ -6863,8 +6872,8 @@ boost::statechart::result PG::RecoveryState::Active::react(const AdvMap& advmap) // if we haven't reported our PG stats in a long time, do so now. if (pg->info.stats.reported_epoch + pg->cct->_conf->osd_pg_stat_report_interval_max < advmap.osdmap->get_epoch()) { - dout(20) << "reporting stats to osd after " << (advmap.osdmap->get_epoch() - pg->info.stats.reported_epoch) - << " epochs" << dendl; + ldout(pg->cct, 20) << "reporting stats to osd after " << (advmap.osdmap->get_epoch() - pg->info.stats.reported_epoch) + << " epochs" << dendl; need_publish = true; } @@ -6877,7 +6886,7 @@ boost::statechart::result PG::RecoveryState::Active::react(const AdvMap& advmap) boost::statechart::result PG::RecoveryState::Active::react(const ActMap&) { PG *pg = context< RecoveryMachine >().pg; - dout(10) << "Active: handling ActMap" << dendl; + ldout(pg->cct, 10) << "Active: handling ActMap" << dendl; assert(pg->is_primary()); if (pg->have_unfound()) { @@ -6899,7 +6908,7 @@ boost::statechart::result PG::RecoveryState::Active::react(const ActMap&) } if (pg->is_active()) { - dout(10) << "Active: kicking snap trim" << dendl; + ldout(pg->cct, 10) << "Active: kicking snap trim" << dendl; pg->kick_snap_trim(); } @@ -6917,17 +6926,17 @@ boost::statechart::result PG::RecoveryState::Active::react(const MNotifyRec& not PG *pg = context< RecoveryMachine >().pg; assert(pg->is_primary()); if (pg->peer_info.count(notevt.from)) { - dout(10) << "Active: got notify from " << notevt.from - << ", already have info from that osd, ignoring" - << dendl; + ldout(pg->cct, 10) << "Active: got notify from " << notevt.from + << ", already have info from that osd, ignoring" + << dendl; } else if (pg->peer_purged.count(notevt.from)) { - dout(10) << "Active: got notify from " << notevt.from - << ", already purged that peer, ignoring" - << dendl; + ldout(pg->cct, 10) << "Active: got notify from " << notevt.from + << ", already purged that peer, ignoring" + << dendl; } else { - dout(10) << "Active: got notify from " << notevt.from - << ", calling proc_replica_info and discover_all_missing" - << dendl; + ldout(pg->cct, 10) << "Active: got notify from " << notevt.from + << ", calling proc_replica_info and discover_all_missing" + << dendl; pg->proc_replica_info( notevt.from, notevt.notify.info, notevt.notify.epoch_sent); if (pg->have_unfound()) { @@ -6947,8 +6956,8 @@ boost::statechart::result PG::RecoveryState::Active::react(const MInfoRec& infoe // may be telling us they have activated (and committed) but we can't // share that until _everyone_ does the same. if (pg->is_actingbackfill(infoevt.from)) { - dout(10) << " peer osd." << infoevt.from << " activated and committed" - << dendl; + ldout(pg->cct, 10) << " peer osd." << infoevt.from + << " activated and committed" << dendl; pg->peer_activated.insert(infoevt.from); pg->blocked_by.erase(infoevt.from.shard); pg->publish_stats_to_osd(); @@ -6961,9 +6970,9 @@ boost::statechart::result PG::RecoveryState::Active::react(const MInfoRec& infoe boost::statechart::result PG::RecoveryState::Active::react(const MLogRec& logevt) { - dout(10) << "searching osd." << logevt.from - << " log for unfound items" << dendl; PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 10) << "searching osd." << logevt.from + << " log for unfound items" << dendl; pg->proc_replica_log( *context().get_cur_transaction(), logevt.msg->info, logevt.msg->log, logevt.msg->missing, logevt.from); @@ -7109,14 +7118,14 @@ PG::RecoveryState::ReplicaActive::ReplicaActive(my_context ctx) boost::statechart::result PG::RecoveryState::ReplicaActive::react( const Activate& actevt) { - dout(10) << "In ReplicaActive, about to call activate" << dendl; PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 10) << "In ReplicaActive, about to call activate" << dendl; map > query_map; pg->activate(*context< RecoveryMachine >().get_cur_transaction(), actevt.activation_epoch, *context< RecoveryMachine >().get_on_safe_context_list(), query_map, NULL, NULL); - dout(10) << "Activate Finished" << dendl; + ldout(pg->cct, 10) << "Activate Finished" << dendl; return discard_event(); } @@ -7131,7 +7140,7 @@ boost::statechart::result PG::RecoveryState::ReplicaActive::react(const MInfoRec boost::statechart::result PG::RecoveryState::ReplicaActive::react(const MLogRec& logevt) { PG *pg = context< RecoveryMachine >().pg; - dout(10) << "received log from " << logevt.from << dendl; + ldout(pg->cct, 10) << "received log from " << logevt.from << dendl; ObjectStore::Transaction* t = context().get_cur_transaction(); pg->merge_log(*t,logevt.msg->info, logevt.msg->log, logevt.from); assert(pg->pg_log.get_head() == pg->info.last_update); @@ -7205,7 +7214,7 @@ boost::statechart::result PG::RecoveryState::Stray::react(const MLogRec& logevt) { PG *pg = context< RecoveryMachine >().pg; MOSDPGLog *msg = logevt.msg.get(); - dout(10) << "got info+log from osd." << logevt.from << " " << msg->info << " " << msg->log << dendl; + ldout(pg->cct, 10) << "got info+log from osd." << logevt.from << " " << msg->info << " " << msg->log << dendl; ObjectStore::Transaction* t = context().get_cur_transaction(); if (msg->info.last_backfill == hobject_t()) { @@ -7233,7 +7242,7 @@ boost::statechart::result PG::RecoveryState::Stray::react(const MLogRec& logevt) boost::statechart::result PG::RecoveryState::Stray::react(const MInfoRec& infoevt) { PG *pg = context< RecoveryMachine >().pg; - dout(10) << "got info from osd." << infoevt.from << " " << infoevt.info << dendl; + ldout(pg->cct, 10) << "got info from osd." << infoevt.from << " " << infoevt.info << dendl; if (pg->info.last_update > infoevt.info.last_update) { // rewind divergent log entries @@ -7335,16 +7344,16 @@ void PG::RecoveryState::GetInfo::get_infos() continue; } if (pg->peer_info.count(peer)) { - dout(10) << " have osd." << peer << " info " << pg->peer_info[peer] << dendl; + ldout(pg->cct, 10) << " have osd." << peer << " info " << pg->peer_info[peer] << dendl; continue; } if (peer_info_requested.count(peer)) { - dout(10) << " already requested info from osd." << peer << dendl; + ldout(pg->cct, 10) << " already requested info from osd." << peer << dendl; pg->blocked_by.insert(peer.osd); } else if (!pg->get_osdmap()->is_up(peer.osd)) { - dout(10) << " not querying info from down osd." << peer << dendl; + ldout(pg->cct, 10) << " not querying info from down osd." << peer << dendl; } else { - dout(10) << " querying info from osd." << peer << dendl; + ldout(pg->cct, 10) << " querying info from osd." << peer << dendl; context< RecoveryMachine >().send_query( peer, pg_query_t(pg_query_t::INFO, it->shard, pg->pg_whoami.shard, @@ -7374,7 +7383,7 @@ boost::statechart::result PG::RecoveryState::GetInfo::react(const MNotifyRec& in // we got something new ... unique_ptr &prior_set = context< Peering >().prior_set; if (old_start < pg->info.history.last_epoch_started) { - dout(10) << " last_epoch_started moved forward, rebuilding prior" << dendl; + ldout(pg->cct, 10) << " last_epoch_started moved forward, rebuilding prior" << dendl; pg->build_prior(prior_set); // filter out any osds that got dropped from the probe set from @@ -7383,7 +7392,7 @@ boost::statechart::result PG::RecoveryState::GetInfo::react(const MNotifyRec& in set::iterator p = peer_info_requested.begin(); while (p != peer_info_requested.end()) { if (prior_set->probe.count(*p) == 0) { - dout(20) << " dropping osd." << *p << " from info_requested, no longer in probe set" << dendl; + ldout(pg->cct, 20) << " dropping osd." << *p << " from info_requested, no longer in probe set" << dendl; peer_info_requested.erase(p++); } else { ++p; @@ -7391,8 +7400,8 @@ boost::statechart::result PG::RecoveryState::GetInfo::react(const MNotifyRec& in } get_infos(); } - dout(20) << "Adding osd: " << infoevt.from.osd << " peer features: " - << hex << infoevt.features << dec << dendl; + ldout(pg->cct, 20) << "Adding osd: " << infoevt.from.osd << " peer features: " + << hex << infoevt.features << dec << dendl; pg->apply_peer_features(infoevt.features); // are we done getting everything? @@ -7413,7 +7422,7 @@ boost::statechart::result PG::RecoveryState::GetInfo::react(const MNotifyRec& in if (!p->second.maybe_went_rw) continue; pg_interval_t& interval = p->second; - dout(10) << " last maybe_went_rw interval was " << interval << dendl; + ldout(pg->cct, 10) << " last maybe_went_rw interval was " << interval << dendl; OSDMapRef osdmap = pg->get_osdmap(); /* @@ -7445,16 +7454,16 @@ boost::statechart::result PG::RecoveryState::GetInfo::react(const MNotifyRec& in } } if (!any_up_complete_now && any_down_now) { - dout(10) << " no osds up+complete from interval " << interval << dendl; + ldout(pg->cct, 10) << " no osds up+complete from interval " << interval << dendl; post_event(IsDown()); return discard_event(); } break; } } - dout(20) << "Common peer features: " << hex << pg->get_min_peer_features() << dec << dendl; - dout(20) << "Common acting features: " << hex << pg->get_min_acting_features() << dec << dendl; - dout(20) << "Common upacting features: " << hex << pg->get_min_upacting_features() << dec << dendl; + ldout(pg->cct, 20) << "Common peer features: " << hex << pg->get_min_peer_features() << dec << dendl; + ldout(pg->cct, 20) << "Common acting features: " << hex << pg->get_min_acting_features() << dec << dendl; + ldout(pg->cct, 20) << "Common upacting features: " << hex << pg->get_min_upacting_features() << dec << dendl; post_event(GotInfo()); } } @@ -7529,7 +7538,7 @@ PG::RecoveryState::GetLog::GetLog(my_context ctx) // am i broken? if (pg->info.last_update < best.log_tail) { - dout(10) << " not contiguous with osd." << auth_log_shard << ", down" << dendl; + ldout(pg->cct, 10) << " not contiguous with osd." << auth_log_shard << ", down" << dendl; post_event(IsIncomplete()); return; } @@ -7547,7 +7556,7 @@ PG::RecoveryState::GetLog::GetLog(my_context ctx) } // how much? - dout(10) << " requesting log from osd." << auth_log_shard << dendl; + ldout(pg->cct, 10) << " requesting log from osd." << auth_log_shard << dendl; context().send_query( auth_log_shard, pg_query_t( @@ -7563,12 +7572,13 @@ PG::RecoveryState::GetLog::GetLog(my_context ctx) boost::statechart::result PG::RecoveryState::GetLog::react(const AdvMap& advmap) { + PG *pg = context< RecoveryMachine >().pg; // make sure our log source didn't go down. we need to check // explicitly because it may not be part of the prior set, which // means the Peering state check won't catch it going down. if (!advmap.osdmap->is_up(auth_log_shard.osd)) { - dout(10) << "GetLog: auth_log_shard osd." - << auth_log_shard.osd << " went down" << dendl; + ldout(pg->cct, 10) << "GetLog: auth_log_shard osd." + << auth_log_shard.osd << " went down" << dendl; post_event(advmap); return transit< Reset >(); } @@ -7579,14 +7589,15 @@ boost::statechart::result PG::RecoveryState::GetLog::react(const AdvMap& advmap) boost::statechart::result PG::RecoveryState::GetLog::react(const MLogRec& logevt) { + PG *pg = context< RecoveryMachine >().pg; assert(!msg); if (logevt.from != auth_log_shard) { - dout(10) << "GetLog: discarding log from " - << "non-auth_log_shard osd." << logevt.from << dendl; + ldout(pg->cct, 10) << "GetLog: discarding log from " + << "non-auth_log_shard osd." << logevt.from << dendl; return discard_event(); } - dout(10) << "GetLog: received master log from osd" - << logevt.from << dendl; + ldout(pg->cct, 10) << "GetLog: received master log from osd" + << logevt.from << dendl; msg = logevt.msg; post_event(GotLog()); return discard_event(); @@ -7594,12 +7605,12 @@ boost::statechart::result PG::RecoveryState::GetLog::react(const MLogRec& logevt boost::statechart::result PG::RecoveryState::GetLog::react(const GotLog&) { - dout(10) << "leaving GetLog" << dendl; PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 10) << "leaving GetLog" << dendl; if (msg) { - dout(10) << "processing master log" << dendl; + ldout(pg->cct, 10) << "processing master log" << dendl; pg->proc_master_log(*context().get_cur_transaction(), - msg->info, msg->log, msg->missing, + msg->info, msg->log, msg->missing, auth_log_shard); } pg->start_flush( @@ -7642,10 +7653,10 @@ boost::statechart::result PG::RecoveryState::WaitActingChange::react(const AdvMa PG *pg = context< RecoveryMachine >().pg; OSDMapRef osdmap = advmap.osdmap; - dout(10) << "verifying no want_acting " << pg->want_acting << " targets didn't go down" << dendl; + ldout(pg->cct, 10) << "verifying no want_acting " << pg->want_acting << " targets didn't go down" << dendl; for (vector::iterator p = pg->want_acting.begin(); p != pg->want_acting.end(); ++p) { if (!osdmap->is_up(*p)) { - dout(10) << " want_acting target osd." << *p << " went down, resetting" << dendl; + ldout(pg->cct, 10) << " want_acting target osd." << *p << " went down, resetting" << dendl; post_event(advmap); return transit< Reset >(); } @@ -7655,19 +7666,22 @@ boost::statechart::result PG::RecoveryState::WaitActingChange::react(const AdvMa boost::statechart::result PG::RecoveryState::WaitActingChange::react(const MLogRec& logevt) { - dout(10) << "In WaitActingChange, ignoring MLocRec" << dendl; + PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 10) << "In WaitActingChange, ignoring MLocRec" << dendl; return discard_event(); } boost::statechart::result PG::RecoveryState::WaitActingChange::react(const MInfoRec& evt) { - dout(10) << "In WaitActingChange, ignoring MInfoRec" << dendl; + PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 10) << "In WaitActingChange, ignoring MInfoRec" << dendl; return discard_event(); } boost::statechart::result PG::RecoveryState::WaitActingChange::react(const MNotifyRec& evt) { - dout(10) << "In WaitActingChange, ignoring MNotifyRec" << dendl; + PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 10) << "In WaitActingChange, ignoring MNotifyRec" << dendl; return discard_event(); } @@ -7751,12 +7765,12 @@ boost::statechart::result PG::RecoveryState::Incomplete::react(const AdvMap &adv } boost::statechart::result PG::RecoveryState::Incomplete::react(const MNotifyRec& notevt) { - dout(7) << "handle_pg_notify from osd." << notevt.from << dendl; PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 7) << "handle_pg_notify from osd." << notevt.from << dendl; if (pg->peer_info.count(notevt.from) && pg->peer_info[notevt.from].last_update == notevt.notify.info.last_update) { - dout(10) << *pg << " got dup osd." << notevt.from << " info " << notevt.notify.info - << ", identical to ours" << dendl; + ldout(pg->cct, 10) << *pg << " got dup osd." << notevt.from << " info " << notevt.notify.info + << ", identical to ours" << dendl; return discard_event(); } else { pg->proc_replica_info( @@ -7798,12 +7812,12 @@ PG::RecoveryState::GetMissing::GetMissing(my_context ctx) continue; // no pg data, nothing divergent if (pi.last_update < pg->pg_log.get_tail()) { - dout(10) << " osd." << *i << " is not contiguous, will restart backfill" << dendl; + ldout(pg->cct, 10) << " osd." << *i << " is not contiguous, will restart backfill" << dendl; pg->peer_missing[*i]; continue; } if (pi.last_backfill == hobject_t()) { - dout(10) << " osd." << *i << " will fully backfill; can infer empty missing set" << dendl; + ldout(pg->cct, 10) << " osd." << *i << " will fully backfill; can infer empty missing set" << dendl; pg->peer_missing[*i]; continue; } @@ -7814,7 +7828,7 @@ PG::RecoveryState::GetMissing::GetMissing(my_context ctx) // pull anything. // FIXME: we can do better here. if last_update==last_complete we // can infer the rest! - dout(10) << " osd." << *i << " has no missing, identical log" << dendl; + ldout(pg->cct, 10) << " osd." << *i << " has no missing, identical log" << dendl; pg->peer_missing[*i]; continue; } @@ -7824,7 +7838,7 @@ PG::RecoveryState::GetMissing::GetMissing(my_context ctx) eversion_t since(pi.last_epoch_started, 0); assert(pi.last_update >= pg->info.log_tail); // or else choose_acting() did a bad thing if (pi.log_tail <= since) { - dout(10) << " requesting log+missing since " << since << " from osd." << *i << dendl; + ldout(pg->cct, 10) << " requesting log+missing since " << since << " from osd." << *i << dendl; context< RecoveryMachine >().send_query( *i, pg_query_t( @@ -7833,9 +7847,9 @@ PG::RecoveryState::GetMissing::GetMissing(my_context ctx) since, pg->info.history, pg->get_osdmap()->get_epoch())); } else { - dout(10) << " requesting fulllog+missing from osd." << *i - << " (want since " << since << " < log.tail " << pi.log_tail << ")" - << dendl; + ldout(pg->cct, 10) << " requesting fulllog+missing from osd." << *i + << " (want since " << since << " < log.tail " + << pi.log_tail << ")" << dendl; context< RecoveryMachine >().send_query( *i, pg_query_t( pg_query_t::FULLLOG, @@ -7848,7 +7862,8 @@ PG::RecoveryState::GetMissing::GetMissing(my_context ctx) if (peer_missing_requested.empty()) { if (pg->need_up_thru) { - dout(10) << " still need up_thru update before going active" << dendl; + ldout(pg->cct, 10) << " still need up_thru update before going active" + << dendl; post_event(NeedUpThru()); return; } @@ -7870,11 +7885,12 @@ boost::statechart::result PG::RecoveryState::GetMissing::react(const MLogRec& lo if (peer_missing_requested.empty()) { if (pg->need_up_thru) { - dout(10) << " still need up_thru update before going active" << dendl; + ldout(pg->cct, 10) << " still need up_thru update before going active" + << dendl; post_event(NeedUpThru()); } else { - dout(10) << "Got last missing, don't need missing " - << "posting Activate" << dendl; + ldout(pg->cct, 10) << "Got last missing, don't need missing " + << "posting Activate" << dendl; post_event(Activate(pg->get_osdmap()->get_epoch())); } } @@ -7936,8 +7952,8 @@ boost::statechart::result PG::RecoveryState::WaitUpThru::react(const ActMap& am) boost::statechart::result PG::RecoveryState::WaitUpThru::react(const MLogRec& logevt) { - dout(10) << "Noting missing from osd." << logevt.from << dendl; PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 10) << "Noting missing from osd." << logevt.from << dendl; pg->peer_missing[logevt.from].claim(logevt.msg->missing); pg->peer_info[logevt.from] = logevt.msg->info; return discard_event(); @@ -7963,18 +7979,20 @@ void PG::RecoveryState::WaitUpThru::exit() /*----RecoveryState::RecoveryMachine Methods-----*/ #undef dout_prefix -#define dout_prefix *_dout << pg->gen_prefix() +#define dout_prefix *_dout << pg->gen_prefix() void PG::RecoveryState::RecoveryMachine::log_enter(const char *state_name) { - dout(5) << "enter " << state_name << dendl; + PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 5) << "enter " << state_name << dendl; pg->osd->pg_recovery_stats.log_enter(state_name); } void PG::RecoveryState::RecoveryMachine::log_exit(const char *state_name, utime_t enter_time) { utime_t dur = ceph_clock_now() - enter_time; - dout(5) << "exit " << state_name << " " << dur << " " << event_count << " " << event_time << dendl; + PG *pg = context< RecoveryMachine >().pg; + ldout(pg->cct, 5) << "exit " << state_name << " " << dur << " " << event_count << " " << event_time << dendl; pg->osd->pg_recovery_stats.log_exit(state_name, ceph_clock_now() - enter_time, event_count, event_time); event_count = 0; @@ -7986,7 +8004,8 @@ void PG::RecoveryState::RecoveryMachine::log_exit(const char *state_name, utime_ #undef dout_prefix #define dout_prefix (*_dout << (debug_pg ? debug_pg->gen_prefix() : string()) << " PriorSet: ") -PG::PriorSet::PriorSet(bool ec_pool, +PG::PriorSet::PriorSet(CephContext* cct, + bool ec_pool, IsPGRecoverablePredicate *c, const OSDMap &osdmap, const map &past_intervals, @@ -7994,7 +8013,7 @@ PG::PriorSet::PriorSet(bool ec_pool, const vector &acting, const pg_info_t &info, const PG *debug_pg) - : ec_pool(ec_pool), pg_down(false), pcontdec(c) + : cct(cct), ec_pool(ec_pool), pg_down(false), pcontdec(c) { /* * We have to be careful to gracefully deal with situations like diff --git a/src/osd/PG.h b/src/osd/PG.h index 31a8ad5dd727..63064304c299 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -163,6 +163,7 @@ class PGRecoveryStats { }; struct PGPool { + CephContext* cct; epoch_t cached_epoch; int64_t id; string name; @@ -174,8 +175,9 @@ struct PGPool { interval_set cached_removed_snaps; // current removed_snaps set interval_set newly_removed_snaps; // newly removed in the last epoch - PGPool(OSDMapRef map, int64_t i) - : cached_epoch(map->get_epoch()), + PGPool(CephContext* cct, OSDMapRef map, int64_t i) + : cct(cct), + cached_epoch(map->get_epoch()), id(i), name(map->get_pool_name(id)), auid(map->get_pg_pool(id)->auid) { @@ -557,6 +559,7 @@ public: // [primary only] content recovery state protected: struct PriorSet { + CephContext* cct; const bool ec_pool; set probe; /// current+prior OSDs we need to probe. set down; /// down osds that would normally be in @a probe and might be interesting. @@ -564,14 +567,15 @@ public: bool pg_down; /// some down osds are included in @a cur; the DOWN pg state bit should be set. boost::scoped_ptr pcontdec; - PriorSet(bool ec_pool, + PriorSet(CephContext* cct, + bool ec_pool, IsPGRecoverablePredicate *c, const OSDMap &osdmap, const map &past_intervals, const vector &up, const vector &acting, const pg_info_t &info, - const PG *debug_pg=NULL); + const PG *debug_pg = nullptr); bool affected_by_map(const OSDMapRef osdmap, const PG *debug_pg=0) const; }; @@ -2189,6 +2193,7 @@ private: public: static int _prepare_write_info( + CephContext* cct, map *km, epoch_t epoch, pg_info_t &info, @@ -2197,7 +2202,7 @@ public: bool dirty_big_info, bool dirty_epoch, bool try_fast_info, - PerfCounters *logger = NULL); + PerfCounters *logger = nullptr); void write_if_dirty(ObjectStore::Transaction& t); PGLog::IndexedLog projected_log; diff --git a/src/osd/PGBackend.cc b/src/osd/PGBackend.cc index 832911eee993..024657d8e436 100644 --- a/src/osd/PGBackend.cc +++ b/src/osd/PGBackend.cc @@ -28,7 +28,7 @@ #include "PGLog.h" #include "common/LogClient.h" -#define dout_context g_ceph_context +#define dout_context cct #define dout_subsys ceph_subsys_osd #define DOUT_PREFIX_ARGS this #undef dout_prefix @@ -410,7 +410,7 @@ PGBackend *PGBackend::build_pg_backend( stringstream ss; ceph::ErasureCodePluginRegistry::instance().factory( profile.find("plugin")->second, - g_conf->erasure_code_dir, + cct->_conf->erasure_code_dir, profile, &ec_impl, &ss); @@ -837,9 +837,9 @@ void PGBackend::be_compare_scrubmaps( update = MAYBE; } if (auth_object.digest_present && auth_object.omap_digest_present && - g_conf->osd_debug_scrub_chance_rewrite_digest && + cct->_conf->osd_debug_scrub_chance_rewrite_digest && (((unsigned)rand() % 100) > - g_conf->osd_debug_scrub_chance_rewrite_digest)) { + cct->_conf->osd_debug_scrub_chance_rewrite_digest)) { dout(20) << __func__ << " randomly updating digest on " << *k << dendl; update = MAYBE; } @@ -869,13 +869,13 @@ void PGBackend::be_compare_scrubmaps( if (update != NO) { utime_t age = now - auth_oi.local_mtime; if (update == FORCE || - age > g_conf->osd_deep_scrub_update_digest_min_age) { + age > cct->_conf->osd_deep_scrub_update_digest_min_age) { dout(20) << __func__ << " will update digest on " << *k << dendl; missing_digest[*k] = make_pair(auth_object.digest, auth_object.omap_digest); } else { dout(20) << __func__ << " missing digest but age " << age - << " < " << g_conf->osd_deep_scrub_update_digest_min_age + << " < " << cct->_conf->osd_deep_scrub_update_digest_min_age << " on " << *k << dendl; } } diff --git a/src/osd/PGBackend.h b/src/osd/PGBackend.h index d4e0091ca735..47cb98f5d818 100644 --- a/src/osd/PGBackend.h +++ b/src/osd/PGBackend.h @@ -50,6 +50,8 @@ typedef ceph::shared_ptr OSDMapRef; * 4) Handling scrub, deep-scrub, repair */ class PGBackend { + public: + CephContext* cct; protected: ObjectStore *store; const coll_t coll; @@ -259,8 +261,9 @@ typedef ceph::shared_ptr OSDMapRef; }; Listener *parent; Listener *get_parent() const { return parent; } - PGBackend(Listener *l, ObjectStore *store, coll_t coll, + PGBackend(CephContext* cct, Listener *l, ObjectStore *store, coll_t coll, ObjectStore::CollectionHandle &ch) : + cct(cct), store(store), coll(coll), ch(ch), diff --git a/src/osd/PGLog.cc b/src/osd/PGLog.cc index 79e49e713344..99ca4ef054a5 100644 --- a/src/osd/PGLog.cc +++ b/src/osd/PGLog.cc @@ -19,7 +19,7 @@ #include "include/unordered_map.h" #include "common/ceph_context.h" -#define dout_context g_ceph_context +#define dout_context cct #define dout_subsys ceph_subsys_osd #undef dout_prefix #define dout_prefix _prefix(_dout, this) @@ -42,6 +42,7 @@ PGLog::IndexedLog PGLog::IndexedLog::split_out_child( } void PGLog::IndexedLog::trim( + CephContext* cct, eversion_t s, set *trimmed) { @@ -121,7 +122,7 @@ void PGLog::trim( assert(trim_to <= info.last_complete); dout(10) << "trim " << log << " to " << trim_to << dendl; - log.trim(trim_to, &trimmed); + log.trim(cct, trim_to, &trimmed); info.log_tail = log.tail; } } diff --git a/src/osd/PGLog.h b/src/osd/PGLog.h index 0e70dca75dff..17fb39d405ae 100644 --- a/src/osd/PGLog.h +++ b/src/osd/PGLog.h @@ -29,8 +29,6 @@ using namespace std; #define PGLOG_INDEXED_EXTRA_CALLER_OPS (1 << 2) #define PGLOG_INDEXED_ALL (PGLOG_INDEXED_OBJECTS | PGLOG_INDEXED_CALLER_OPS | PGLOG_INDEXED_EXTRA_CALLER_OPS) -#define dout_context g_ceph_context - class CephContext; struct PGLog : DoutPrefixProvider { @@ -477,6 +475,7 @@ public: } void trim( + CephContext* cct, eversion_t s, set *trimmed); @@ -1242,9 +1241,9 @@ public: continue; if (i.second.need > log.tail || cmp(i.first, info.last_backfill, info.last_backfill_bitwise) > 0) { - derr << __func__ << ": invalid missing set entry found " - << i.first - << dendl; + lderr(dpp->get_cct()) << __func__ << ": invalid missing set entry found " + << i.first + << dendl; assert(0 == "invalid missing set entry found"); } bufferlist bv; @@ -1311,6 +1310,4 @@ public: } }; -#undef dout_context - #endif // CEPH_PG_LOG_H diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index f16f85a803fd..0f7c1b70035c 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -55,7 +55,7 @@ #define tracepoint(...) #endif -#define dout_context g_ceph_context +#define dout_context cct #define dout_subsys ceph_subsys_osd #define DOUT_PREFIX_ARGS this, osd->whoami, get_osdmap() #undef dout_prefix @@ -694,7 +694,8 @@ public: class PGLSParentFilter : public PGLSFilter { inodeno_t parent_ino; public: - PGLSParentFilter() { + CephContext* cct; + PGLSParentFilter(CephContext* cct) : cct(cct) { xattr = "_parent"; } virtual int init(bufferlist::iterator ¶ms) @@ -781,7 +782,7 @@ int PrimaryLogPG::get_pgls_filter(bufferlist::iterator& iter, PGLSFilter **pfilt } if (type.compare("parent") == 0) { - filter = new PGLSParentFilter(); + filter = new PGLSParentFilter(cct); } else if (type.compare("plain") == 0) { filter = new PGLSPlainFilter(); } else { @@ -1573,7 +1574,7 @@ PrimaryLogPG::PrimaryLogPG(OSDService *o, OSDMapRef curmap, pgbackend( PGBackend::build_pg_backend( _pool.info, curmap, this, coll_t(p), ch, o->store, cct)), - object_contexts(o->cct, g_conf->osd_pg_object_context_cache_count), + object_contexts(o->cct, o->cct->_conf->osd_pg_object_context_cache_count), snapset_contexts_lock("PrimaryLogPG::snapset_contexts_lock"), backfills_in_flight(hobject_t::Comparator(true)), pending_backfill_updates(hobject_t::Comparator(true)), @@ -1795,24 +1796,25 @@ void PrimaryLogPG::do_op(OpRequestRef& op) info.pgid.pool(), m->get_object_locator().nspace); // object name too long? - if (m->get_oid().name.size() > g_conf->osd_max_object_name_len) { + if (m->get_oid().name.size() > cct->_conf->osd_max_object_name_len) { dout(4) << "do_op name is longer than " - << g_conf->osd_max_object_name_len + << cct->_conf->osd_max_object_name_len << " bytes" << dendl; osd->reply_op_error(op, -ENAMETOOLONG); return; } - if (m->get_object_locator().key.size() > g_conf->osd_max_object_name_len) { + if (m->get_object_locator().key.size() > + cct->_conf->osd_max_object_name_len) { dout(4) << "do_op locator is longer than " - << g_conf->osd_max_object_name_len + << cct->_conf->osd_max_object_name_len << " bytes" << dendl; osd->reply_op_error(op, -ENAMETOOLONG); return; } if (m->get_object_locator().nspace.size() > - g_conf->osd_max_object_namespace_len) { + cct->_conf->osd_max_object_namespace_len) { dout(4) << "do_op namespace is longer than " - << g_conf->osd_max_object_namespace_len + << cct->_conf->osd_max_object_namespace_len << " bytes" << dendl; osd->reply_op_error(op, -ENAMETOOLONG); return; @@ -3832,10 +3834,10 @@ void PrimaryLogPG::snap_trimmer(epoch_t queued) if (deleting || pg_has_reset_since(queued)) { return; } - if (g_conf->osd_snap_trim_sleep > 0) { + if (cct->_conf->osd_snap_trim_sleep > 0) { unlock(); utime_t t; - t.set_from_double(g_conf->osd_snap_trim_sleep); + t.set_from_double(cct->_conf->osd_snap_trim_sleep); t.sleep(); lock(); dout(20) << __func__ << " slept for " << t << dendl; @@ -5789,8 +5791,8 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) tracepoint(osd, do_osd_op_pre_omapgetkeys, soid.oid.name.c_str(), soid.snap.val, "???", 0); goto fail; } - if (max_return > g_conf->osd_max_omap_entries_per_request) { - max_return = g_conf->osd_max_omap_entries_per_request; + if (max_return > cct->_conf->osd_max_omap_entries_per_request) { + max_return = cct->_conf->osd_max_omap_entries_per_request; } tracepoint(osd, do_osd_op_pre_omapgetkeys, soid.oid.name.c_str(), soid.snap.val, start_after.c_str(), max_return); @@ -5804,7 +5806,7 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) iter->upper_bound(start_after); for (num = 0; num < max_return && - bl.length() < g_conf->osd_max_omap_bytes_per_request && + bl.length() < cct->_conf->osd_max_omap_bytes_per_request && iter->valid(); ++num, iter->next(false)) { ::encode(iter->key(), bl); @@ -5833,8 +5835,8 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) tracepoint(osd, do_osd_op_pre_omapgetvals, soid.oid.name.c_str(), soid.snap.val, "???", 0, "???"); goto fail; } - if (max_return > g_conf->osd_max_omap_entries_per_request) { - max_return = g_conf->osd_max_omap_entries_per_request; + if (max_return > cct->_conf->osd_max_omap_entries_per_request) { + max_return = cct->_conf->osd_max_omap_entries_per_request; } tracepoint(osd, do_osd_op_pre_omapgetvals, soid.oid.name.c_str(), soid.snap.val, start_after.c_str(), max_return, filter_prefix.c_str()); @@ -5852,7 +5854,7 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) if (filter_prefix > start_after) iter->lower_bound(filter_prefix); for (num = 0; num < max_return && - bl.length() < g_conf->osd_max_omap_bytes_per_request && + bl.length() < cct->_conf->osd_max_omap_bytes_per_request && iter->valid() && iter->key().substr(0, filter_prefix.size()) == filter_prefix; ++num, iter->next(false)) { @@ -6000,7 +6002,7 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) goto fail; } tracepoint(osd, do_osd_op_pre_omapsetvals, soid.oid.name.c_str(), soid.snap.val); - if (g_ceph_context->_conf->subsys.should_gather(dout_subsys, 20)) { + if (cct->_conf->subsys.should_gather(dout_subsys, 20)) { dout(20) << "setting vals: " << dendl; map to_set; bufferlist::iterator pt = to_set_bl.begin(); @@ -7340,7 +7342,7 @@ void PrimaryLogPG::_copy_some(ObjectContextRef obc, CopyOpRef cop) if (cop->flags & CEPH_OSD_COPY_FROM_FLAG_RWORDERED) flags |= CEPH_OSD_FLAG_RWORDERED; - C_GatherBuilder gather(g_ceph_context); + C_GatherBuilder gather(cct); if (cop->cursor.is_initial() && cop->mirror_snapset) { // list snaps too. @@ -7529,7 +7531,7 @@ void PrimaryLogPG::process_copy_chunk(hobject_t oid, ceph_tid_t tid, int r) r = -EIO; goto out; } - if (g_conf->osd_debug_inject_copyfrom_error) { + if (cct->_conf->osd_debug_inject_copyfrom_error) { derr << __func__ << " injecting copyfrom failure" << dendl; r = -EIO; goto out; @@ -10449,16 +10451,16 @@ void PG::MissingLoc::check_recovery_sources(const OSDMapRef& osdmap) ++p; continue; } - dout(10) << "check_recovery_sources source osd." << *p << " now down" << dendl; + ldout(pg->cct, 10) << "check_recovery_sources source osd." << *p << " now down" << dendl; now_down.insert(*p); missing_loc_sources.erase(p++); } if (now_down.empty()) { - dout(10) << "check_recovery_sources no source osds (" << missing_loc_sources << ") went down" << dendl; + ldout(pg->cct, 10) << "check_recovery_sources no source osds (" << missing_loc_sources << ") went down" << dendl; } else { - dout(10) << "check_recovery_sources sources osds " << now_down << " now down, remaining sources are " - << missing_loc_sources << dendl; + ldout(pg->cct, 10) << "check_recovery_sources sources osds " << now_down << " now down, remaining sources are " + << missing_loc_sources << dendl; // filter missing_loc map, hobject_t::BitwiseComparator>::iterator p = missing_loc.begin(); @@ -11716,11 +11718,13 @@ void PrimaryLogPG::hit_set_create() p->target_size = (double)unique * (double)pool.info.hit_set_period / (double)dur; } - if (p->target_size < static_cast(g_conf->osd_hit_set_min_size)) - p->target_size = g_conf->osd_hit_set_min_size; + if (p->target_size < + static_cast(cct->_conf->osd_hit_set_min_size)) + p->target_size = cct->_conf->osd_hit_set_min_size; - if (p->target_size > static_cast(g_conf->osd_hit_set_max_size)) - p->target_size = g_conf->osd_hit_set_max_size; + if (p->target_size + > static_cast(cct->_conf->osd_hit_set_max_size)) + p->target_size = cct->_conf->osd_hit_set_max_size; p->seed = now.sec(); @@ -12109,7 +12113,7 @@ bool PrimaryLogPG::agent_work(int start_max, int agent_flush_quota) } } - if (++agent_state->hist_age > g_conf->osd_agent_hist_halflife) { + if (++agent_state->hist_age > cct->_conf->osd_agent_hist_halflife) { dout(20) << __func__ << " resetting atime and temp histograms" << dendl; agent_state->hist_age = 0; agent_state->temp_hist.decay(); @@ -12511,7 +12515,7 @@ bool PrimaryLogPG::agent_choose_mode(bool restart, OpRequestRef op) // flush mode uint64_t flush_target = pool.info.cache_target_dirty_ratio_micro; uint64_t flush_high_target = pool.info.cache_target_dirty_high_ratio_micro; - uint64_t flush_slop = (float)flush_target * g_conf->osd_agent_slop; + uint64_t flush_slop = (float)flush_target * cct->_conf->osd_agent_slop; if (restart || agent_state->flush_mode == TierAgentState::FLUSH_MODE_IDLE) { flush_target += flush_slop; flush_high_target += flush_slop; @@ -12528,7 +12532,7 @@ bool PrimaryLogPG::agent_choose_mode(bool restart, OpRequestRef op) // evict mode uint64_t evict_target = pool.info.cache_target_full_ratio_micro; - uint64_t evict_slop = (float)evict_target * g_conf->osd_agent_slop; + uint64_t evict_slop = (float)evict_target * cct->_conf->osd_agent_slop; if (restart || agent_state->evict_mode == TierAgentState::EVICT_MODE_IDLE) evict_target += evict_slop; else @@ -12544,10 +12548,10 @@ bool PrimaryLogPG::agent_choose_mode(bool restart, OpRequestRef op) uint64_t over = full_micro - evict_target; uint64_t span = 1000000 - evict_target; evict_effort = MAX(over * 1000000 / span, - (unsigned)(1000000.0 * g_conf->osd_agent_min_evict_effort)); + (unsigned)(1000000.0 * cct->_conf->osd_agent_min_evict_effort)); // quantize effort to avoid too much reordering in the agent_queue. - uint64_t inc = g_conf->osd_agent_quantize_effort * 1000000; + uint64_t inc = cct->_conf->osd_agent_quantize_effort * 1000000; assert(inc > 0); uint64_t was = evict_effort; evict_effort -= evict_effort % inc; @@ -13225,12 +13229,12 @@ PrimaryLogPG::SnapTrimmer::~SnapTrimmer() void PrimaryLogPG::SnapTrimmer::log_enter(const char *state_name) { - dout(20) << "enter " << state_name << dendl; + ldout(pg->cct, 20) << "enter " << state_name << dendl; } void PrimaryLogPG::SnapTrimmer::log_exit(const char *state_name, utime_t enter_time) { - dout(20) << "exit " << state_name << dendl; + ldout(pg->cct, 20) << "exit " << state_name << dendl; } /*---SnapTrimmer states---*/ @@ -13254,22 +13258,22 @@ void PrimaryLogPG::NotTrimming::exit() boost::statechart::result PrimaryLogPG::NotTrimming::react(const KickTrim&) { PrimaryLogPG *pg = context< SnapTrimmer >().pg; - dout(10) << "NotTrimming react KickTrim" << dendl; + ldout(pg->cct, 10) << "NotTrimming react KickTrim" << dendl; assert(pg->is_primary() && pg->is_active()); if (!pg->is_clean() || pg->snap_trimq.empty()) { - dout(10) << "NotTrimming not clean or nothing to trim" << dendl; + ldout(pg->cct, 10) << "NotTrimming not clean or nothing to trim" << dendl; return discard_event(); } if (pg->scrubber.active) { - dout(10) << " scrubbing, will requeue snap_trimmer after" << dendl; + ldout(pg->cct, 10) << " scrubbing, will requeue snap_trimmer after" << dendl; pg->scrubber.queue_snap_trim = true; return transit< WaitScrub >(); } else { context().snap_to_trim = pg->snap_trimq.range_start(); - dout(10) << "NotTrimming: trimming " + ldout(pg->cct, 10) << "NotTrimming: trimming " << pg->snap_trimq.range_start() << dendl; return transit< AwaitAsyncWork >(); @@ -13293,8 +13297,8 @@ void PrimaryLogPG::AwaitAsyncWork::exit() boost::statechart::result PrimaryLogPG::AwaitAsyncWork::react(const DoSnapWork&) { - dout(10) << "AwaitAsyncWork react" << dendl; PrimaryLogPGRef pg = context< SnapTrimmer >().pg; + ldout(pg->cct, 10) << "AwaitAsyncWork react" << dendl; snapid_t snap_to_trim = context().snap_to_trim; auto &in_flight = context().in_flight; assert(in_flight.empty()); @@ -13302,36 +13306,36 @@ boost::statechart::result PrimaryLogPG::AwaitAsyncWork::react(const DoSnapWork&) assert(pg->is_primary() && pg->is_active()); if (!pg->is_clean() || pg->scrubber.active) { - dout(10) << "something changed, reverting to NotTrimming" << dendl; + ldout(pg->cct, 10) << "something changed, reverting to NotTrimming" << dendl; post_event(KickTrim()); return transit< NotTrimming >(); } - dout(10) << "AwaitAsyncWork: trimming snap " << snap_to_trim << dendl; + ldout(pg->cct, 10) << "AwaitAsyncWork: trimming snap " << snap_to_trim << dendl; vector to_trim; - unsigned max = g_conf->osd_pg_max_concurrent_snap_trims; + unsigned max = pg->cct->_conf->osd_pg_max_concurrent_snap_trims; to_trim.reserve(max); int r = pg->snap_mapper.get_next_objects_to_trim( snap_to_trim, max, &to_trim); if (r != 0 && r != -ENOENT) { - derr << "get_next_objects_to_trim returned " - << cpp_strerror(r) << dendl; + lderr(pg->cct) << "get_next_objects_to_trim returned " + << cpp_strerror(r) << dendl; assert(0 == "get_next_objects_to_trim returned an invalid code"); } else if (r == -ENOENT) { // Done! - dout(10) << "got ENOENT" << dendl; + ldout(pg->cct, 10) << "got ENOENT" << dendl; - dout(10) << "adding snap " << snap_to_trim - << " to purged_snaps" - << dendl; + ldout(pg->cct, 10) << "adding snap " << snap_to_trim + << " to purged_snaps" + << dendl; pg->info.purged_snaps.insert(snap_to_trim); pg->snap_trimq.erase(snap_to_trim); - dout(10) << "purged_snaps now " - << pg->info.purged_snaps << ", snap_trimq now " - << pg->snap_trimq << dendl; + ldout(pg->cct, 10) << "purged_snaps now " + << pg->info.purged_snaps << ", snap_trimq now " + << pg->snap_trimq << dendl; ObjectStore::Transaction t; pg->dirty_big_info = true; @@ -13347,19 +13351,19 @@ boost::statechart::result PrimaryLogPG::AwaitAsyncWork::react(const DoSnapWork&) for (auto &&object: to_trim) { // Get next - dout(10) << "AwaitAsyncWork react trimming " << object << dendl; + ldout(pg->cct, 10) << "AwaitAsyncWork react trimming " << object << dendl; OpContextUPtr ctx = pg->trim_object(in_flight.empty(), object); if (!ctx) { - dout(10) << "could not get write lock on obj " - << object << dendl; + ldout(pg->cct, 10) << "could not get write lock on obj " + << object << dendl; if (in_flight.empty()) { - dout(10) << "waiting for it to clear" - << dendl; + ldout(pg->cct, 10) << "waiting for it to clear" + << dendl; return transit< WaitRWLock >(); } else { - dout(10) << "letting the ones we already started finish" - << dendl; + ldout(pg->cct, 10) << "letting the ones we already started finish" + << dendl; return transit< WaitRepops >(); } } diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index 94d8951ef267..2a8d7a2b116e 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -22,7 +22,7 @@ #include "messages/MOSDPGPull.h" #include "messages/MOSDPGPushReply.h" -#define dout_context g_ceph_context +#define dout_context cct #define dout_subsys ceph_subsys_osd #define DOUT_PREFIX_ARGS this #undef dout_prefix @@ -114,8 +114,7 @@ ReplicatedBackend::ReplicatedBackend( ObjectStore::CollectionHandle &c, ObjectStore *store, CephContext *cct) : - PGBackend(pg, store, coll, c), - cct(cct) {} + PGBackend(cct, pg, store, coll, c) {} void ReplicatedBackend::run_recovery_op( PGBackend::RecoveryHandle *_h, diff --git a/src/osd/ReplicatedBackend.h b/src/osd/ReplicatedBackend.h index b9431cc0a8d0..c36736c5b9f2 100644 --- a/src/osd/ReplicatedBackend.h +++ b/src/osd/ReplicatedBackend.h @@ -27,8 +27,6 @@ class ReplicatedBackend : public PGBackend { }; friend struct C_ReplicatedBackend_OnPullComplete; public: - CephContext *cct; - ReplicatedBackend( PGBackend::Listener *pg, coll_t coll, diff --git a/src/osd/SnapMapper.cc b/src/osd/SnapMapper.cc index deceaf7ccc00..8f758f05d4b0 100644 --- a/src/osd/SnapMapper.cc +++ b/src/osd/SnapMapper.cc @@ -14,7 +14,7 @@ #include "SnapMapper.h" -#define dout_context g_ceph_context +#define dout_context cct #define dout_subsys ceph_subsys_osd #undef dout_prefix #define dout_prefix *_dout << "snap_mapper." diff --git a/src/osd/SnapMapper.h b/src/osd/SnapMapper.h index 16cc763f7f1e..ef59cdedee91 100644 --- a/src/osd/SnapMapper.h +++ b/src/osd/SnapMapper.h @@ -97,6 +97,7 @@ public: */ class SnapMapper { public: + CephContext* cct; struct object_snaps { hobject_t oid; std::set snaps; @@ -165,13 +166,14 @@ public: const shard_id_t shard; const string shard_prefix; SnapMapper( + CephContext* cct, MapCacher::StoreDriver *driver, uint32_t match, ///< [in] pgid uint32_t bits, ///< [in] current split bits int64_t pool, ///< [in] pool shard_id_t shard ///< [in] shard ) - : backend(driver), mask_bits(bits), match(match), pool(pool), + : cct(cct), backend(driver), mask_bits(bits), match(match), pool(pool), shard(shard), shard_prefix(make_shard_prefix(shard)) { update_bits(mask_bits); } diff --git a/src/osd/Watch.cc b/src/osd/Watch.cc index 0ec5edda3f1a..93f7a0717fb8 100644 --- a/src/osd/Watch.cc +++ b/src/osd/Watch.cc @@ -16,7 +16,7 @@ struct CancelableContext : public Context { virtual void cancel() = 0; }; -#define dout_context g_ceph_context +#define dout_context osd->cct #define dout_subsys ceph_subsys_osd #undef dout_prefix #define dout_prefix _prefix(_dout, this) @@ -241,9 +241,9 @@ public: } void finish(int) { ceph_abort(); /* not used */ } void complete(int) { - dout(10) << "HandleWatchTimeout" << dendl; - boost::intrusive_ptr pg(watch->pg); OSDService *osd(watch->osd); + ldout(osd->cct, 10) << "HandleWatchTimeout" << dendl; + boost::intrusive_ptr pg(watch->pg); osd->watch_lock.Unlock(); pg->lock(); watch->cb = NULL; @@ -264,6 +264,7 @@ public: canceled = true; } void finish(int) { + OSDService *osd(watch->osd); dout(10) << "HandleWatchTimeoutDelayed" << dendl; assert(watch->pg->is_locked()); watch->cb = NULL; @@ -530,7 +531,7 @@ void WatchConState::reset(Connection *con) if ((*i)->is_connected(con)) { (*i)->disconnect(); } else { - generic_derr << __func__ << " not still connected to " << (*i) << dendl; + lgeneric_derr(cct) << __func__ << " not still connected to " << (*i) << dendl; } } pg->unlock(); diff --git a/src/osd/Watch.h b/src/osd/Watch.h index 8f49779b4136..1897a50a5193 100644 --- a/src/osd/Watch.h +++ b/src/osd/Watch.h @@ -277,7 +277,8 @@ class WatchConState { Mutex lock; std::set watches; public: - WatchConState() : lock("WatchConState") {} + CephContext* cct; + WatchConState(CephContext* cct) : lock("WatchConState"), cct(cct) {} /// Add a watch void addWatch( diff --git a/src/test/test_snap_mapper.cc b/src/test/test_snap_mapper.cc index 61664b66c968..a48fd03a9518 100644 --- a/src/test/test_snap_mapper.cc +++ b/src/test/test_snap_mapper.cc @@ -451,7 +451,7 @@ public: uint32_t mask, uint32_t bits) : driver(driver), - mapper(new SnapMapper(driver, mask, bits, 0, shard_id_t(1))), + mapper(new SnapMapper(g_ceph_context, driver, mask, bits, 0, shard_id_t(1))), mask(mask), bits(bits), lock("lock") {} diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index d5ce63a98c1b..1806e5869509 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -377,7 +377,7 @@ int finish_remove_pgs(ObjectStore *store) if (it->is_temp(&pgid) || (it->is_pg(&pgid) && PG::_has_removal_flag(store, pgid))) { cout << "finish_remove_pgs " << *it << " removing " << pgid << std::endl; - OSD::recursive_remove_collection(store, pgid, *it); + OSD::recursive_remove_collection(g_ceph_context, store, pgid, *it); continue; } @@ -450,6 +450,7 @@ int write_info(ObjectStore::Transaction &t, epoch_t epoch, pg_info_t &info, map km; pg_info_t last_written_info; int ret = PG::_prepare_write_info( + g_ceph_context, &km, epoch, info, last_written_info, @@ -890,7 +891,7 @@ int ObjectStoreTool::get_object(ObjectStore *store, coll_t coll, OSD::make_snapmapper_oid()); spg_t pg; coll.is_pg_prefix(&pg); - SnapMapper mapper(&driver, 0, 0, 0, pg.shard); + SnapMapper mapper(g_ceph_context, &driver, 0, 0, 0, pg.shard); if (ob.hoid.hobj.is_temp()) { cerr << "ERROR: Export contains temporary object '" << ob.hoid << "'" << std::endl; @@ -1445,7 +1446,7 @@ int do_remove_object(ObjectStore *store, coll_t coll, store, coll_t(), OSD::make_snapmapper_oid()); - SnapMapper mapper(&driver, 0, 0, 0, pg.shard); + SnapMapper mapper(g_ceph_context, &driver, 0, 0, 0, pg.shard); struct stat st; int r = store->stat(coll, ghobj, &st);