mirror of
https://github.com/ceph/ceph
synced 2025-02-23 11:07:35 +00:00
Merge pull request #9314 from xiexingguo/xxg-wip-fix-radosclient
RadosClient: reduce cpu burning; fix message leak Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
commit
870fd846d8
@ -190,8 +190,7 @@ struct C_aio_notify_Ack : public Context {
|
||||
librados::IoCtxImpl::IoCtxImpl() :
|
||||
ref_cnt(0), client(NULL), poolid(0), assert_ver(0), last_objver(0),
|
||||
notify_timeout(30), aio_write_list_lock("librados::IoCtxImpl::aio_write_list_lock"),
|
||||
aio_write_seq(0), cached_pool_names_lock("librados::IoCtxImpl::cached_pool_names_lock"),
|
||||
objecter(NULL)
|
||||
aio_write_seq(0), objecter(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -201,8 +200,7 @@ librados::IoCtxImpl::IoCtxImpl(RadosClient *c, Objecter *objecter,
|
||||
assert_ver(0), last_objver(0),
|
||||
notify_timeout(c->cct->_conf->client_notify_timeout),
|
||||
oloc(poolid), aio_write_list_lock("librados::IoCtxImpl::aio_write_list_lock"),
|
||||
aio_write_seq(0), cached_pool_names_lock("librados::IoCtxImpl::cached_pool_names_lock"),
|
||||
objecter(objecter)
|
||||
aio_write_seq(0), objecter(objecter)
|
||||
{
|
||||
}
|
||||
|
||||
@ -323,12 +321,7 @@ const string& librados::IoCtxImpl::get_cached_pool_name()
|
||||
std::string pn;
|
||||
client->pool_get_name(get_id(), &pn);
|
||||
|
||||
Mutex::Locker l(cached_pool_names_lock);
|
||||
|
||||
if (cached_pool_names.empty() || cached_pool_names.back() != pn)
|
||||
cached_pool_names.push_back(pn);
|
||||
|
||||
return cached_pool_names.back();
|
||||
return pn;
|
||||
}
|
||||
|
||||
// SNAPS
|
||||
|
@ -46,9 +46,6 @@ struct librados::IoCtxImpl {
|
||||
xlist<AioCompletionImpl*> aio_write_list;
|
||||
map<ceph_tid_t, std::list<AioCompletionImpl*> > aio_write_waiters;
|
||||
|
||||
Mutex cached_pool_names_lock;
|
||||
std::list<std::string> cached_pool_names;
|
||||
|
||||
Objecter *objecter;
|
||||
|
||||
IoCtxImpl();
|
||||
|
@ -490,6 +490,7 @@ bool librados::RadosClient::_dispatch(Message *m)
|
||||
break;
|
||||
|
||||
case CEPH_MSG_MDS_MAP:
|
||||
m->put();
|
||||
break;
|
||||
|
||||
case MSG_LOG:
|
||||
@ -526,13 +527,21 @@ int librados::RadosClient::wait_for_osdmap()
|
||||
if (cct->_conf->rados_mon_op_timeout > 0)
|
||||
timeout.set_from_double(cct->_conf->rados_mon_op_timeout);
|
||||
|
||||
bool wait_forever = false;
|
||||
if (timeout.is_zero()) {
|
||||
// we'll going to wait forever, but wake up every 1 seconds,
|
||||
// e.g., to avoid cpu burning.
|
||||
wait_forever = true;
|
||||
timeout = utime_t(1, 0);
|
||||
}
|
||||
|
||||
if (objecter->with_osdmap(std::mem_fn(&OSDMap::get_epoch)) == 0) {
|
||||
ldout(cct, 10) << __func__ << " waiting" << dendl;
|
||||
utime_t start = ceph_clock_now(cct);
|
||||
while (objecter->with_osdmap(std::mem_fn(&OSDMap::get_epoch)) == 0) {
|
||||
cond.WaitInterval(cct, lock, timeout);
|
||||
utime_t elapsed = ceph_clock_now(cct) - start;
|
||||
if (!timeout.is_zero() && elapsed > timeout) {
|
||||
if (!wait_forever && elapsed > timeout) {
|
||||
lderr(cct) << "timed out waiting for first osdmap from monitors"
|
||||
<< dendl;
|
||||
return -ETIMEDOUT;
|
||||
@ -848,8 +857,7 @@ int librados::RadosClient::osd_command(int osd, vector<string>& cmd,
|
||||
int r = objecter->osd_command(osd, cmd, inbl, &tid, poutbl, prs,
|
||||
new C_SafeCond(&mylock, &cond, &done, &ret));
|
||||
lock.Unlock();
|
||||
if (r != 0)
|
||||
return r;
|
||||
assert(r == 0);
|
||||
mylock.Lock();
|
||||
while (!done)
|
||||
cond.Wait(mylock);
|
||||
@ -870,8 +878,7 @@ int librados::RadosClient::pg_command(pg_t pgid, vector<string>& cmd,
|
||||
int r = objecter->pg_command(pgid, cmd, inbl, &tid, poutbl, prs,
|
||||
new C_SafeCond(&mylock, &cond, &done, &ret));
|
||||
lock.Unlock();
|
||||
if (r != 0)
|
||||
return r;
|
||||
assert(r == 0);
|
||||
mylock.Lock();
|
||||
while (!done)
|
||||
cond.Wait(mylock);
|
||||
|
Loading…
Reference in New Issue
Block a user