func (quota *GrpQuota) SetSubtree(dir string, qid uint32) (uint32, error) {
	logrus.Debugf("set subtree, dir: %s, quotaID: %d", dir, qid)
	if !UseQuota {
		return 0, nil
	}
	id := qid
	var err error
	if id == 0 {
		id = quota.GetFileAttr(dir)
		if id > 0 {
			return id, nil
		}
		id, err = quota.GetNextQuatoID()
	}
	if err != nil {
		return 0, err
	}
	strid := strconv.FormatUint(uint64(id), 10)
	_, _, _, err = exec.Run(0, "setfattr", "-n", "system.subtree", "-v", strid, dir)
	return id, err
}
SetSubtree is used to set quota id for directory,
setfattr -n system.subtree -v $QUOTAID
package quota
import (
	"fmt"
	"io/ioutil"
	"os"
	"strconv"
	"strings"
	"sync"
	"github.com/alibaba/pouch/pkg/bytefmt"
	"github.com/alibaba/pouch/pkg/exec"
	"github.com/sirupsen/logrus"
)
type GrpQuota struct {
	lock sync.Mutex
	quotaIDs map[uint32]uint32
	mountPoints map[uint64]string
	quotaLastID uint32
}
func (quota *GrpQuota) StartQuotaDriver(dir string) (string, error) {
	logrus.Debugf("start group quota driver: %s", dir)
	if !UseQuota {
		return "", nil
	}
	devID, err := GetDevID(dir)
	if err != nil {
		return "", err
	}
	quota.lock.Lock()
	defer quota.lock.Unlock()
	if mp, ok := quota.mountPoints[devID]; ok {
		return mp, nil
	}
	mountPoint, hasQuota, _ := quota.CheckMountpoint(devID)
	if len(mountPoint) == 0 {
		return mountPoint, fmt.Errorf("mountPoint not found: %s", dir)
	}
	if !hasQuota {
		_, _, _, err := exec.Run(0, "mount", "-o", "remount,grpquota", mountPoint)
		if err != nil {
			return "", err
		}
	}
	vfsVersion, quotaFilename, err := quota.getVFSVersionAndQuotaFile(devID)
	if err != nil {
		return "", err
	}
	filename := mountPoint + "/" + quotaFilename
	if _, err := os.Stat(filename); err != nil {
		os.Remove(mountPoint + "/aquota.user")
		header := []byte{0x27, 0x19, 0xc0, 0xd9, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3a, 0x09, 0x00, 0x80,
			0x3a, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
			0x00, 0x00, 0x05, 0x00, 0x00, 0x00}
		if vfsVersion == "vfsv1" {
			header[4] = 0x01
		}
		if writeErr := ioutil.WriteFile(filename, header, 644); writeErr != nil {
			logrus.Errorf("write file error. %s, %s, %s", filename, vfsVersion, writeErr)
			return mountPoint, writeErr
		}
		if _, _, _, err := exec.Run(0, "setquota", "-g", "-t", "43200", "43200", mountPoint); err != nil {
			os.Remove(filename)
			return mountPoint, err
		}
		if err := quota.setUserQuota(0, 0, mountPoint); err != nil {
			os.Remove(filename)
			return mountPoint, err
		}
	}
	exit, stdout, stderr, err := exec.Run(0, "quotaon", "-pg", mountPoint)
	if err != nil && exit != 1 {
		logrus.Errorf("quotaon failed, exit: %d, stdout: %s, stderr: %s, err: %v", exit, stdout, stderr, err)
		return "", fmt.Errorf("stderr: %s, err: %v", stderr, err)
	}
	if strings.Contains(stdout, " is on") {
		quota.mountPoints[devID] = mountPoint
		return mountPoint, nil
	}
	if _, _, _, err = exec.Run(0, "quotaon", mountPoint); err != nil {
		mountPoint = ""
	}
	quota.mountPoints[devID] = mountPoint
	return mountPoint, err
}