From 2830824381ba62d91d25776502cde2df1505960b Mon Sep 17 00:00:00 2001 From: Rudy Zhang Date: Tue, 21 Aug 2018 17:18:38 +0800 Subject: [PATCH] bugfix: can't quota on disk quota Can't quota on diskquota when mount file system without diskquota. Signed-off-by: Rudy Zhang --- storage/quota/grpquota.go | 17 ++++++++++++----- storage/quota/prjquota.go | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/storage/quota/grpquota.go b/storage/quota/grpquota.go index db9d17b2c..8ddcb23cd 100644 --- a/storage/quota/grpquota.go +++ b/storage/quota/grpquota.go @@ -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 @@ -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. diff --git a/storage/quota/prjquota.go b/storage/quota/prjquota.go index 22be7ab0b..531c711f3 100644 --- a/storage/quota/prjquota.go +++ b/storage/quota/prjquota.go @@ -185,6 +185,11 @@ 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, " ") @@ -192,14 +197,16 @@ func (quota *PrjQuotaDriver) 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 prjquota or not. for _, value := range strings.Split(parts[3], ",") { if value == "prjquota" { return mountPoint, true, fsType @@ -207,7 +214,7 @@ func (quota *PrjQuotaDriver) CheckMountpoint(devID uint64) (string, bool, string } } - return "", false, "" + return mountPoint, false, fsType } // setQuota uses system tool "setquota" to set project quota for binding of limit and mountpoint and quotaID.