Merge pull request #33753 from ukernel/wip-44448

mds: fix 'if there is lock cache on dir' check
This commit is contained in:
Yan, Zheng 2020-03-24 10:07:36 +08:00 committed by GitHub
commit ca0978a892
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 12 deletions

View File

@ -802,6 +802,8 @@ void Locker::put_lock_cache(MDLockCache* lock_cache)
ceph_assert(lock_cache->invalidating);
lock_cache->detach_locks();
CInode *diri = lock_cache->get_dir_inode();
for (auto dir : lock_cache->auth_pinned_dirfrags) {
if (dir->get_inode() != diri)
@ -832,7 +834,7 @@ void Locker::invalidate_lock_cache(MDLockCache *lock_cache)
ceph_assert(!lock_cache->client_cap);
} else {
lock_cache->invalidating = true;
lock_cache->detach_all();
lock_cache->detach_dirfrags();
}
Capability *cap = lock_cache->client_cap;
@ -880,8 +882,10 @@ void Locker::invalidate_lock_caches(CDir *dir)
void Locker::invalidate_lock_caches(SimpleLock *lock)
{
dout(10) << "invalidate_lock_caches " << *lock << " on " << *lock->get_parent() << dendl;
while (lock->is_cached()) {
invalidate_lock_cache(lock->get_first_cache());
if (lock->is_cached()) {
auto&& lock_caches = lock->get_active_caches();
for (auto& lc : lock_caches)
invalidate_lock_cache(lc);
}
}

View File

@ -578,7 +578,7 @@ void MDLockCache::attach_dirfrags(std::vector<CDir*>&& dfv)
}
}
void MDLockCache::detach_all()
void MDLockCache::detach_locks()
{
ceph_assert(items_lock);
int i = 0;
@ -588,9 +588,12 @@ void MDLockCache::detach_all()
++i;
}
items_lock.reset();
}
void MDLockCache::detach_dirfrags()
{
ceph_assert(items_dir);
i = 0;
int i = 0;
for (auto dir : auth_pinned_dirfrags) {
(void)dir;
items_dir[i].item_dir.remove_myself();

View File

@ -496,7 +496,8 @@ struct MDLockCache : public MutationImpl {
void attach_locks();
void attach_dirfrags(std::vector<CDir*>&& dfv);
void detach_all();
void detach_locks();
void detach_dirfrags();
CInode *diri;
Capability *client_cap;

View File

@ -95,12 +95,14 @@ void SimpleLock::remove_cache(MDLockCacheItem& item) {
}
}
MDLockCache* SimpleLock::get_first_cache() {
std::vector<MDLockCache*> SimpleLock::get_active_caches() {
std::vector<MDLockCache*> result;
if (have_more()) {
auto& lock_caches = more()->lock_caches;
if (!lock_caches.empty()) {
return lock_caches.front()->parent;
for (auto it = more()->lock_caches.begin_use_current(); !it.end(); ++it) {
auto lock_cache = (*it)->parent;
if (!lock_cache->invalidating)
result.push_back(lock_cache);
}
}
return nullptr;
return result;
}

View File

@ -228,7 +228,7 @@ public:
}
void add_cache(MDLockCacheItem& item);
void remove_cache(MDLockCacheItem& item);
MDLockCache* get_first_cache();
std::vector<MDLockCache*> get_active_caches();
// state
int get_state() const { return state; }