Skip to content

Commit d754032

Browse files
authored
eosfs: set initial quota depending on user type (#4720)
1 parent e08a0ba commit d754032

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

changelog/unreleased/eos-userquota.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Enhancement: differentiate quota for user types in EOS
2+
3+
We now assign a different initial quota to users depending
4+
on their type, whether PRIMARY or not.
5+
6+
https://github.com/cs3org/reva/pull/4720

pkg/storage/utils/eosfs/config.go

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ type Config struct {
2929
// DefaultQuotaBytes sets the default maximum bytes available for a user
3030
DefaultQuotaBytes uint64 `mapstructure:"default_quota_bytes"`
3131

32+
// DefaultSecondaryQuotaBytes sets the default maximum bytes available for a secondary user
33+
DefaultSecondaryQuotaBytes uint64 `mapstructure:"default_secondary_quota_bytes"`
34+
3235
// DefaultQuotaFiles sets the default maximum files available for a user
3336
DefaultQuotaFiles uint64 `mapstructure:"default_quota_files"`
3437

pkg/storage/utils/eosfs/eosfs.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ func (c *Config) ApplyDefaults() {
101101
if c.DefaultQuotaBytes == 0 {
102102
c.DefaultQuotaBytes = 2000000000000 // 1 TB logical
103103
}
104+
if c.DefaultSecondaryQuotaBytes == 0 {
105+
c.DefaultSecondaryQuotaBytes = c.DefaultQuotaBytes
106+
}
104107
if c.DefaultQuotaFiles == 0 {
105108
c.DefaultQuotaFiles = 1000000 // 1 Million
106109
}
@@ -1489,12 +1492,16 @@ func (fs *eosfs) createNominalHome(ctx context.Context) error {
14891492
return err
14901493
}
14911494

1492-
// set quota for user
1495+
// set quota for user, depending on its type
1496+
quotaBytes := fs.conf.DefaultQuotaBytes
1497+
if u.Id.Type != userpb.UserType_USER_TYPE_PRIMARY {
1498+
quotaBytes = fs.conf.DefaultSecondaryQuotaBytes
1499+
}
14931500
quotaInfo := &eosclient.SetQuotaInfo{
14941501
Username: u.Username,
14951502
UID: auth.Role.UID,
14961503
GID: auth.Role.GID,
1497-
MaxBytes: fs.conf.DefaultQuotaBytes,
1504+
MaxBytes: quotaBytes,
14981505
MaxFiles: fs.conf.DefaultQuotaFiles,
14991506
QuotaNode: fs.conf.QuotaNode,
15001507
}

0 commit comments

Comments
 (0)