mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rbd: use DeepCopy to create a thick-provisioned clone
To create a full-allocated RBD image from a snapshot/clone DeepCopy() can be used. This is needed when the parent of the new volume is thick-provisioner, so that the new volume is independent of the parent and thick-provisioned as well. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
334f237e23
commit
6cc11c15d3
@ -1508,6 +1508,32 @@ func (rv *rbdVolume) RepairThickProvision() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopy creates an independent image (dest) from the source image. This
|
||||
// process may take some time when the image is large.
|
||||
func (rv *rbdVolume) DeepCopy(dest *rbdVolume) error {
|
||||
opts := librbd.NewRbdImageOptions()
|
||||
defer opts.Destroy()
|
||||
|
||||
// when doing DeepCopy, also flatten the new image
|
||||
err := opts.SetUint64(librbd.ImageOptionFlatten, 1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = dest.openIoctx()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
image, err := rv.open()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer image.Close()
|
||||
|
||||
return image.DeepCopy(dest.ioctx, dest.RbdImageName, opts)
|
||||
}
|
||||
|
||||
func (rv *rbdVolume) listSnapshots() ([]librbd.SnapInfo, error) {
|
||||
image, err := rv.open()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user