Skip to content

Commit 28daf2e

Browse files
iPraveenPariharmergify[bot]
authored andcommitted
rbd: use StorageClass image features for temp clones and snapshots
Previously, temporary clone images (-temp) and snapshot backing images had their features hard-coded to only layering and deep-flatten. Inherit the image features from the parent volume (configured via StorageClass imageFeatures) while ensuring layering and deep-flatten are always enabled, as they are required for the flatten operation. Signed-off-by: Praveen M <m.praveen@ibm.com>
1 parent 2b92dc1 commit 28daf2e

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

internal/rbd/clone.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ func (rv *rbdVolume) checkCloneImage(ctx context.Context, parentVol *rbdVolume)
109109
func (rv *rbdVolume) generateTempClone() *rbdVolume {
110110
tempClone := rbdVolume{}
111111
tempClone.conn = rv.conn.Copy()
112-
// The temp clone image need to have deep flatten feature
112+
// Use the parent volume's image features (from StorageClass) and ensure
113+
// that layering and deep-flatten are always enabled, as these are
114+
// required for the flatten operation on the temporary clone.
113115
f := []string{librbd.FeatureNameLayering, librbd.FeatureNameDeepFlatten}
114-
tempClone.ImageFeatureSet = librbd.FeatureSetFromNames(f)
116+
tempClone.ImageFeatureSet = rv.ImageFeatureSet | librbd.FeatureSetFromNames(f)
115117
tempClone.ClusterID = rv.ClusterID
116118
tempClone.Monitors = rv.Monitors
117119
tempClone.Pool = rv.Pool

internal/rbd/controllerserver.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,9 +1391,10 @@ func (cs *ControllerServer) doSnapshotClone(
13911391
// generate cloned volume details from snapshot
13921392
cloneRbd := rbdSnap.toVolume()
13931393
defer cloneRbd.Destroy(ctx)
1394-
// add image feature for cloneRbd
1394+
// Use the parent volume's image features and ensure that layering and
1395+
// deep-flatten are always enabled for the snapshot backing image.
13951396
f := []string{librbd.FeatureNameLayering, librbd.FeatureNameDeepFlatten}
1396-
cloneRbd.ImageFeatureSet = librbd.FeatureSetFromNames(f)
1397+
cloneRbd.ImageFeatureSet = parentVol.ImageFeatureSet | librbd.FeatureSetFromNames(f)
13971398

13981399
// For snapshot creation, the temporary clone must use the same data pool as the parent
13991400
// volume to ensure correct storage placement for erasure-coded pools.

internal/rbd/snapshot.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,10 @@ func (rv *rbdVolume) NewSnapshotByID(
292292
return nil, err
293293
}
294294

295-
// set the features for the clone image.
295+
// Use the parent volume's image features and ensure that layering and
296+
// deep-flatten are always enabled for the snapshot backing image.
296297
f := []string{librbd.FeatureNameLayering, librbd.FeatureNameDeepFlatten}
297-
rv.ImageFeatureSet = librbd.FeatureSetFromNames(f)
298+
rv.ImageFeatureSet |= librbd.FeatureSetFromNames(f)
298299

299300
options, err := rv.constructImageOptions(ctx)
300301
if err != nil {

0 commit comments

Comments
 (0)