The return value of rbd_discard() is the number of bytes that have been
discarded, or in case of an error, a negative errno value.
It seems Image.Discard() never can have worked as intended, unless the
error was disregarded. Just like Image.Write(), Image.Discard() should
return a tuple of the number of bytes discarded and an error.
Fixes: ceph/go-ceph#123
Signed-off-by: Niels de Vos <ndevos@redhat.com>
rbd_get_features() returns a uint64_t with the features that are set in
the image. That means combining (with logical OR) features should result
in a uint64 too. Marking all features explicitly uint64 makes it easier
and cleaner to set/test features.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
A recent PR added new error values that were similar to the existing
naming convention but were not the normal go convention. Change all the
errors to match typical convention but leave the older names as aliases
such that older code will continue to work (for now).
Signed-off-by: John Mulligan <jmulligan@redhat.com>
By convention many projects are separating the golang stdlib imports
from other imports. Do that as well for rbd.go.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Translate the return value (errno) from the C rbd_*() functions into the
standardized strerror() error message.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Make it possible to easily validate the *Image and *Snapshot objects
before using them. This makes the use of go-ceph for RBD functions more
stable, and it is less likely that incorrect use causes Go panics.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This allows to set additional options while creating RBD images.
Ceph-CSI will initially consume this to configure an optionally
different pool for data.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
The C library offers rbd_create2() and rbd_create3() and does not try to
cover all options with rbd_create(). For users that are familiar with
the C API, the Create2() and Create3() functions have been added.
The existing Create() API still handles the complete set of
rbd_create*() functions, so backwards compatibility is covered.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
- Use C errno constants in place of hardcoded ints
- Use type inference where possible (especially C.CString
- Don't explicitly specify zero values where value would be default anway
- Rewrap some unnecessarily wrapped short lines
- Use if/else one-liners where value is not needed afterwards
Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
ReadAt and WriteAt should not rely on image.offset as this
prevents the from working in a thread-safe manner.
Signed-off-by: Alex Bligh <alex@alex.org.uk>
The AIO interface is not thread safe. There is an example of how to use
non-Go threads to make callback into Go found in the zookeepr api go
bindings.
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>