From f8fbf2e95afe714928179553712b1b99d3058789 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Tue, 18 Jun 2024 11:19:11 +0200 Subject: [PATCH] journal: add volumeMap to the group instead of adding single volumes to the group journal, support adding multiple volumeID's map to the group journal which is required for RBD as well. Signed-off-by: Madhu Rajanna --- internal/cephfs/groupcontrollerserver.go | 10 ++++---- internal/journal/volumegroupjournal.go | 30 ++++++++++++------------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/internal/cephfs/groupcontrollerserver.go b/internal/cephfs/groupcontrollerserver.go index 40421517c..b5dfeaabb 100644 --- a/internal/cephfs/groupcontrollerserver.go +++ b/internal/cephfs/groupcontrollerserver.go @@ -461,11 +461,13 @@ func (cs *ControllerServer) createSnapshotAndAddMapping( } defer j.Destroy() // Add the snapshot to the volume group journal - err = j.AddVolumeMapping(ctx, + err = j.AddVolumesMapping(ctx, vgo.MetadataPool, vgs.ReservedID, - req.GetSourceVolumeId(), - resp.GetSnapshot().GetSnapshotId()) + map[string]string{ + req.GetSourceVolumeId(): resp.GetSnapshot().GetSnapshotId(), + }, + ) if err != nil { log.ErrorLog(ctx, "failed to add volume snapshot mapping: %v", err) // Delete the last created snapshot as its still not added to the @@ -640,7 +642,7 @@ func (cs *ControllerServer) deleteSnapshotsAndUndoReservation(ctx context.Contex return err } // remove the entry from the omap - err = j.RemoveVolumeMapping( + err = j.RemoveVolumesMapping( ctx, vgo.MetadataPool, vgsi.ReservedID, diff --git a/internal/journal/volumegroupjournal.go b/internal/journal/volumegroupjournal.go index 4663731aa..990c38d85 100644 --- a/internal/journal/volumegroupjournal.go +++ b/internal/journal/volumegroupjournal.go @@ -55,17 +55,18 @@ type VolumeGroupJournal interface { journalPoolID int64, reqName, namePrefix string) (string, string, error) - // AddVolumeMapping adds a volumeID and value mapping to the UUID + // AddVolumesMapping adds a volumeMap map which contains volumeID's and its + // corresponding values mapping which need to be added to the UUID // directory. value can be anything which needs mapping, in case of - // volumegroupsnapshot its a snapshotID and its empty in case of volumegroup. - AddVolumeMapping( + // volumegroupsnapshot its a snapshotID and its empty in case of + // volumegroup. + AddVolumesMapping( ctx context.Context, pool, - reservedUUID, - volumeID, - value string) error - // RemoveVolumeMapping removes volumeIDs mapping from the UUID directory. - RemoveVolumeMapping( + reservedUUID string, + volumeMap map[string]string) error + // RemoveVolumesMapping removes volumeIDs mapping from the UUID directory. + RemoveVolumesMapping( ctx context.Context, pool, reservedUUID string, @@ -403,17 +404,16 @@ func (vgjc *VolumeGroupJournalConnection) GetVolumeGroupAttributes( return groupAttributes, nil } -func (vgjc *VolumeGroupJournalConnection) AddVolumeMapping( +func (vgjc *VolumeGroupJournalConnection) AddVolumesMapping( ctx context.Context, pool, - reservedUUID, - volumeID, - value string, + reservedUUID string, + volumeMap map[string]string, ) error { err := setOMapKeys(ctx, vgjc.connection, pool, vgjc.config.namespace, vgjc.config.cephUUIDDirectoryPrefix+reservedUUID, - map[string]string{volumeID: value}) + volumeMap) if err != nil { - log.ErrorLog(ctx, "failed adding volume mapping: %v", err) + log.ErrorLog(ctx, "failed to add volumeMap %v: %w ", volumeMap, err) return err } @@ -421,7 +421,7 @@ func (vgjc *VolumeGroupJournalConnection) AddVolumeMapping( return nil } -func (vgjc *VolumeGroupJournalConnection) RemoveVolumeMapping( +func (vgjc *VolumeGroupJournalConnection) RemoveVolumesMapping( ctx context.Context, pool, reservedUUID string,