From fec47ac9a910438e6a8f25587b8cb64198dfdf62 Mon Sep 17 00:00:00 2001 From: Mudit Agarwal Date: Sat, 4 Jul 2020 18:44:50 +0530 Subject: [PATCH] rbd: add wrapper for unexported pool stat functions. Added wrappers for rbd_pool_stats_create() and rbd_pool_stats_destroy() functions. Right now, keeping these unexported. Signed-off-by: Mudit Agarwal --- rbd/pool_nautilus.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/rbd/pool_nautilus.go b/rbd/pool_nautilus.go index 5731436..b3f8067 100644 --- a/rbd/pool_nautilus.go +++ b/rbd/pool_nautilus.go @@ -99,3 +99,30 @@ func PoolInit(ioctx *rados.IOContext, force bool) error { ret := C.rbd_pool_init(cephIoctx(ioctx), C.bool(force)) return getError(ret) } + +// poolStats represents RBD pool stats variable. +type poolStats struct { + stats C.rbd_pool_stats_t +} + +// poolStatsCreate creates a new poolStats struct. +// +// Implements: +// void rbd_pool_stats_create(rbd_pool_stats_t *stats) +func poolStatsCreate() *poolStats { + poolstats := &poolStats{} + C.rbd_pool_stats_create(&poolstats.stats) + return poolstats +} + +// destroy a poolStats struct and free the associated resources. +// +// Implements: +// void rbd_pool_stats_destroy(rbd_pool_stats_t stats) +func (poolstats *poolStats) destroy() { + C.rbd_pool_stats_destroy(poolstats.stats) + + if poolstats.stats != nil { + poolstats.stats = nil + } +}