Changed StatCache code and Improved small performance

This commit is contained in:
Takeshi Nakatani
2025-08-17 06:19:03 +00:00
committed by Andrew Gaul
parent c719e36f91
commit ba386a8d7a

View File

@ -978,7 +978,7 @@ bool DirStatCache::AddHasLock(const std::string& strpath, const struct stat* pst
}
}else{
// found not negative type
if(!hasNestedChildren && IS_NEGATIVE_OBJ(type)){
if(!hasNestedChildren && (IS_NEGATIVE_OBJ(type) || !iter->second->isSameObjectTypeHasLock(type))){
// strpath is a direct child as negative cache
children.erase(iter);
iter = children.end();
@ -990,18 +990,18 @@ bool DirStatCache::AddHasLock(const std::string& strpath, const struct stat* pst
// found
if(hasNestedChildren){
// Add an under child
return iter->second->AddHasLock(strpath, pstat, pmeta, type, is_notruncate);
if(!iter->second->AddHasLock(strpath, pstat, pmeta, type, is_notruncate)){
return false;
}
}else{
// Add as a child
if(!iter->second->isSameObjectTypeHasLock(type)){
// The type(other than negative type) of object found is different
return false;
}else{
// Already has strpath child, so set stat and meta.
if(!iter->second->UpdateHasLock(pstat, pmeta, true) || !iter->second->UpdateHasLock(is_notruncate) || !iter->second->UpdateHasLock()){
return false;
}
return true;
}
// Already has strpath child, so set stat and meta.
if(!iter->second->UpdateHasLock(pstat, pmeta, true) || !iter->second->UpdateHasLock(is_notruncate) || !iter->second->UpdateHasLock()){
return false;
}
}
}else{
@ -1081,6 +1081,10 @@ bool DirStatCache::AddHasLock(const std::string& strpath, const struct stat* pst
children[strLeafName] = std::move(pstatcache);
}
}
if(!UpdateHasLock()){
return false;
}
return true;
}
@ -1090,7 +1094,9 @@ s3obj_type_map_t::size_type DirStatCache::GetChildMapHasLock(s3obj_type_map_t& c
std::lock_guard<std::mutex> dircachelock(dir_cache_lock);
for(const auto& pair: children){
childmap[pair.first] = pair.second->GetTypeHasLock();
if(!pair.second->isNegativeHasLock()){
childmap[pair.first] = pair.second->GetTypeHasLock();
}
}
return childmap.size();
}