1
0
mirror of https://github.com/ceph/ceph-csi.git synced 2024-12-19 19:40:19 +00:00

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 <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2021-06-18 09:42:48 +05:30 committed by mergify[bot]
parent 6d14eeee70
commit 591ba3f580

View File

@ -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 // if flattening is not needed, the snapshot is ready for use
readyToUse := true 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) err = cloneRbd.createSnapshot(ctx, rbdSnap)
if err != nil { if err != nil {
// update rbd image name for logging // update rbd image name for logging