From b32569bc47d2f89a5abe9b309caf8446fbc47d4f Mon Sep 17 00:00:00 2001 From: Yug Date: Thu, 10 Sep 2020 18:04:48 +0530 Subject: [PATCH] cephfs: use subvolume info if available Use subvolume info to fetch the subvolume path. If `subvolume info` command is not available, use `getpath` command instead. Signed-off-by: Yug (cherry picked from commit 365eb58ff7134d3b738059684c447a5dc2209a0a) --- internal/cephfs/volumeoptions.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/internal/cephfs/volumeoptions.go b/internal/cephfs/volumeoptions.go index 51c186cb8..fe6ee8e89 100644 --- a/internal/cephfs/volumeoptions.go +++ b/internal/cephfs/volumeoptions.go @@ -47,6 +47,7 @@ type volumeOptions struct { KernelMountOptions string `json:"kernelMountOptions"` FuseMountOptions string `json:"fuseMountOptions"` SubvolumeGroup string + Features []string } func validateNonEmptyField(field, fieldName string) error { @@ -224,6 +225,7 @@ func newVolumeOptionsFromVolID(ctx context.Context, volID string, volOpt, secret vi util.CSIIdentifier volOptions volumeOptions vid volumeIdentifier + info Subvolume ) // Decode the VolID first, to detect older volumes or pre-provisioned volumes @@ -299,11 +301,18 @@ func newVolumeOptionsFromVolID(ctx context.Context, volID string, volOpt, secret } volOptions.ProvisionVolume = true - volOptions.RootPath, err = getVolumeRootPathCeph(ctx, &volOptions, cr, volumeID(vid.FsSubvolName)) - if err != nil { - return &volOptions, &vid, err + + info, err = getSubVolumeInfo(ctx, &volOptions, cr, volumeID(vid.FsSubvolName)) + if err == nil { + volOptions.RootPath = info.Path + volOptions.Features = info.Features } - return &volOptions, &vid, nil + + if errors.Is(err, ErrInvalidCommand) { + volOptions.RootPath, err = getVolumeRootPathCeph(ctx, &volOptions, cr, volumeID(vid.FsSubvolName)) + } + + return &volOptions, &vid, err } // newVolumeOptionsFromMonitorList generates a new instance of volumeOptions and