rbd: add one depth for softlimit of snapshot for restore PVC

Currently, while preparing a volume for snapshot,
the depthToAvoidFlatten is set to 2. This accounts one
for snapshot and another since parent of the volume is
flattened.
This commit modifies the depth to 3 to also account for
future PVC restore since
- snapshot alone is useless and it is very likely to be restore
  at one point in time.
- this ensures snapshot is not flattened when restore does occur.
- flattening of snapshot in the above case will make the snapshot
  no longer eligible for changed block tracking(snap diff)
  operation.
- maintain similarity with PVC-PVC clone operation which currently
  depthToAvoidFlatten set to 1.

Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
Rakshith R 2025-03-13 14:24:15 +05:30 committed by mergify[bot]
parent dd68f1a0bc
commit 6f802589aa

View File

@ -2255,8 +2255,9 @@ func (rv *rbdVolume) PrepareVolumeForSnapshot(ctx context.Context, cr *util.Cred
return err
}
// choosing 2, since snapshot adds one depth and we'll be flattening the parent.
const depthToAvoidFlatten = 2
// choosing 3, since snapshot adds one depth, restore pvc will add one in future
// and we'll be flattening the parent.
const depthToAvoidFlatten = 3
if rbdHardMaxCloneDepth > depthToAvoidFlatten {
hardLimit = rbdHardMaxCloneDepth - depthToAvoidFlatten
}