@@ -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 "
0 commit comments