Skip to content

Commit 52c0963

Browse files
amadioesindril
authored andcommitted
MGM: Add option to allow setting quota by logical/raw bytes
1 parent 7f3f94c commit 52c0963

2 files changed

Lines changed: 26 additions & 12 deletions

File tree

mgm/Quota.cc

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,7 +1609,6 @@ Quota::SetQuotaTypeForId(const std::string& qpath, long id, Quota::IdT id_type,
16091609
}
16101610
}
16111611

1612-
std::string svalue = std::to_string(value);
16131612
oss_config << id << ":" << SpaceQuota::GetTagAsString(quota_tag);
16141613
eos::common::RWMutexReadLock rd_quota_lock(pMapMutex);
16151614
SpaceQuota* squota = GetSpaceQuota(path);
@@ -1620,25 +1619,37 @@ Quota::SetQuotaTypeForId(const std::string& qpath, long id, Quota::IdT id_type,
16201619
return false;
16211620
}
16221621

1623-
squota->SetQuota(quota_tag, id, value);
1624-
gOFS->mConfigEngine->SetConfigValue("quota", oss_config.str().c_str(),
1625-
svalue.c_str());
1626-
16271622
// When setting logical bytes quota, set also raw bytes for backward compatibility
16281623
if (quota_type == Type::kVolume) {
1629-
long long raw_bytes = value * squota->GetLayoutSizeFactor();
1630-
std::string raw_value = std::to_string(raw_bytes);
1624+
long long raw_bytes, log_bytes;
1625+
16311626
std::string raw_config = oss_config.str();
16321627
raw_config.erase(raw_config.find("logical"), 7);
16331628

1634-
oss_msg << "updating quota using " << value << "bytes (" << raw_bytes << " raw bytes)\n";
1629+
SpaceQuota::eQuotaTag quota_raw = (id_type == IdT::kUid) ? SpaceQuota::kUserBytesTarget
1630+
: SpaceQuota::kGroupBytesTarget;
16351631

1636-
if (id_type == IdT::kUid)
1637-
squota->SetQuota(SpaceQuota::kUserBytesTarget, id, raw_bytes);
1638-
else
1639-
squota->SetQuota(SpaceQuota::kGroupBytesTarget, id, raw_bytes);
1632+
if (getenv("EOS_MGM_QUOTA_SET_BY_LOGICAL")) {
1633+
log_bytes = value;
1634+
raw_bytes = value * squota->GetLayoutSizeFactor();
1635+
} else {
1636+
log_bytes = value / squota->GetLayoutSizeFactor();
1637+
raw_bytes = value;
1638+
}
16401639

1640+
std::string log_value = std::to_string(log_bytes);
1641+
std::string raw_value = std::to_string(raw_bytes);
1642+
1643+
oss_msg << "updating quota using " << log_bytes << " bytes (" << raw_bytes << " raw bytes)\n";
1644+
1645+
squota->SetQuota(quota_tag, id, log_bytes);
1646+
squota->SetQuota(quota_raw, id, raw_bytes);
1647+
gOFS->mConfigEngine->SetConfigValue("quota", oss_config.str().c_str(), log_value.c_str());
16411648
gOFS->mConfigEngine->SetConfigValue("quota", raw_config.c_str(), raw_value.c_str());
1649+
} else {
1650+
std::string svalue = std::to_string(value);
1651+
squota->SetQuota(quota_tag, id, value);
1652+
gOFS->mConfigEngine->SetConfigValue("quota", oss_config.str().c_str(), svalue.c_str());
16421653
}
16431654

16441655
oss_msg << "success: updated "

misc/etc/sysconfig/eos_env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ EOS_NOTIFY="mail -s `date +%s`-`hostname`-eos-notify $EOS_MAIL_CC"
119119
# If you only want to report the space acacounting you can define
120120
# EOS_MGM_STATVFS_ONLY_SPACE=1
121121

122+
# Set to 1 if you want eos quota set by logical space (default is by raw)
123+
# EOS_MGM_QUOTA_SET_BY_LOGICAL=1
124+
122125
# If variable defined then enable the use of xrootd connection pool i.e.
123126
# create/share different physical connections for transfers to the same
124127
# destination xrootd server. By default this is disabled.

0 commit comments

Comments
 (0)