Skip to content

Commit

Permalink
bugfix: can't quota on disk quota
Browse files Browse the repository at this point in the history
Can't quota on diskquota when mount file system without diskquota.

Signed-off-by: Rudy Zhang <rudyflyzhang@gmail.com>
  • Loading branch information
rudyfly committed Aug 21, 2018
1 parent 93622fa commit 822e154
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
12 changes: 11 additions & 1 deletion 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 @@ -192,12 +197,17 @@ func (quota *GrpQuotaDriver) CheckMountpoint(devID uint64) (string, bool, string
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

0 comments on commit 822e154

Please sign in to comment.