mirror of
https://github.com/ceph/ceph
synced 2025-02-14 14:28:36 +00:00
Merge pull request #33753 from ukernel/wip-44448
mds: fix 'if there is lock cache on dir' check
This commit is contained in:
commit
ca0978a892
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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; }
|
||||
|
Loading…
Reference in New Issue
Block a user