File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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\" "
Original file line number Diff line number Diff 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+
23982437EOSMGMNAMESPACE_END
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments