diff --git a/changelog/unreleased/broken-quota.md b/changelog/unreleased/broken-quota.md new file mode 100644 index 0000000000..7bd85be519 --- /dev/null +++ b/changelog/unreleased/broken-quota.md @@ -0,0 +1,5 @@ +Bugfix: wrong quota total reported + +The EOS `QuotaInfo` struct had fields for `AvailableBytes` and `AvailableInodes`, but these were used to mean the total. This is fixed now. + +https://github.com/cs3org/reva/pull/5082 \ No newline at end of file diff --git a/pkg/eosclient/eosbinary/eosbinary.go b/pkg/eosclient/eosbinary/eosbinary.go index cd38d26d45..cc1b84a0a1 100644 --- a/pkg/eosclient/eosbinary/eosbinary.go +++ b/pkg/eosclient/eosbinary/eosbinary.go @@ -1073,10 +1073,10 @@ func (c *Client) parseQuota(path, raw string) (*eosclient.QuotaInfo, error) { usedInodes, _ := strconv.ParseUint(usedInodesString, 10, 64) qi := &eosclient.QuotaInfo{ - AvailableBytes: maxBytes, - UsedBytes: usedBytes, - AvailableInodes: maxInodes, - UsedInodes: usedInodes, + TotalBytes: maxBytes, + UsedBytes: usedBytes, + TotalInodes: maxInodes, + UsedInodes: usedInodes, } return qi, nil } diff --git a/pkg/eosclient/eosclient.go b/pkg/eosclient/eosclient.go index bbbf31a428..c3e436a535 100644 --- a/pkg/eosclient/eosclient.go +++ b/pkg/eosclient/eosclient.go @@ -110,11 +110,11 @@ type Checksum struct { XSType string } -// QuotaInfo reports the available bytes and inodes for a particular user. +// QuotaInfo reports the total and used bytes and inodes for a particular user. // eos reports all quota values are unsigned long, see https://github.com/cern-eos/eos/blob/93515df8c0d5a858982853d960bec98f983c1285/mgm/Quota.hh#L135 type QuotaInfo struct { - AvailableBytes, UsedBytes uint64 - AvailableInodes, UsedInodes uint64 + TotalBytes, UsedBytes uint64 + TotalInodes, UsedInodes uint64 } // SetQuotaInfo encapsulates the information needed to diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 706c1baf6a..452f7912f6 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -852,18 +852,10 @@ func (c *Client) GetQuota(ctx context.Context, username string, rootAuth eosclie for i := 0; i < len(resp.Quota.Quotanode); i++ { log.Debug().Str("func", "GetQuota").Str("quotanode:", fmt.Sprintf("%d: %#v", i, resp.Quota.Quotanode[i])).Msg("") - mx := int64(resp.Quota.Quotanode[i].Maxlogicalbytes) - int64(resp.Quota.Quotanode[i].Usedbytes) - if mx < 0 { - mx = 0 - } - qi.AvailableBytes += uint64(mx) + qi.TotalBytes += max(uint64(resp.Quota.Quotanode[i].Maxlogicalbytes), 0) qi.UsedBytes += resp.Quota.Quotanode[i].Usedbytes - mx = int64(resp.Quota.Quotanode[i].Maxfiles) - int64(resp.Quota.Quotanode[i].Usedfiles) - if mx < 0 { - mx = 0 - } - qi.AvailableInodes += uint64(mx) + qi.TotalInodes += max(uint64(resp.Quota.Quotanode[i].Maxfiles), 0) qi.UsedInodes += resp.Quota.Quotanode[i].Usedfiles } diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index 5ea59221a3..5f56b96109 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -1202,7 +1202,7 @@ func (fs *eosfs) CreateStorageSpace(ctx context.Context, req *provider.CreateSto return nil, fmt.Errorf("unimplemented: CreateStorageSpace") } -func (fs *eosfs) GetQuota(ctx context.Context, ref *provider.Reference) (uint64, uint64, error) { +func (fs *eosfs) GetQuota(ctx context.Context, ref *provider.Reference) (totalbytes, usedbytes uint64, err error) { u, err := utils.GetUser(ctx) if err != nil { return 0, 0, errors.Wrap(err, "eosfs: no user in ctx") @@ -1221,7 +1221,7 @@ func (fs *eosfs) GetQuota(ctx context.Context, ref *provider.Reference) (uint64, return 0, 0, err } - return qi.AvailableBytes, qi.UsedBytes, nil + return qi.TotalBytes, qi.UsedBytes, nil } func (fs *eosfs) GetHome(ctx context.Context) (string, error) {