Skip to content

Commit

Permalink
journal: change omap remove func to handle multiple keys at once
Browse files Browse the repository at this point in the history
For any function that removes more than one key on a single oid removing
them as a batch will be more efficient.

Signed-off-by: John Mulligan <[email protected]>
  • Loading branch information
phlogistonjohn committed May 28, 2020
1 parent 75e771a commit f270757
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions internal/journal/omap.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ func getOMapValues(
return results, nil
}

func removeOneOMapKey(
func removeMapKeys(
ctx context.Context,
conn *Connection,
poolName, namespace, oMapName, oMapKey string) error {
poolName, namespace, oid string, keys []string) error {
// fetch and configure the rados ioctx
ioctx, err := conn.conn.GetIoctx(poolName)
if err != nil {
Expand All @@ -76,15 +76,15 @@ func removeOneOMapKey(
ioctx.SetNamespace(namespace)
}

err = ioctx.RmOmapKeys(oMapName, []string{oMapKey})
err = ioctx.RmOmapKeys(oid, keys)
if err != nil {
klog.Errorf(
util.Log(ctx, "failed removing omap key (pool=%q, namespace=%q, name=%q, key=%q): %v"),
poolName, namespace, oMapName, oMapKey, err)
util.Log(ctx, "failed removing omap keys (pool=%q, namespace=%q, name=%q): %v"),
poolName, namespace, oid, err)
} else {
klog.Infof(
util.Log(ctx, "XXX removed omap key (pool=%q, namespace=%q, name=%q, key=%q, ): %v"),
poolName, namespace, oMapName, oMapKey, err)
util.Log(ctx, "XXX removed omap key (pool=%q, namespace=%q, name=%q): %v"),
poolName, namespace, oid, err)
}
return err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/journal/voljournal.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ func (conn *Connection) UndoReservation(ctx context.Context,
}

// delete the request name key (last, inverse of create order)
err := removeOneOMapKey(ctx, conn, csiJournalPool, cj.namespace, cj.csiDirectory,
cj.csiNameKeyPrefix+reqName)
err := removeMapKeys(ctx, conn, csiJournalPool, cj.namespace, cj.csiDirectory,
[]string{cj.csiNameKeyPrefix + reqName})
if err != nil {
klog.Errorf(util.Log(ctx, "failed removing oMap key %s (%s)"), cj.csiNameKeyPrefix+reqName, err)
return err
Expand Down

0 comments on commit f270757

Please sign in to comment.