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 <yuggupta27@gmail.com>
(cherry picked from commit 365eb58ff7)
This commit is contained in:
Yug 2020-09-10 18:04:48 +05:30 committed by mergify[bot]
parent 0f51df99e8
commit b32569bc47

View File

@ -47,6 +47,7 @@ type volumeOptions struct {
KernelMountOptions string `json:"kernelMountOptions"` KernelMountOptions string `json:"kernelMountOptions"`
FuseMountOptions string `json:"fuseMountOptions"` FuseMountOptions string `json:"fuseMountOptions"`
SubvolumeGroup string SubvolumeGroup string
Features []string
} }
func validateNonEmptyField(field, fieldName string) error { func validateNonEmptyField(field, fieldName string) error {
@ -224,6 +225,7 @@ func newVolumeOptionsFromVolID(ctx context.Context, volID string, volOpt, secret
vi util.CSIIdentifier vi util.CSIIdentifier
volOptions volumeOptions volOptions volumeOptions
vid volumeIdentifier vid volumeIdentifier
info Subvolume
) )
// Decode the VolID first, to detect older volumes or pre-provisioned volumes // 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.ProvisionVolume = true
volOptions.RootPath, err = getVolumeRootPathCeph(ctx, &volOptions, cr, volumeID(vid.FsSubvolName))
if err != nil { info, err = getSubVolumeInfo(ctx, &volOptions, cr, volumeID(vid.FsSubvolName))
return &volOptions, &vid, err 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 // newVolumeOptionsFromMonitorList generates a new instance of volumeOptions and