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>
This change adds a new pointer alias CPtr, that should always only
contains pointers to C allocated memory and should always used for
such pointers in order to keep them separate from Go pointers more
easily. This is helpful, since only CPtr are allowed to be stored in
C allocated memory, and Go pointers can only be passed to C functions
if they don't point to memory not containing Go pointers again, that
is all pointers in such memory must be CPtr.
The change also adds aliases for C.malloc and C.free that return and
accept the CPtr type as a little safety measure.
Additionally there are some useful constants defined.
Signed-off-by: Sven Anderson <sven@redhat.com>
Ceph issue https://tracker.ceph.com/issues/46084 has been fixed with
backports to nautilus and octopus. Re-enable the relevant test data
and fix up the tests to match.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add Write implementing rados_write_op_write.
Add WriteFull implementing rados_write_op_write_full.
Add WriteSame implementing rados_write_op_writesame.
These are some of the basic functions needed to write data to
a rados object using a WriteOp.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Refactor the previous ListOmapValues logic into a new read op step
that can be used for iteration over the results of the operation. The
previous function is now based on the ReadOp.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Reimplement SetOmap in terms of a new SetOmap function on the WriteOp.
Now the actions of the write op can start to be atomically chained the
way WriteOps are supposed to.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add a new error that will be returned from a op step method if the
method is called before the step is ready to provide data - like
when the operation has not yet been performed.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The WriteOp type will manage librados write operations and the
corresponding functions that ceph names like rados_write_op_*.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This utility function avoids having to have a custom finalizer for every
op step. It calls the free() function to release any allocated C memory
the step may have.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Now that the new year has arrived this test assertion has started to
fail. This is because, although I anticipated the year would eventually
change and used GreaterOrEqual, the argument order is wrong. My excuse
is that I find the argument order in testify's Equal function confusing,
it causes me to assume other functions in testify are also confusing
(even when it's the "normal" order) and/or I copy and pasted from an
Equal line and didn't change the args (both are true!).
Instead of allowing any old year, we assume that the clocks where the
test are run are in sync enough that the current year is correct for
the assertion (thanks for the suggestion Sven).
Happy new year, go-ceph!
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The "extended-review" label indicates that review is likely to take
an extended period of time and for bots to not automatically take
a PR.
This avoid the need to preemptively mark a PR as changes needed or
give a false impression with a "do-not-merge" tag, which has a subtle
lack-of-quality implication.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This flagSet type allows the user to also set the value of the retain
snapshots flag, something unique to subvolume removal (all others had
the force flag only).
Signed-off-by: John Mulligan <jmulligan@redhat.com>
To prepare for multiple flags types, we create a flagSet interface and
break out the functionality that was in Update into a per-type method
and then the common "merger" function.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add a Truncate method to File type. Note the doc comment as I hit
a bug in ceph when writing the first test cases. Go-ceph will behave
as ceph here - so using go-ceph with an unfixed version of the
ceph libs will also exhibit the bug.
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>
The LIBRADOS_OP_FLAG_* constants can be passed to rbd_writesame() and
other operations that will be added in the future.
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 former code assumed a LIFO usage, and otherwise always produced
collisions. This change uses unique IDs instead, that as a
side-effect might make debugging easier.
Signed-off-by: Sven Anderson <sven@redhat.com>
We had been using setup-go@v2-beta for a while, before v2 was out.
Now v2-beta is out of data and generating warnings in the github
actions ui.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Enabling Smart-mode for "Strict Merge" causes Mergify to do a rebase of
the PR before merging. The rebase will trigger CI runs again, and
merging will be done only when the CI results are successful.
See-also: https://docs.mergify.io/actions.html#merge
Signed-off-by: Niels de Vos <ndevos@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>