Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced availablebytes -> totalbytes, as this was erroneously used #5082

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/broken-quota.md
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/eosclient/eosclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 2 additions & 10 deletions pkg/eosclient/eosgrpc/eosgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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) {
Expand Down