From 5baed6190cd1048c72a5098c0d2fff96e969ff84 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 21 Oct 2020 13:20:52 +0200 Subject: [PATCH] cephfs: implement resizeVolume() with go-ceph Reduce the number of calls to the `ceph fs` executable to improve performance of CephFS volume resizing. Signed-off-by: Niels de Vos --- internal/cephfs/volume.go | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/internal/cephfs/volume.go b/internal/cephfs/volume.go index d81a12595..e52c1390a 100644 --- a/internal/cephfs/volume.go +++ b/internal/cephfs/volume.go @@ -20,7 +20,6 @@ import ( "context" "fmt" "path" - "strconv" "strings" "github.com/ceph/ceph-csi/internal/util" @@ -188,26 +187,13 @@ func (vo *volumeOptions) resizeVolume(ctx context.Context, cr *util.Credentials, // resize subvolume when either it's supported, or when corresponding // clusterID key was not present. if clusterAdditionalInfo[vo.ClusterID].resizeSupported || !keyPresent { - args := []string{ - "fs", - "subvolume", - "resize", - vo.FsName, - string(volID), - strconv.FormatInt(bytesQuota, 10), - "--group_name", - vo.SubvolumeGroup, - "-m", vo.Monitors, - "-c", util.CephConfigPath, - "-n", cephEntityClientPrefix + cr.ID, - "--keyfile=" + cr.KeyFile, + fsa, err := vo.conn.GetFSAdmin() + if err != nil { + util.ErrorLog(ctx, "could not get FSAdmin, can not resize volume %s:", vo.FsName, err) + return err } - err := execCommandErr( - ctx, - "ceph", - args[:]...) - + _, err = fsa.ResizeSubVolume(vo.FsName, vo.SubvolumeGroup, string(volID), fsAdmin.ByteCount(bytesQuota), true) if err == nil { clusterAdditionalInfo[vo.ClusterID].resizeSupported = true return nil