From 7b56123e178499336ec9f393d5098b1d27224bba Mon Sep 17 00:00:00 2001 From: Mudit Agarwal Date: Sat, 6 Jun 2020 06:27:08 +0530 Subject: [PATCH] rbd: add wrapper for rbd_pool_metadata_set() Add wrapper for rbd_pool_metadata_set() function which sets pool metadata associated with the given key. Signed-off-by: Mudit Agarwal --- rbd/pool_nautilus.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/rbd/pool_nautilus.go b/rbd/pool_nautilus.go index d39ad98..b86c6a2 100644 --- a/rbd/pool_nautilus.go +++ b/rbd/pool_nautilus.go @@ -1,6 +1,7 @@ // +build !luminous,!mimic // -// Ceph Nautilus is the first release that includes rbd_pool_metadata_get(). +// Ceph Nautilus is the first release that includes rbd_pool_metadata_get(), +// rbd_pool_metadata_set(). package rbd @@ -45,3 +46,17 @@ func GetPoolMetadata(ioctx *rados.IOContext, key string) (string, error) { } return C.GoString((*C.char)(unsafe.Pointer(&buf[0]))), nil } + +// SetPoolMetadata updates the pool metadata string associated with the given key. +// +// Implements: +// int rbd_pool_metadata_set(rados_ioctx_t io_ctx, const char *key, const char *value); +func SetPoolMetadata(ioctx *rados.IOContext, key, value string) error { + cKey := C.CString(key) + defer C.free(unsafe.Pointer(cKey)) + cValue := C.CString(value) + defer C.free(unsafe.Pointer(cValue)) + + ret := C.rbd_pool_metadata_set(cephIoctx(ioctx), cKey, cValue) + return getError(ret) +}