* Add GroupSnapRollbackWithProgress implementing rbd_group_snap_rollback_with_progress
This has supporting code basically the same as our other existing
callback functions.
Tests too.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
* Add GroupImageAdd implementing rbd_group_image_add
* Add GroupImageRemove implementing rbd_group_image_remove
* Add GroupImageRemoveByID implementing rbd_group_image_remove_by_id
These functions allow managing the images that are part of a group.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
As per go-ceph issue #427, and a discussion in #399 this change and
test ensure that the cephIoctx helper function, that extracts the
C.rados_ioctx_t from a Go rados.IOContext, never returns a nil/null
C type.
As these are always "programming errors" panicking is reasonable
behavior for this case.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Using WriteSame() to implement a zerofill function is less straight
forward than expected. `rbd_discard_on_zeroed_write_same` is a Ceph
option than affects the behaviour of WriteSame(). By default the option
is enabled, causing WriteSame() to call discard instead of writing
zeros.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
RBD was misspelled as RDB. While I was there I made the comments
for both constants more consistently worded.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add functions:
* SetMirrorMode implementing rbd_mirror_mode_set
* GetMirrorMode implementing rbd_mirror_mode_get
* MirrorEnable implementing rbd_mirror_image_enable2
* MirrorDisable implementing rbd_mirror_image_disable
* MirrorPromote implementing rbd_mirror_image_promote
* MirrorDemote implementing rbd_mirror_image_demote
* MirrorResync implementing rbd_mirror_image_resync
* MirrorInstanceId implementing rbd_mirror_image_get_instance_id
For now, these mirroring related functions are only supported on octopus
builds. Right now the demand is for snapshot based mirroring, which is
new in octopus. We can always relax this in the future and add the
necessary support for nautilus, for journaling only based mirroring.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add GroupCreate implementing rbd_group_create
Add GroupRemove implementing rbd_group_remove
Add GroupRename implementing rbd_group_rename
Naming was <noun><verb> to better match other functions in rbd
like NamespaceCreate, etc. even though I don't prefer that
ordering ;-).
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Ceph issue https://tracker.ceph.com/issues/43178 has been fixed for
a while with backports. No reason not to enable these test cases now.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
In order to provide the ability to do thick provisioning of RBD images,
Image.WriteSame() can be used. The `rbd` commandline utility calls the
rbd_writesame() function when an image is created with the
`--thick-provision` option.
See-also: ceph/ceph-csi#1675
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Although it seems to be stable with the current Go versions,
unsafe.Pointers that are created by applying arithmetic on nil
pointers are explicitly not allowed[1], and could potentially lead to
panics by the garbage collector. To be on the safe side, this change
goes back to minimal inline wrappers for the callback registrations,
which should be zero-cost. For the callbacks themselves fortunately
no wrappers are required, because CGo happily converts void* to
uintptr arguments. The potentially problematic VoidPtr helper is
removed again.
[1] https://golang.org/pkg/unsafe/#Pointer
Signed-off-by: Sven Anderson <sven@redhat.com>
The function is named ListMetadata but returns a map of all
the metadata assigned to the rbd image. It is named ListMetadata to
match the C librbd api call.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Like the metadata functions were recently moved to a separate file,
move TestImageMetadata to a matching metadata_test.go file.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
As rbd.go is very long, and the get-/set-/remove- metadata functions in
rbd.go make a nice logical unit, move them to a new metadata.go file.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
GetParentInfo() currently requires the caller to specify the
string length for various attributes it returns. If the
specified string length is less than required, it can return
ERANGE error. Replacing it with a new function which avoids
this.
Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
The sparsify function can be used to make an image sparse by replacing
runs of zeros with holes. This change adds a wrapper for the basic
rbd_sparsify function and accompanying tests.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Since the index of the registered callbacks is basically only used as
void*/unsafe.Pointer, it makes more sense and code simpler, if
the index type is uintptr instead of a simple int.
Signed-off-by: Sven Anderson <sven@redhat.com>
This patch changes the name to the as-agreed-upon naming from a call.
I forgot to fix this in the original patches before merging things.
Oops.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Previously, the code that set up the callbacks was doing a pretty
direct translation of go-function to c-function. It turns out this
is not needed due to the way we set up the "dynamic" go callbacks
via an integer based callback "registry". Instead, we can stay within
the C layer entirely for the C callback, passing it only the index
value and then return to the go layer through a static C function
that only needs the index value.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Corresponding fields for Parent_pool and Parent_name have been deprecated from
ceph's rbd_image_info_t stuct, removing the same from go-ceph's ImageInfo struct.
Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
Added pool stat options constants.
Also implemented GetAllPoolStats() function to introduce
the functionality of rbd_pool_stats_option_add_uint64() and rbd_pool_stats_get()
Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
Added wrappers for rbd_pool_stats_create() and rbd_pool_stats_destroy() functions.
Right now, keeping these unexported.
Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
RBD_IMAGE_OPTION_CLONE_FORMAT was added in Ceph Mimic but fix for issue #295 added
it only for Ceph Nautilus, moving it to rbd/options_mimic.go
Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
Added a wrapper for function rbd_snap_get_trash_namespace() which
returns the original name of the snapshot which was moved to Trash.
Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
Added few constants used for determining snapshot namespace.
Added wrapper for function rbd_snap_get_namespace_type() which returns namespace type for a given snapshot.
Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
Add UpdateWatch function implementing rbd_update_watch.
Add Unwatch function implementing rbd_update_unwatch.
Add a higher level Watch type to encapsulate watching
the image and the watch handle.
Add basic tests to validate the callback behavior.
Signed-off-by: John Mulligan <jmulligan@redhat.com>