From b1045364d9e69d69050ed8d19c323b5b66ba72f2 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 16 Jun 2021 17:19:55 +0200 Subject: [PATCH] rbd: disable FeatureDeepFlatten when doing DeepCopy() Not all Linux kernels support the deep-flatten feature. Disabling the feature makes it possible to map RBD images on older kernels (like what minikube uses). Signed-off-by: Niels de Vos --- internal/rbd/rbd_util.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index afac474c0..f2a6fbbc1 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -1531,7 +1531,24 @@ func (rv *rbdVolume) DeepCopy(dest *rbdVolume) error { } defer image.Close() - return image.DeepCopy(dest.ioctx, dest.RbdImageName, opts) + err = image.DeepCopy(dest.ioctx, dest.RbdImageName, opts) + if err != nil { + return err + } + + // deep-flatten is not supported by all clients, so disable it + return dest.DisableDeepFlatten() +} + +// DisableDeepFlatten removed the deep-flatten feature from the image. +func (rv *rbdVolume) DisableDeepFlatten() error { + image, err := rv.open() + if err != nil { + return err + } + defer image.Close() + + return image.UpdateFeatures(librbd.FeatureDeepFlatten, false) } func (rv *rbdVolume) listSnapshots() ([]librbd.SnapInfo, error) {