From 591ba3f580c099f4e74a7f2d39a23bf78083bbf0 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Fri, 18 Jun 2021 09:42:48 +0530 Subject: [PATCH] rbd: set thick provision metadata on clone volume the parent volume(CreateVolume) and the clone volume (CreateSnapshot) are both indepedent and parent volume can be deleted anytime. To check the thick provision during Snapshot restore(CreateVolume from snapshot) we need the thick provision metadata so for the same reason setting the thick provision metadata on the clone image we are creating at the CreateSnapshot time. Signed-off-by: Madhu Rajanna --- internal/rbd/controllerserver.go | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index 4f9d535ac..deab669cd 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -895,6 +895,30 @@ func cloneFromSnapshot(ctx context.Context, rbdVol *rbdVolume, rbdSnap *rbdSnaps } } + // The clone image created during CreateSnapshot has to be marked as thick. + // As snapshot and volume both are independent we cannot depend on the + // parent volume of the clone to check thick provision during CreateVolume + // from snapshot operation because the parent volume can be deleted anytime + // after snapshot is created. + // TODO: copy thick provision config + thick, err := rbdVol.isThickProvisioned() + if err != nil { + return nil, status.Errorf(codes.Internal, "failed checking thick-provisioning of %q: %s", rbdVol, err) + } + + if thick { + // check the thick metadata is already set on the clone image. + thick, err = vol.isThickProvisioned() + if err != nil { + return nil, status.Errorf(codes.Internal, "failed checking thick-provisioning of %q: %s", vol, err) + } + if !thick { + err = vol.setThickProvisioned() + if err != nil { + return nil, status.Errorf(codes.Internal, "failed mark %q thick-provisioned: %s", vol, err) + } + } + } // if flattening is not needed, the snapshot is ready for use readyToUse := true @@ -986,6 +1010,24 @@ func (cs *ControllerServer) doSnapshotClone(ctx context.Context, parentVol *rbdV } } + // The clone image created during CreateSnapshot has to be marked as thick. + // As snapshot and volume both are independent we cannot depend on the + // parent volume of the clone to check thick provision during CreateVolume + // from snapshot operation because the parent volume can be deleted anytime + // after snapshot is created. + // TODO: copy thick provision config + thick, err := parentVol.isThickProvisioned() + if err != nil { + return ready, nil, status.Errorf(codes.Internal, "failed checking thick-provisioning of %q: %s", parentVol, err) + } + + if thick { + err = cloneRbd.setThickProvisioned() + if err != nil { + return ready, nil, status.Errorf(codes.Internal, "failed mark %q thick-provisioned: %s", cloneRbd, err) + } + } + err = cloneRbd.createSnapshot(ctx, rbdSnap) if err != nil { // update rbd image name for logging