Skip to content

Commit 687eb22

Browse files
tavisitccaffy
authored andcommitted
MGM: Quota recomputation that affects the namespace quota should also trigger a refresh of the space quota - all while making sure stall entries from the space quota are removed before applying the ns quota updates.
1 parent facb225 commit 687eb22

3 files changed

Lines changed: 55 additions & 2 deletions

File tree

mgm/proc/admin/NsCmd.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,8 +950,14 @@ NsCmd::QuotaSizeSubcmd(const eos::console::NsProto_QuotaSizeProto& tree,
950950
cont_id, cont_uri.c_str());
951951
} else {
952952
quotaNode->replaceCore(qnc);
953-
eos_info("msg=\"quota recomputation successful\" cxid=%08llx path=\"%s\"",
954-
cont_id, cont_uri.c_str());
953+
if (Quota::RefreshFromNsQuota(cont_uri)) {
954+
eos_info("msg=\"quota recomputation successful\" cxid=%08llx path=\"%s\"",
955+
cont_id, cont_uri.c_str());
956+
} else {
957+
eos_warning("msg=\"quota recomputation failed to refresh SpaceQuota\" "
958+
"cxid=%08llx path=\"%s\"",
959+
cont_id, cont_uri.c_str());
960+
}
955961
}
956962
} catch (const eos::MDException& e) {
957963
eos_err("msg=\"quota recomputation failed, directory removed\" "

mgm/quota/Quota.cc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2395,4 +2395,43 @@ Quota::AddFile(eos::IFileMD::id_t fid)
23952395
return false;
23962396
}
23972397

2398+
//------------------------------------------------------------------------------
2399+
// Force refresh of space quota from namespace quota node
2400+
//------------------------------------------------------------------------------
2401+
bool
2402+
Quota::RefreshFromNsQuota(const std::string& path)
2403+
{
2404+
eos::common::RWMutexReadLock rd_quota_lock(pMapMutex);
2405+
SpaceQuota* squota = GetResponsibleSpaceQuota(path);
2406+
2407+
if (!squota || squota->GetSpaceNameStr().compare(path)) {
2408+
return false;
2409+
}
2410+
2411+
{
2412+
XrdSysMutexHelper scope_lock(squota->mMutex);
2413+
auto it = squota->mMapIdQuota.begin();
2414+
while (it != squota->mMapIdQuota.end()) {
2415+
unsigned long tag = squota->UnIndex(it->first);
2416+
2417+
// Only remove "Is" tags
2418+
if (tag == SpaceQuota::kUserBytesIs || tag == SpaceQuota::kUserLogicalBytesIs ||
2419+
tag == SpaceQuota::kUserFilesIs || tag == SpaceQuota::kGroupBytesIs ||
2420+
tag == SpaceQuota::kGroupLogicalBytesIs || tag == SpaceQuota::kGroupFilesIs ||
2421+
tag == SpaceQuota::kAllUserBytesIs ||
2422+
tag == SpaceQuota::kAllUserLogicalBytesIs ||
2423+
tag == SpaceQuota::kAllUserFilesIs || tag == SpaceQuota::kAllGroupBytesIs ||
2424+
tag == SpaceQuota::kAllGroupLogicalBytesIs ||
2425+
tag == SpaceQuota::kAllGroupFilesIs) {
2426+
it = squota->mMapIdQuota.erase(it);
2427+
} else {
2428+
++it;
2429+
}
2430+
}
2431+
}
2432+
squota->Refresh(0);
2433+
2434+
return true;
2435+
}
2436+
23982437
EOSMGMNAMESPACE_END

mgm/quota/Quota.hh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,14 @@ public:
641641
//----------------------------------------------------------------------------
642642
static bool AddFile(eos::IFileMD::id_t fid);
643643

644+
//----------------------------------------------------------------------------
645+
//! Force refresh of space quota from namespace quota node
646+
//!
647+
//! @param path quota node path
648+
//!
649+
//! @return true if refresh successful, otherwise false
650+
//----------------------------------------------------------------------------
651+
static bool RefreshFromNsQuota(const std::string& path);
644652

645653
static gid_t gProjectId; ///< gid indicating project quota
646654
static eos::common::RWMutex pMapMutex; ///< Protect access to pMapQuota

0 commit comments

Comments
 (0)