Skip to content

Commit

Permalink
eosfs: set initial quota depending on user type
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Jun 11, 2024
1 parent e08a0ba commit 231e3d5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/eos-userquota.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: differentiate quota for user types in EOS

We now assign a different initial quota to users depending
on their type, whether PRIMARY or not.

https://github.com/cs3org/reva/pull/4720
3 changes: 3 additions & 0 deletions pkg/storage/utils/eosfs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ type Config struct {
// DefaultQuotaBytes sets the default maximum bytes available for a user
DefaultQuotaBytes uint64 `mapstructure:"default_quota_bytes"`

// DefaultSecondaryQuotaBytes sets the default maximum bytes available for a secondary user
DefaultSecondaryQuotaBytes uint64 `mapstructure:"default_secondary_quota_bytes"`

// DefaultQuotaFiles sets the default maximum files available for a user
DefaultQuotaFiles uint64 `mapstructure:"default_quota_files"`

Expand Down
11 changes: 9 additions & 2 deletions pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func (c *Config) ApplyDefaults() {
if c.DefaultQuotaBytes == 0 {
c.DefaultQuotaBytes = 2000000000000 // 1 TB logical
}
if c.DefaultSecondaryQuotaBytes == 0 {
c.DefaultSecondaryQuotaBytes = c.DefaultQuotaBytes
}
if c.DefaultQuotaFiles == 0 {
c.DefaultQuotaFiles = 1000000 // 1 Million
}
Expand Down Expand Up @@ -1489,12 +1492,16 @@ func (fs *eosfs) createNominalHome(ctx context.Context) error {
return err
}

// set quota for user
// set quota for user, depending on its type
quotaBytes := fs.conf.DefaultQuotaBytes
if u.Id.Type != userpb.UserType_USER_TYPE_PRIMARY {
quotaBytes = fs.conf.DefaultSecondaryQuotaBytes
}
quotaInfo := &eosclient.SetQuotaInfo{
Username: u.Username,
UID: auth.Role.UID,
GID: auth.Role.GID,
MaxBytes: fs.conf.DefaultQuotaBytes,
MaxBytes: quotaBytes,
MaxFiles: fs.conf.DefaultQuotaFiles,
QuotaNode: fs.conf.QuotaNode,
}
Expand Down

0 comments on commit 231e3d5

Please sign in to comment.