mirror of
https://github.com/ceph/ceph
synced 2025-01-01 08:32:24 +00:00
Merge pull request #10562 from aclamk/wip-rgw-s3-keystone-cache-mutex
rgw: Got rid of recursive mutex. Reviewed-by: Casey Bodley <cbodley@redhat.com>
This commit is contained in:
commit
7a7dad82a2
@ -298,13 +298,17 @@ RGWKeystoneTokenCache& RGWKeystoneTokenCache::get_instance()
|
||||
static RGWKeystoneTokenCache instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool RGWKeystoneTokenCache::find(const string& token_id, KeystoneToken& token)
|
||||
{
|
||||
lock.Lock();
|
||||
Mutex::Locker l(lock);
|
||||
return find_locked(token_id, token);
|
||||
}
|
||||
|
||||
bool RGWKeystoneTokenCache::find_locked(const string& token_id, KeystoneToken& token)
|
||||
{
|
||||
assert(lock.is_locked_by_me());
|
||||
map<string, token_entry>::iterator iter = tokens.find(token_id);
|
||||
if (iter == tokens.end()) {
|
||||
lock.Unlock();
|
||||
if (perfcounter) perfcounter->inc(l_rgw_keystone_token_cache_miss);
|
||||
return false;
|
||||
}
|
||||
@ -314,7 +318,6 @@ bool RGWKeystoneTokenCache::find(const string& token_id, KeystoneToken& token)
|
||||
|
||||
if (entry.token.expired()) {
|
||||
tokens.erase(iter);
|
||||
lock.Unlock();
|
||||
if (perfcounter) perfcounter->inc(l_rgw_keystone_token_cache_hit);
|
||||
return false;
|
||||
}
|
||||
@ -323,7 +326,6 @@ bool RGWKeystoneTokenCache::find(const string& token_id, KeystoneToken& token)
|
||||
tokens_lru.push_front(token_id);
|
||||
entry.lru_iter = tokens_lru.begin();
|
||||
|
||||
lock.Unlock();
|
||||
if (perfcounter) perfcounter->inc(l_rgw_keystone_token_cache_hit);
|
||||
|
||||
return true;
|
||||
@ -333,13 +335,20 @@ bool RGWKeystoneTokenCache::find_admin(KeystoneToken& token)
|
||||
{
|
||||
Mutex::Locker l(lock);
|
||||
|
||||
return find(admin_token_id, token);
|
||||
return find_locked(admin_token_id, token);
|
||||
}
|
||||
|
||||
void RGWKeystoneTokenCache::add(const string& token_id,
|
||||
const KeystoneToken& token)
|
||||
{
|
||||
lock.Lock();
|
||||
Mutex::Locker l(lock);
|
||||
add_locked(token_id, token);
|
||||
}
|
||||
|
||||
void RGWKeystoneTokenCache::add_locked(const string& token_id,
|
||||
const KeystoneToken& token)
|
||||
{
|
||||
assert(lock.is_locked_by_me());
|
||||
map<string, token_entry>::iterator iter = tokens.find(token_id);
|
||||
if (iter != tokens.end()) {
|
||||
token_entry& e = iter->second;
|
||||
@ -358,8 +367,6 @@ void RGWKeystoneTokenCache::add(const string& token_id,
|
||||
tokens.erase(iter);
|
||||
tokens_lru.pop_back();
|
||||
}
|
||||
|
||||
lock.Unlock();
|
||||
}
|
||||
|
||||
void RGWKeystoneTokenCache::add_admin(const KeystoneToken& token)
|
||||
@ -367,7 +374,7 @@ void RGWKeystoneTokenCache::add_admin(const KeystoneToken& token)
|
||||
Mutex::Locker l(lock);
|
||||
|
||||
rgw_get_token_id(token.token.id, admin_token_id);
|
||||
add(admin_token_id, token);
|
||||
add_locked(admin_token_id, token);
|
||||
}
|
||||
|
||||
void RGWKeystoneTokenCache::invalidate(const string& token_id)
|
||||
|
@ -173,7 +173,7 @@ class RGWKeystoneTokenCache {
|
||||
RGWKeystoneTokenCache()
|
||||
: revocator(g_ceph_context, this),
|
||||
cct(g_ceph_context),
|
||||
lock("RGWKeystoneTokenCache", true /* recursive */),
|
||||
lock("RGWKeystoneTokenCache"),
|
||||
max(cct->_conf->rgw_keystone_token_cache_size) {
|
||||
/* The thread name has been kept for backward compliance. */
|
||||
revocator.create("rgw_swift_k_rev");
|
||||
@ -197,6 +197,10 @@ public:
|
||||
void add_admin(const KeystoneToken& token);
|
||||
void invalidate(const string& token_id);
|
||||
bool going_down() const;
|
||||
private:
|
||||
void add_locked(const string& token_id, const KeystoneToken& token);
|
||||
bool find_locked(const string& token_id, KeystoneToken& token);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user