Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions pkg/meta/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -884,9 +884,15 @@ func (m *baseMeta) handleQuotaList(ctx Context, qtype uint32, key uint64, quotas
}
}
for uid, quota := range filterOrAll(userQuotas, UserQuotaType) {
if quota.MaxInodes == -1 && quota.MaxSpace == -1 {
continue
}
quotas[fmt.Sprintf("uid:%d", uid)] = quota
}
for gid, quota := range filterOrAll(groupQuotas, GroupQuotaType) {
if quota.MaxInodes == -1 && quota.MaxSpace == -1 {
continue
}
quotas[fmt.Sprintf("gid:%d", gid)] = quota
}

Expand Down
19 changes: 14 additions & 5 deletions pkg/meta/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -4226,10 +4226,6 @@ func (m *redisMeta) doLoadQuotas(ctx Context) (map[uint64]*Quota, map[uint64]*Qu
continue
}

maxSpace, maxInodes := m.parseQuota(val)
if maxSpace < 0 && maxInodes < 0 {
continue
}
usedSpace, err := m.rdb.HGet(ctx, config.usedSpaceKey, key).Int64()
if err != nil && err != redis.Nil {
return err
Expand All @@ -4238,7 +4234,19 @@ func (m *redisMeta) doLoadQuotas(ctx Context) (map[uint64]*Quota, map[uint64]*Qu
if err != nil && err != redis.Nil {
return err
}

maxSpace, maxInodes := m.parseQuota(val)
if maxSpace < 0 && maxInodes < 0 && usedSpace == 0 && usedInodes == 0 {
_, err := m.rdb.TxPipelined(ctx, func(pipe redis.Pipeliner) error {
pipe.HDel(ctx, config.quotaKey, key)
pipe.HDel(ctx, config.usedSpaceKey, key)
pipe.HDel(ctx, config.usedInodesKey, key)
return nil
})
if err != nil {
logger.Errorf("failed to delete quota for key %s: %v", key, err)
}
continue
}
quotas[id] = &Quota{
MaxSpace: int64(maxSpace),
MaxInodes: int64(maxInodes),
Expand All @@ -4265,6 +4273,7 @@ func (m *redisMeta) doFlushQuotas(ctx Context, quotas []*iQuota) error {
}

field := strconv.FormatUint(q.qkey, 10)
pipe.HSetNX(ctx, config.quotaKey, field, m.packQuota(-1, -1))
pipe.HIncrBy(ctx, config.usedSpaceKey, field, q.quota.newSpace)
pipe.HIncrBy(ctx, config.usedInodesKey, field, q.quota.newInodes)
}
Expand Down
Loading