Commit Graph

215 Commits

Author SHA1 Message Date
John Mulligan 51885f0875 rbd: add test case for Stringer supporting mirroring constants
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-03-19 11:23:37 +00:00
John Mulligan b614e93b9d rbd: add String method for MirrorImageState
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-03-19 11:23:37 +00:00
John Mulligan 741e7d43bd rbd: add String method for ImageMirrorMode
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-03-19 11:23:37 +00:00
John Mulligan 406868763c rbd: add String method for MirrorMode
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-03-19 11:23:37 +00:00
John Mulligan 1286e0d4d0 rbd: add GroupSnapRollbackWithProgress function
* 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>
2021-02-08 15:29:11 +00:00
John Mulligan 8e6dfe4259 rbd: add GroupSnapRollback implementing rbd_group_snap_rollback
* Add GroupSnapRollback implementing rbd_group_snap_rollback

Adds tests for the above.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-02-08 15:29:11 +00:00
John Mulligan ffeabf1436 rbd: add GroupSnapList implementing rbd_group_snap_list
* Add GroupSnapList implementing rbd_group_snap_list

Adds tests for the above.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-02-08 15:29:11 +00:00
John Mulligan fd08e791cc rbd: add GroupSnapCreate, GroupSnapRemove, & GroupSnapRename funcs
* Add GroupSnapCreate implementing rbd_group_snap_create
* Add GroupSnapRemove implementing rbd_group_snap_remove
* Add GroupSnapRename implementing rbd_group_snap_rename

And tests for the above.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-02-08 15:29:11 +00:00
John Mulligan 0b4ed9dbe8 rbd: add GetGroup implementing rbd_get_group
This method is useful to determine what group an image is part of.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-02-02 15:48:00 +00:00
John Mulligan cbf2a51698 rbd: add GroupImageList implementing rbd_group_image_list
This function can be used to list the images in a group.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-02-02 15:48:00 +00:00
John Mulligan cd0a5bfe01 rbd: add GroupImageAdd, GroupImageRemove, and GroupImageRemoveByID
* 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>
2021-02-02 15:48:00 +00:00
John Mulligan 1748ad781c rbd: test that cephIoctx helper panics when fed invalid inputs
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>
2021-02-01 15:31:17 +00:00
Niels de Vos 05a8b48688 rbd: Add TestWriteSame/zerofill test case
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>
2021-01-28 16:04:12 +00:00
Mudit Agarwal 3032c539a0 rbd: add GetImageMirrorMode() to get the mirroing mode of a RBD image
Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2021-01-25 20:35:15 +00:00
Mudit Agarwal 6ff40f828f rbd: add function to fetch mirror status of a RBD image.
Add GetMirrorImageInfo() to fetch the mirror status of a RBD image.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2021-01-25 20:35:15 +00:00
John Mulligan 25a5086184 rbd: fix typo in comment & improve comment consistency
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>
2021-01-25 14:38:39 +00:00
John Mulligan 1e3b9a2cd9 rbd: add an initial set of basic mirroring functions
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>
2021-01-22 09:27:06 -05:00
John Mulligan a40638e947 rbd: add GroupList implementing rbd_group_list
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-22 08:13:20 +00:00
John Mulligan 7eeb5f79ab rbd: add GroupCreate, GroupRemove, & GroupRename functions
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>
2021-01-22 08:13:20 +00:00
John Mulligan 76bca17e43 rbd: enable test cases with ceph issues that have been fixed
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>
2021-01-21 21:40:20 +00:00
Niels de Vos 0afcf98b34 Add rbd_writesame()
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>
2020-11-12 12:50:03 +00:00
Sven Anderson c8f26a841b rbd: eliminate invalid unsafe.Pointers
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>
2020-11-09 08:58:22 +00:00
John Mulligan e7791c9e06 rbd: add ListMetadata implementing rbd_metadata_list
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>
2020-11-04 14:01:51 +00:00
John Mulligan 6bc6c7c3b1 rbd: move TestImageMetadata function to a new test file
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>
2020-11-04 14:01:51 +00:00
John Mulligan eb84f5aba1 rbd: move image metadata functions to new go file
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>
2020-11-04 14:01:51 +00:00
Mudit Agarwal 736858ca7d rbd: add wrapper for rbd_snap_set_by_id()
Added wrapper for rbd_snap_set_by_id() function

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-09-24 14:03:01 -04:00
Mudit Agarwal 2f0905b585 rbd: add wrapper for rbd_snap_get_timestamp()
Added a wrapper for rbd_snap_get_timestamp() function.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-09-24 14:03:01 -04:00
Mudit Agarwal 0e09cd4370 rbd: add snapshot ID related functions
added wrappers for rbd_snap_get_name() and rbd_snap_get_id()

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-09-24 14:03:01 -04:00
Mudit Agarwal 34cab3407f rbd: add a new version of GetParentInfo()
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>
2020-09-21 11:19:38 -04:00
Sven Anderson 4706453428 rbd: remove unnecessary C wrapper functions
Signed-off-by: Sven Anderson <sven@redhat.com>
2020-08-28 09:51:06 -04:00
John Mulligan dbf20aea0a rbd: add Sparsify implementing rbd_sparsify
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>
2020-08-27 14:22:52 -04:00
Sven Anderson 176a163c3c callbacks: use uintptr instead of int as index
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>
2020-08-27 10:26:12 -04:00
John Mulligan 849fc3c1f3 rbd: use FormatErrorCode for formatting rbd errors
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-08-10 13:03:24 -04:00
John Mulligan ab49935b5b rbd: rename error type's Errno method to ErrorCode
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-08-10 13:03:24 -04:00
John Mulligan d6e928993b rbd: fix naming of internal watch callback item type
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>
2020-08-07 08:38:15 -04:00
John Mulligan aa29fad715 rbd: simplify callback mechanism in diff_iterate and watchers
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>
2020-08-07 08:38:15 -04:00
Mudit Agarwal 7a387654c5 rbd: remove deprecated fields from ImageInfo struct
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>
2020-08-04 12:48:01 -04:00
Sven Anderson 085e2049b3 tests: add tests for the Errno() methods of numeric error types
Signed-off-by: Sven Anderson <sven@redhat.com>
2020-07-24 23:14:20 +02:00
Mudit Agarwal 2bb1b9bffc rbd: add constants for pool stat options and wrapper for rbd_pool_stats_get()
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>
2020-07-24 10:35:57 -04:00
Mudit Agarwal fec47ac9a9 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 <muagarwa@redhat.com>
2020-07-24 10:35:57 -04:00
Mudit Agarwal 0cd2b21224 rbd: add wrapper for rbd_pool_init() function
Added PoolInit function implementing rbd_pool_init which sets the
application tag to rbd.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-07-24 10:35:57 -04:00
Mudit Agarwal 0ffebd1f25 rbd: moved ImageOptionCloneFormat to rbd/options_mimic.go
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>
2020-07-24 10:20:27 -04:00
Mudit Agarwal 982a3975a9 rbd: add wrapper for function rbd_snap_get_trash_namespace()
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>
2020-07-24 10:20:27 -04:00
Mudit Agarwal a5da5e308b rbd: add functions and constants related to snapshot namespace.
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>
2020-07-24 10:20:27 -04:00
John Mulligan bfe4adfd2d rbd: convert ListChildren for mimic to use cutil.SplitSparseBuffer
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00
John Mulligan 2a62588181 rbd: convert NamespaceList for nautilus to use cutil.SplitSparseBuffer
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00
John Mulligan 4d2d6493af rbd: convert GetImageNames for mimic to use cutil.SplitSparseBuffer
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00
John Mulligan 3d5741301d rbd: convert uses of split function to use cutil.SplitSparseBuffer
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00
John Mulligan 97732ac885 rbd: add a UpdateWatch test case with multiple watches and go channels
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 13:19:57 -04:00
John Mulligan f3f2180e66 rbd: add Watch type and watch callbacks support
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>
2020-07-23 13:19:57 -04:00