Skip to content

Commit

Permalink
cephfs: add support for RWX clone from ROX
Browse files Browse the repository at this point in the history
Add support to create RWX clone from the
ROX clone, in ceph no subvolume clone is
created when ROX clone is created from a
snapshot just a internal ref counter is
added. This PR allows creating a RWX clone
from a ROX clone which allows users to create
RW copy of PVC where cephcsi will identify
the snapshot created for the ROX volume and
creates a subvolume from the CephFS snapshot.

updates: ceph#3603

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 authored and iPraveenParihar committed Sep 6, 2023
1 parent c4dfc47 commit eca83fc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/cephfs/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,23 @@ func (cs *ControllerServer) CreateVolume(
return nil, status.Error(codes.InvalidArgument, err.Error())
}

// As we are trying to create RWX volume from backing snapshot, we need to
// retrieve the snapshot details from the backing snapshot and create a
// subvolume clone from the snapshot.
if parentVol != nil && parentVol.BackingSnapshot && !store.IsVolumeCreateRO(req.VolumeCapabilities) {
// unset pvID as we dont have real subvolume for the parent volumeID as its a backing snapshot
pvID = nil
parentVol, _, sID, err = store.NewSnapshotOptionsFromID(ctx, parentVol.BackingSnapshotID, cr,
req.GetSecrets(), cs.ClusterName, cs.SetMetadata)
if err != nil {
if errors.Is(err, cerrors.ErrSnapNotFound) {
return nil, status.Error(codes.NotFound, err.Error())
}

return nil, status.Error(codes.Internal, err.Error())
}
}

vID, err := store.CheckVolExists(ctx, volOptions, parentVol, pvID, sID, cr, cs.ClusterName, cs.SetMetadata)
if err != nil {
if cerrors.IsCloneRetryError(err) {
Expand Down

0 comments on commit eca83fc

Please sign in to comment.