Skip to content

Commit

Permalink
journal: add volumeMap to the group
Browse files Browse the repository at this point in the history
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 <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 committed Jun 18, 2024
1 parent 0651b97 commit 46aab0f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
11 changes: 7 additions & 4 deletions internal/cephfs/groupcontrollerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,14 @@ 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
Expand Down Expand Up @@ -640,7 +643,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,
Expand Down
30 changes: 15 additions & 15 deletions internal/journal/volumegroupjournal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -403,25 +404,24 @@ 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
}

return nil
}

func (vgjc *VolumeGroupJournalConnection) RemoveVolumeMapping(
func (vgjc *VolumeGroupJournalConnection) RemoveVolumesMapping(
ctx context.Context,
pool,
reservedUUID string,
Expand Down

0 comments on commit 46aab0f

Please sign in to comment.