mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
journal: change omap set func to handle multiple key-value pairs
For any function that sets more than one key on a single oid setting them as a batch will be more efficient. Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
a8409eccc8
commit
c14cbee132
@ -105,10 +105,10 @@ func removeMapKeys(
|
||||
return err
|
||||
}
|
||||
|
||||
func setOneOMapKey(
|
||||
func setOMapKeys(
|
||||
ctx context.Context,
|
||||
conn *Connection,
|
||||
poolName, namespace, oMapName, oMapKey, keyValue string) error {
|
||||
poolName, namespace, oid string, pairs map[string]string) error {
|
||||
// fetch and configure the rados ioctx
|
||||
ioctx, err := conn.conn.GetIoctx(poolName)
|
||||
if err != nil {
|
||||
@ -120,20 +120,21 @@ func setOneOMapKey(
|
||||
ioctx.SetNamespace(namespace)
|
||||
}
|
||||
|
||||
pairs := map[string][]byte{
|
||||
oMapKey: []byte(keyValue),
|
||||
bpairs := make(map[string][]byte, len(pairs))
|
||||
for k, v := range pairs {
|
||||
bpairs[k] = []byte(v)
|
||||
}
|
||||
err = ioctx.SetOmap(oMapName, pairs)
|
||||
err = ioctx.SetOmap(oid, bpairs)
|
||||
if err != nil {
|
||||
klog.Errorf(
|
||||
util.Log(ctx, "failed setting omap key (pool=%q, namespace=%q, name=%q, key=%q, value=%q): %v"),
|
||||
poolName, namespace, oMapName, oMapKey, keyValue, err)
|
||||
} else {
|
||||
klog.Infof(
|
||||
util.Log(ctx, "XXX set omap key (pool=%q, namespace=%q, name=%q, key=%q, value=%q): %v"),
|
||||
poolName, namespace, oMapName, oMapKey, keyValue, err)
|
||||
util.Log(ctx, "failed setting omap keys (pool=%q, namespace=%q, name=%q, pairs=%+v): %v"),
|
||||
poolName, namespace, oid, pairs, err)
|
||||
return err
|
||||
}
|
||||
return err
|
||||
klog.V(4).Infof(
|
||||
util.Log(ctx, "set omap keys (pool=%q, namespace=%q, name=%q): %+v)"),
|
||||
poolName, namespace, oid, pairs)
|
||||
return nil
|
||||
}
|
||||
|
||||
func omapPoolError(poolName string, err error) error {
|
||||
|
Reference in New Issue
Block a user