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

bugfix: can't quota on disk quota #2133

Merged
merged 1 commit into from
Aug 21, 2018
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
17 changes: 12 additions & 5 deletions storage/quota/grpquota.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ func (quota *GrpQuotaDriver) CheckMountpoint(devID uint64) (string, bool, string
return "", false, ""
}

var (
mountPoint string
fsType string
)

// Two formats of group quota.
// /dev/sdb1 /home/pouch ext4 rw,relatime,prjquota,data=ordered 0 0
// /dev/sda1 /home/pouch ext4 rw,relatime,data=ordered,jqfmt=vfsv0,grpjquota=aquota.group 0 0
Expand All @@ -184,20 +189,22 @@ func (quota *GrpQuotaDriver) CheckMountpoint(devID uint64) (string, bool, string
continue
}

mountPoint := parts[1]
fsType := parts[2]

devID2, _ := system.GetDevID(mountPoint)
devID2, _ := system.GetDevID(parts[1])
if devID != devID2 {
continue
}

// get device's mountpoint and fs type.
mountPoint = parts[1]
fsType = parts[2]

// check the device turn on the prpquota or not.
if strings.Contains(parts[3], "grpquota") || strings.Contains(parts[3], "grpjquota") {
return mountPoint, true, fsType
}
}

return "", false, ""
return mountPoint, false, fsType
}

// SetDiskQuota is used to set quota for directory.
Expand Down
17 changes: 12 additions & 5 deletions storage/quota/prjquota.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,29 +185,36 @@ func (quota *PrjQuotaDriver) CheckMountpoint(devID uint64) (string, bool, string
return "", false, ""
}

var (
mountPoint string
fsType string
)

// /dev/sdb1 /home/pouch ext4 rw,relatime,prjquota,data=ordered 0 0
for _, line := range strings.Split(string(output), "\n") {
parts := strings.Split(line, " ")
if len(parts) != 6 {
continue
}

mountPoint := parts[1]
fsType := parts[2]

devID2, _ := system.GetDevID(mountPoint)
devID2, _ := system.GetDevID(parts[1])
if devID != devID2 {
continue
}

// get device's mountpoint and fs type.
mountPoint = parts[1]
fsType = parts[2]

// check the device turn on the prjquota or not.
for _, value := range strings.Split(parts[3], ",") {
if value == "prjquota" {
return mountPoint, true, fsType
}
}
}

return "", false, ""
return mountPoint, false, fsType
}

// setQuota uses system tool "setquota" to set project quota for binding of limit and mountpoint and quotaID.
Expand Down