Commit Graph

37 Commits

Author SHA1 Message Date
John Mulligan 811f851c99 rbd: convert to common errno handling
Use the errno handling function originally created for rbd and
then made common in rbd package.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2019-12-16 16:59:25 +01:00
Niels de Vos 22c15e5a37 rbd: fix problems with Image.Discard()
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>
2019-12-16 10:12:51 -05:00
Niels de Vos 9381485fac test/rbd: Add tests for Image.Seek()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2019-12-16 10:12:51 -05:00
Niels de Vos dbfc54d61e rbd: RbdFeature* constants should be uint64
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>
2019-12-16 10:12:51 -05:00
John Mulligan 36fc3510d8 rbd: use conventional naming style for errors
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>
2019-12-16 11:32:21 +01:00
John Mulligan a2d1c64180 rbd: separate standard lib imports from pkg imports
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>
2019-12-16 10:03:58 +01:00
Niels de Vos a713db983a rbd: return more useful error messages
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>
2019-12-12 13:56:53 -05:00
Niels de Vos 2d52744470 rbd: improve error checking
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>
2019-12-11 19:47:21 -05:00
Niels de Vos b86563db7e rbd: add Create4() for more advanced RBD Image creation
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>
2019-12-11 13:43:58 -05:00
Niels de Vos 6a17d59988 rbd: split Create() off into Create2() ad Create3() following librbd.h
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>
2019-12-11 09:09:54 -05:00
zhangyue de3bd20fe3 bugfix: use GetError instead of RDBError to return
Signed-off-by: zhangyue <zy675793960@yeah.net>
2019-12-11 08:44:00 -05:00
Daniel Swarbrick 951118e855
Drop unnecessary typecasts
Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
2018-09-18 11:12:32 +02:00
Daniel Swarbrick 3023eb281d
Go style cleanups
- 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>
2018-09-18 11:03:41 +02:00
Noah Watkins 208695a8c1 fmt: apply gofmt updates
Signed-off-by: Noah Watkins <nwatkins@redhat.com>
2018-09-17 15:57:31 -07:00
Daniel Swarbrick 4a88b5da12
Implement wrappers around rbd_trash_* functions
Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
2018-09-17 20:46:23 +02:00
Daniel Swarbrick 9d12f2ecd1
Merge branch 'master' into feature-consts 2018-09-14 23:53:47 +02:00
Daniel Swarbrick 1623e77d20
Wrap feature macros from rbd/features.h 2018-09-14 23:52:24 +02:00
Daniel Swarbrick 3a8c38ca41 Add RBD feature flag sets as per Python rbd module 2018-09-14 16:59:08 +02:00
Daniel Swarbrick 340e124452 Convert RBD feature flags to constants with iota 2018-09-14 16:38:01 +02:00
Daniel Swarbrick df4109f4b7 Check that parent image has been opened before attempting snapshot operations 2018-09-14 16:02:11 +02:00
Vicente Cheng 19439f3958 rbd: the length of args on create_v3 should be 3 instead of 2
Signed-off-by: Vicente Cheng <freeze.bilsted@gmail.com>
2016-12-20 19:24:31 +08:00
Noah Watkins 1cbeb759e2 Merge pull request #22 from david-z/wip-fix-list-lockers-crash
Fix rbd list lockers crashing
2016-05-20 07:34:18 -07:00
Noah Watkins 62e94854a4 Merge pull request #19 from abligh/fix-read-at-write-at-race
Replace ReadAt and WriteAt with thread-safe versions
2016-05-20 07:34:10 -07:00
Zhi Zhang b68bd88243 Fix rbd list lockers crashing
Signed-off-by: Zhi Zhang <zhangz.david@outlook.com>
2016-05-20 17:26:29 +08:00
Alex Bligh 38c3c12b50 Replace ReadAt and WriteAt with thread-safe versions
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>
2016-04-29 14:36:01 +01:00
Ryan Roemmich 777d9c72ab continue after -ERANGE in retval of rbd_list_children. fix out of range on zero children 2016-04-05 10:23:09 -06:00
Crazykev ee740834a2 add param 'order' to Create() and Image.Clone(), and upgrade ci ceph version to hammer
Signed-off-by: Crazykev <crazykev@zju.edu.cn>
2016-03-03 21:59:09 -05:00
Noah Watkins 3f52ea219a repo: update new repo path
noahdesu -> ceph

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
2015-08-31 07:34:42 -07:00
Ye Yin 5c2d42ef5a Change return new error for rados and rbd
Signed-off-by: Ye Yin <eyniy@qq.com>
2015-07-24 11:34:18 +08:00
Ye Yin 193dbacdb0 Convert some C error code to Go code, for convenient Golang code to handle error.
Define some Rbd constant variables, to pass to librbd API.
Add test unit for RbdErrorNotFound

Signed-off-by: Ye Yin <eyniy@qq.com>
2015-07-23 15:33:34 +08:00
Ye Yin 80e3e9ea7f Add rbd_get_parent_info
Signed-off-by: Ye Yin <eyniy@qq.com>
2015-07-20 11:34:47 +08:00
Kai Storbeck 0c6bdf8d59 run gofmt on all sources 2015-02-11 22:21:05 +01:00
Noah Watkins 0d62c1455a rbd: remove buggy aio interface
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>
2015-02-09 10:54:19 -08:00
Sylvain Baubeau 75e9c455a6 rbd: fix error handling for write, seek and flush 2015-01-15 15:15:31 +01:00
Sylvain Baubeau 921a14b17f rbd: fix calls to wrong C functions 2015-01-15 15:13:53 +01:00
Sylvain Baubeau e00f9bf1a8 lib: add full support for RADOS block devices 2015-01-15 00:44:26 +01:00
Noah Watkins 44c15bf439 rbd: add rbd package
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
2015-01-12 22:15:32 -08:00