Skip to content

Commit

Permalink
Merge pull request ceph#33770 from majianpeng/osd-simple-logger
Browse files Browse the repository at this point in the history
osd/OSD: simple perfcounter usage in OSDService

Reviewed-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov authored Jul 16, 2020
2 parents 1dd932a + 5ace640 commit 49fa970
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 31 deletions.
47 changes: 18 additions & 29 deletions src/osd/OSD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ void OSDService::agent_entry()
<< " no agent_work, delay for " << cct->_conf->osd_agent_delay_time
<< " seconds" << dendl;

osd->logger->inc(l_osd_tier_delay);
logger->inc(l_osd_tier_delay);
// Queue a timer to call agent_choose_mode for this pg in 5 seconds
std::lock_guard timer_locker{agent_timer_lock};
Context *cb = new AgentTimeoutCB(pg);
Expand Down Expand Up @@ -971,9 +971,9 @@ void OSDService::set_statfs(const struct store_statfs_t &stbuf,
used = bytes - avail;
}

osd->logger->set(l_osd_stat_bytes, bytes);
osd->logger->set(l_osd_stat_bytes_used, used);
osd->logger->set(l_osd_stat_bytes_avail, avail);
logger->set(l_osd_stat_bytes, bytes);
logger->set(l_osd_stat_bytes_used, used);
logger->set(l_osd_stat_bytes_avail, avail);

std::lock_guard l(stat_lock);
osd_stat.statfs = stbuf;
Expand Down Expand Up @@ -1514,12 +1514,10 @@ bool OSDService::_get_map_bl(epoch_t e, bufferlist& bl)
{
bool found = map_bl_cache.lookup(e, &bl);
if (found) {
if (logger)
logger->inc(l_osd_map_bl_cache_hit);
logger->inc(l_osd_map_bl_cache_hit);
return true;
}
if (logger)
logger->inc(l_osd_map_bl_cache_miss);
logger->inc(l_osd_map_bl_cache_miss);
found = store->read(meta_ch,
OSD::get_osdmap_pobject_name(e), 0, 0, bl,
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED) >= 0;
Expand All @@ -1534,12 +1532,10 @@ bool OSDService::get_inc_map_bl(epoch_t e, bufferlist& bl)
std::lock_guard l(map_cache_lock);
bool found = map_bl_inc_cache.lookup(e, &bl);
if (found) {
if (logger)
logger->inc(l_osd_map_bl_cache_hit);
logger->inc(l_osd_map_bl_cache_hit);
return true;
}
if (logger)
logger->inc(l_osd_map_bl_cache_miss);
logger->inc(l_osd_map_bl_cache_miss);
found = store->read(meta_ch,
OSD::get_inc_osdmap_pobject_name(e), 0, 0, bl,
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED) >= 0;
Expand Down Expand Up @@ -1596,12 +1592,10 @@ OSDMapRef OSDService::try_get_map(epoch_t epoch)
OSDMapRef retval = map_cache.lookup(epoch);
if (retval) {
dout(30) << "get_map " << epoch << " -cached" << dendl;
if (logger) {
logger->inc(l_osd_map_cache_hit);
}
logger->inc(l_osd_map_cache_hit);
return retval;
}
if (logger) {
{
logger->inc(l_osd_map_cache_miss);
epoch_t lb = map_cache.cached_key_lower_bound();
if (epoch < lb) {
Expand Down Expand Up @@ -2160,8 +2154,8 @@ OSD::OSD(CephContext *cct_, ObjectStore *store_,
objecter_messenger(osdc_messenger),
monc(mc),
mgrc(cct_, client_messenger, &mc->monmap),
logger(NULL),
recoverystate_perf(NULL),
logger(create_logger()),
recoverystate_perf(create_recoverystate_perf()),
store(store_),
log_client(cct, client_messenger, &mc->monmap, LogClient::NO_FLAGS),
clog(log_client.create_channel()),
Expand Down Expand Up @@ -3489,8 +3483,6 @@ int OSD::init()

check_osdmap_features();

create_recoverystate_perf();

{
epoch_t bind_epoch = osdmap->get_epoch();
service.set_epochs(NULL, NULL, &bind_epoch);
Expand All @@ -3509,7 +3501,6 @@ int OSD::init()

dout(2) << "superblock: I am osd." << superblock.whoami << dendl;

create_logger();

// prime osd stats
{
Expand Down Expand Up @@ -4052,20 +4043,18 @@ void OSD::final_init()
ceph_assert(r == 0);
}

void OSD::create_logger()
PerfCounters* OSD::create_logger()
{
dout(10) << "create_logger" << dendl;

logger = build_osd_logger(cct);
PerfCounters* logger = build_osd_logger(cct);
cct->get_perfcounters_collection()->add(logger);
return logger;
}

void OSD::create_recoverystate_perf()
PerfCounters* OSD::create_recoverystate_perf()
{
dout(10) << "create_recoverystate_perf" << dendl;

recoverystate_perf = build_recoverystate_perf(cct);
PerfCounters* recoverystate_perf = build_recoverystate_perf(cct);
cct->get_perfcounters_collection()->add(recoverystate_perf);
return recoverystate_perf;
}

int OSD::shutdown()
Expand Down
4 changes: 2 additions & 2 deletions src/osd/OSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,8 @@ class OSD : public Dispatcher,
bool journal_is_rotational = true;

ZTracer::Endpoint trace_endpoint;
void create_logger();
void create_recoverystate_perf();
PerfCounters* create_logger();
PerfCounters* create_recoverystate_perf();
void tick();
void tick_without_osd_lock();
void _dispatch(Message *m);
Expand Down

0 comments on commit 49fa970

Please sign in to comment.