From 4be53a27d343e6556d3843046c864bbcb4eacab5 Mon Sep 17 00:00:00 2001 From: Humble Chirammal Date: Wed, 8 Sep 2021 10:42:30 +0530 Subject: [PATCH] cleanup: replace parentName to snapParentName in checkReservation at present, eventhough the checkReservation works for both volume and snapshot, the arg parentName make sense only for snapshot cases renaming that arg to more approprite Signed-off-by: Humble Chirammal --- internal/journal/voljournal.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/journal/voljournal.go b/internal/journal/voljournal.go index 7f3c2f24b..9ffee3729 100644 --- a/internal/journal/voljournal.go +++ b/internal/journal/voljournal.go @@ -264,7 +264,7 @@ CheckReservation checks if given request name contains a valid reservation - If there is a valid reservation, then the corresponding ImageData for the volume/snapshot is returned - If there is a reservation that is stale (or not fully cleaned up), it is garbage collected using the UndoReservation call, as appropriate -- If a snapshot is being checked, then its source is matched to the parentName that is provided +- If a snapshot is being checked, then its source is matched to the snapParentName that is provided NOTE: As the function manipulates omaps, it should be called with a lock against the request name held, to prevent parallel operations from modifying the state of the omaps for this request name. @@ -275,7 +275,7 @@ Return values: - error: non-nil in case of any errors */ func (conn *Connection) CheckReservation(ctx context.Context, - journalPool, reqName, namePrefix, parentName, kmsConfig string) (*ImageData, error) { + journalPool, reqName, namePrefix, snapParentName, kmsConfig string) (*ImageData, error) { var ( snapSource bool objUUID string @@ -284,7 +284,7 @@ func (conn *Connection) CheckReservation(ctx context.Context, cj = conn.config ) - if parentName != "" { + if snapParentName != "" { if cj.cephSnapSourceKey == "" { err := errors.New("invalid request, cephSnapSourceKey is nil") @@ -378,12 +378,12 @@ func (conn *Connection) CheckReservation(ctx context.Context, if snapSource { // check if source UUID key points back to the parent volume passed in - if savedImageAttributes.SourceName != parentName { + if savedImageAttributes.SourceName != snapParentName { // NOTE: This can happen if there is a snapname conflict, and we already have a snapshot // with the same name pointing to a different UUID as the source err = fmt.Errorf("%w: snapname points to different volume, request name (%s)"+ - " source name (%s) saved source name (%s)", util.ErrSnapNameConflict, - reqName, parentName, savedImageAttributes.SourceName) + " source name (%s) : saved source name (%s)", util.ErrSnapNameConflict, + reqName, snapParentName, savedImageAttributes.SourceName) return nil, err }