From: Yehuda Sadeh Date: Thu, 6 Mar 2014 21:07:20 +0000 (-0800) Subject: librados: don't hold client lock in certain operations X-Git-Tag: v0.86~213^2~104 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e2fa0cf219b23cf5beea883730b0a37fda386309;p=ceph.git librados: don't hold client lock in certain operations Signed-off-by: Yehuda Sadeh --- diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc index 6fc22ade16c..ee58524a7f5 100644 --- a/src/librados/IoCtxImpl.cc +++ b/src/librados/IoCtxImpl.cc @@ -66,13 +66,11 @@ int librados::IoCtxImpl::set_snap_write_context(snapid_t seq, vector& uint32_t librados::IoCtxImpl::get_object_hash_position(const std::string& oid) { - Mutex::Locker l(*lock); return objecter->get_object_hash_position(poolid, oid, oloc.nspace); } uint32_t librados::IoCtxImpl::get_object_pg_hash_position(const std::string& oid) { - Mutex::Locker l(*lock); return objecter->get_object_pg_hash_position(poolid, oid, oloc.nspace); } @@ -158,9 +156,7 @@ int librados::IoCtxImpl::snap_create(const char *snapName) Cond cond; bool done; Context *onfinish = new C_SafeCond(&mylock, &cond, &done, &reply); - lock->Lock(); reply = objecter->create_pool_snap(poolid, sName, onfinish); - lock->Unlock(); if (reply < 0) { delete onfinish; @@ -182,9 +178,7 @@ int librados::IoCtxImpl::selfmanaged_snap_create(uint64_t *psnapid) bool done; Context *onfinish = new C_SafeCond(&mylock, &cond, &done, &reply); snapid_t snapid; - lock->Lock(); reply = objecter->allocate_selfmanaged_snap(poolid, &snapid, onfinish); - lock->Unlock(); if (reply < 0) { delete onfinish; @@ -208,9 +202,7 @@ int librados::IoCtxImpl::snap_remove(const char *snapName) Cond cond; bool done; Context *onfinish = new C_SafeCond(&mylock, &cond, &done, &reply); - lock->Lock(); reply = objecter->delete_pool_snap(poolid, sName, onfinish); - lock->Unlock(); if (reply < 0) { delete onfinish; @@ -238,11 +230,9 @@ int librados::IoCtxImpl::selfmanaged_snap_rollback_object(const object_t& oid, ::ObjectOperation op; prepare_assert_ops(&op); op.rollback(snapid); - lock->Lock(); objecter->mutate(oid, oloc, op, snapc, ut, 0, onack, NULL, NULL); - lock->Unlock(); mylock.Lock(); while (!done) cond.Wait(mylock); @@ -256,6 +246,7 @@ int librados::IoCtxImpl::rollback(const object_t& oid, const char *snapName) lock->Lock(); snapid_t snap; +#warning should do that internally in osdmap with some other lock const map& pools = objecter->osdmap->get_pools(); const pg_pool_t& pg_pool = pools.find(poolid)->second; map::const_iterator p; @@ -283,10 +274,8 @@ int librados::IoCtxImpl::selfmanaged_snap_remove(uint64_t snapid) Mutex mylock("IoCtxImpl::selfmanaged_snap_remove::mylock"); Cond cond; bool done; - lock->Lock(); objecter->delete_selfmanaged_snap(poolid, snapid_t(snapid), new C_SafeCond(&mylock, &cond, &done, &reply)); - lock->Unlock(); mylock.Lock(); while (!done) cond.Wait(mylock); @@ -301,11 +290,9 @@ int librados::IoCtxImpl::pool_change_auid(unsigned long long auid) Mutex mylock("IoCtxImpl::pool_change_auid::mylock"); Cond cond; bool done; - lock->Lock(); objecter->change_pool_auid(poolid, new C_SafeCond(&mylock, &cond, &done, &reply), auid); - lock->Unlock(); mylock.Lock(); while (!done) cond.Wait(mylock); @@ -316,7 +303,6 @@ int librados::IoCtxImpl::pool_change_auid(unsigned long long auid) int librados::IoCtxImpl::pool_change_auid_async(unsigned long long auid, PoolAsyncCompletionImpl *c) { - Mutex::Locker l(*lock); objecter->change_pool_auid(poolid, new C_PoolAsync_Safe(c), auid); @@ -326,6 +312,7 @@ int librados::IoCtxImpl::pool_change_auid_async(unsigned long long auid, int librados::IoCtxImpl::snap_list(vector *snaps) { Mutex::Locker l(*lock); +#warning locking for this and following snap functions const pg_pool_t *pi = objecter->osdmap->get_pg_pool(poolid); for (map::const_iterator p = pi->snaps.begin(); p != pi->snaps.end(); @@ -388,9 +375,7 @@ int librados::IoCtxImpl::list(Objecter::ListContext *context, int max_entries) context->max_entries = max_entries; context->nspace = oloc.nspace; - lock->Lock(); objecter->list_objects(context, new C_SafeCond(&mylock, &cond, &done, &r)); - lock->Unlock(); mylock.Lock(); while(!done) @@ -403,7 +388,6 @@ int librados::IoCtxImpl::list(Objecter::ListContext *context, int max_entries) uint32_t librados::IoCtxImpl::list_seek(Objecter::ListContext *context, uint32_t pos) { - Mutex::Locker l(*lock); context->list.clear(); return objecter->list_objects_seek(context, pos); } @@ -523,9 +507,7 @@ int librados::IoCtxImpl::operate(const object_t& oid, ::ObjectOperation *o, Objecter::Op *objecter_op = objecter->prepare_mutate_op(oid, oloc, *o, snapc, ut, flags, NULL, oncommit, &ver); - lock->Lock(); objecter->op_submit(objecter_op); - lock->Unlock(); mylock.Lock(); while (!done) @@ -560,9 +542,7 @@ int librados::IoCtxImpl::operate_read(const object_t& oid, Objecter::Op *objecter_op = objecter->prepare_read_op(oid, oloc, *o, snap_seq, pbl, flags, onack, &ver); - lock->Lock(); objecter->op_submit(objecter_op); - lock->Unlock(); mylock.Lock(); while (!done) @@ -590,7 +570,6 @@ int librados::IoCtxImpl::aio_operate_read(const object_t &oid, Objecter::Op *objecter_op = objecter->prepare_read_op(oid, oloc, *o, snap_seq, pbl, flags, onack, &c->objver); - Mutex::Locker l(*lock); objecter->op_submit(objecter_op); return 0; } @@ -610,7 +589,6 @@ int librados::IoCtxImpl::aio_operate(const object_t& oid, c->io = this; queue_aio_write(c); - Mutex::Locker l(*lock); objecter->mutate(oid, oloc, *o, snap_context, ut, flags, onack, oncommit, &c->objver); @@ -630,7 +608,6 @@ int librados::IoCtxImpl::aio_read(const object_t oid, AioCompletionImpl *c, c->io = this; c->blp = pbl; - Mutex::Locker l(*lock); objecter->read(oid, oloc, off, len, snapid, pbl, 0, onack, &c->objver); @@ -652,7 +629,6 @@ int librados::IoCtxImpl::aio_read(const object_t oid, AioCompletionImpl *c, c->bl.push_back(buffer::create_static(len, buf)); c->blp = &c->bl; - Mutex::Locker l(*lock); objecter->read(oid, oloc, off, len, snapid, &c->bl, 0, onack, &c->objver); @@ -688,7 +664,6 @@ int librados::IoCtxImpl::aio_sparse_read(const object_t oid, onack->m_ops.sparse_read(off, len, m, data_bl, NULL); - Mutex::Locker l(*lock); objecter->read(oid, oloc, onack->m_ops, snap_seq, NULL, 0, onack, &c->objver); @@ -712,7 +687,6 @@ int librados::IoCtxImpl::aio_write(const object_t &oid, AioCompletionImpl *c, Context *onack = new C_aio_Ack(c); Context *onsafe = new C_aio_Safe(c); - Mutex::Locker l(*lock); objecter->write(oid, oloc, off, len, snapc, bl, ut, 0, onack, onsafe, &c->objver); @@ -735,7 +709,6 @@ int librados::IoCtxImpl::aio_append(const object_t &oid, AioCompletionImpl *c, Context *onack = new C_aio_Ack(c); Context *onsafe = new C_aio_Safe(c); - Mutex::Locker l(*lock); objecter->append(oid, oloc, len, snapc, bl, ut, 0, onack, onsafe, &c->objver); @@ -759,7 +732,6 @@ int librados::IoCtxImpl::aio_write_full(const object_t &oid, Context *onack = new C_aio_Ack(c); Context *onsafe = new C_aio_Safe(c); - Mutex::Locker l(*lock); objecter->write_full(oid, oloc, snapc, bl, ut, 0, onack, onsafe, &c->objver); @@ -781,7 +753,6 @@ int librados::IoCtxImpl::aio_remove(const object_t &oid, AioCompletionImpl *c) Context *onack = new C_aio_Ack(c); Context *onsafe = new C_aio_Safe(c); - Mutex::Locker l(*lock); objecter->remove(oid, oloc, snapc, ut, 0, onack, onsafe, &c->objver); @@ -796,7 +767,6 @@ int librados::IoCtxImpl::aio_stat(const object_t& oid, AioCompletionImpl *c, c->io = this; C_aio_stat_Ack *onack = new C_aio_stat_Ack(c, pmtime); - Mutex::Locker l(*lock); objecter->stat(oid, oloc, snap_seq, psize, &onack->mtime, 0, onack, &c->objver); @@ -811,7 +781,6 @@ int librados::IoCtxImpl::hit_set_list(uint32_t hash, AioCompletionImpl *c, c->is_read = true; c->io = this; - Mutex::Locker l(*lock); ::ObjectOperation rd; rd.hit_set_ls(pls, NULL); object_locator_t oloc(poolid); @@ -827,7 +796,6 @@ int librados::IoCtxImpl::hit_set_get(uint32_t hash, AioCompletionImpl *c, c->is_read = true; c->io = this; - Mutex::Locker l(*lock); ::ObjectOperation rd; rd.hit_set_get(utime_t(stamp, 0), pbl, 0); object_locator_t oloc(poolid); @@ -902,7 +870,6 @@ int librados::IoCtxImpl::aio_exec(const object_t& oid, AioCompletionImpl *c, c->is_read = true; c->io = this; - Mutex::Locker l(*lock); ::ObjectOperation rd; prepare_assert_ops(&rd); rd.call(cls, method, inbl); @@ -944,11 +911,9 @@ int librados::IoCtxImpl::mapext(const object_t& oid, int r; Context *onack = new C_SafeCond(&mylock, &cond, &done, &r); - lock->Lock(); objecter->mapext(oid, oloc, off, len, snap_seq, &bl, 0, onack); - lock->Unlock(); mylock.Lock(); while (!done) @@ -1073,6 +1038,8 @@ int librados::IoCtxImpl::watch(const object_t& oid, uint64_t ver, lock->Lock(); +#warning watch related locking? + WatchContext *wc = new WatchContext(this, oid, ctx); client->register_watcher(wc, cookie); prepare_assert_ops(&wr);