From 6f802589aaccb7ac472b90a4c5dbfdb44f24bd42 Mon Sep 17 00:00:00 2001 From: Rakshith R Date: Thu, 13 Mar 2025 14:24:15 +0530 Subject: [PATCH] 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 --- internal/rbd/rbd_util.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index 8c49ce12a..f01ee79e2 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -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 }