mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-23 23:00: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>
(cherry picked from commit 591ba3f580
)
This commit is contained in:
parent
a17eb07947
commit
f59051aa2e
@ -867,6 +867,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
|
||||||
|
|
||||||
@ -956,6 +980,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
|
||||||
|
Loading…
Reference in New Issue
Block a user