Commit Graph

622 Commits

Author SHA1 Message Date
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 54c268cb81 rados: 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 1ecac966de cephfs: rename error types 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
John Mulligan 4a58616b96 cephfs: fix a typo in the ListXattr doc comment
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-08-04 13:35:35 -04:00
John Mulligan f020a3ffac cephfs: add path-based xattr functions
This change adds wrappers for:

* ceph_getxattr
* ceph_listxattr
* ceph_removexattr
* ceph_setxattr

As well as:
* ceph_lgetxattr
* ceph_llistxattr
* ceph_lremovexattr
* ceph_lsetxattr

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-08-04 13:35:35 -04:00
John Mulligan 80ce962b68 cephfs: give xattr test samples a better name
The name "samples" was too generic. Rename it to "xattrSamples".
This variable will be used outside of this file in a future change.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-08-04 13:35:35 -04:00
Sven Anderson e0982bc6e1 tests: disable disk space check in micro-osd.sh
Signed-off-by: Sven Anderson <sven@redhat.com>
2020-08-04 12:59:38 -04:00
Sven Anderson 2a75461371 make: add micro-osd.sh to container dependencies
Signed-off-by: Sven Anderson <sven@redhat.com>
2020-08-04 12:59:38 -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
Mudit Agarwal 16a24da06d rados: add wrapper for rados_ioctx_snap_set_read() function
Implemented SetReadSnap() which sets the snapshot from which reads
would be performed.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-08-04 11:07:40 -04:00
Mudit Agarwal 610b92ded2 rados: add wrapper for rados_ioctx_snap_rollback() function
Implemented RollbackSnapshot() and testcases for the same.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-08-04 11:07:40 -04:00
Mudit Agarwal 62f5881485 rados: add wrapper for rados_ioctx_snap_list() function
Signed-off-by Mudit Agarwal <muagarwa@redhat.com>
2020-08-04 11:07:40 -04:00
Mudit Agarwal ff1ce13478 rados: add wrappers for rados snapshot ID related functions
Add wrappers for following three functions which involve snapshot ID:
1. rados_ioctx_snap_lookup()
2. rados_ioctx_snap_get_name()
3. rados_ioctx_snap_get_stamp()

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-08-04 11:07:40 -04:00
Mudit Agarwal 8e5a05c1a4 rados: add snapshot create/remove functions
Added wrappers for pool-wide snapshot create and remove functions.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-08-04 11:07:40 -04:00
Mudit Agarwal 558b366fbb rados: modify validate() to return ErrInvalidIOContext error
If ioctx is not ready to be used then validate() should
return ErrInvalidIOContext error.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-08-04 11:07:40 -04:00
Mudit Agarwal 8788a901dc rados: one minor reformat in errors.go
Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-08-04 11:07:40 -04:00
John Mulligan edcee808b1 rados: add GetLastVersion implementing rados_get_last_version
The GetLastVersion returns a number representing the most recent
read/write version for the io context.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-31 09:17:38 -04:00
John Mulligan 9179f8df29 rados: add a validate() function to IOContexts
The validate function works similarly to those already found
in rbd and cephfs. It will be used in future functions or
updated functions to ensure the C ioctx is ready for use.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-31 09:17:38 -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
John Mulligan d044f177c3 cephfs: use new SplitSparseBuffer call in ListXattr function
Use the newly added SplitSparseBuffer cutil function to break the buffer
cephfs returns into a slice of strings with xattr names.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 13:42:35 -04:00
John Mulligan 1bbd6edb4b cephfs: add a pointer in the docs for no-value issue
Add a section to the doc comment for SetXattr that notes the behavior
I observed while working on the tests: that passing an empty value
(or null on the C side) causes the xattr to be removed rather than
set with an "empty" value. This issue has been reported in the
ceph tracker (see link in comment).

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 13:42:35 -04:00
John Mulligan 5f41e2d8d2 cephfs: add file method RemoveXattr implementing ceph_fremovexattr
Add RemoveXattr implementing ceph_fremovexattr as well as a test for it.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 13:42:35 -04:00
John Mulligan 04bf7a4d0e cephfs: add file method ListXattr implementing ceph_flistxattr
Add ListXattr implementing ceph_flistxattr. Add a test for the function.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 13:42:35 -04:00
John Mulligan a9738e7d45 cephfs: add file SetXattr and GetXattr functions
Add SetXattr implementing ceph_fsetxattr.
Add GetXattr implementing ceph_fgetxattr.
Add test function to exercise both.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 13:42:35 -04:00
John Mulligan 65227dd4d4 cephfs: add a getErrorIfNegative helper func
Works like the ones already in the other packages.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 13:42:35 -04:00
Mudit Agarwal 837777d3fc rados: add wrapper for the function rados_ioctx_get_id()
Implements GetPoolID() and test case around the same.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-07-24 10:48:18 -04: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 7dea1f728f cephfs: add function ParseDefaultConfigEnv to set ceph config from env
Similar to the rados function of the same name, ParseDefaultConfigEnv
uses the environment to configure the cephfs mount.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 09:54:04 -04:00
John Mulligan c34501fc6a cephfs: add a ParseConfigArgv function
The ParseConfigArgv behaves similarly to the same named function in
rados. The command line argv value is parsed by ceph libs and used to
configure the mount object.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 09:54:04 -04:00
John Mulligan bf0e4723e2 cephfs: add error for function args that must have data
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 09:54:04 -04:00
John Mulligan afc819354b rados: document what env variable ceph uses for ParseDefaultConfigEnv.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 09:54:04 -04:00
John Mulligan a50c60be49 rados: add a more direct argv config wrapper ParseConfigArgv
Previously, ParseCmdLineArgs was the function directly wrapping the
ceph rados_conf_parse_argv function. This function has the improper
(IMO) behavior of assuming you didn't know your own argv[0] and just
always stuck "placeholder" in argv[0]. This function adds a more
direct wrapper ParseConfigArgv that allows the caller to pass an
full argv, and they can put any placholder value desired if they want.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 09:54:04 -04:00
John Mulligan 8b16f804a3 rados: add error for function args that must have data
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 09:54:04 -04:00
John Mulligan 08bb0096c4 rados: convert ListPools to use cutil.SplitSparseBuffer
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -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 e5d1a53060 cutil: add SplitBuffer and SplitSparseBuffer helper functions
Add SplitBuffer and SplitSparseBuffer functions for extracting a list
of strings from a single buffer, typically returned in C code, from
a single Go buffer. The SplitBuffer variant will return empty strings
if multiple nulls are found in sequence, assuming that the C code
packs data between on single null byte (expect the final byte).
The SplitSparseBuffer variant assumes that the C code may not
tightly pack the data with single null bytes and thus will not
return any empty strings (unless the input buffer is empty
or only contains nulls).
Most of the code in the go-ceph codebase is doing the latter but
probably should have been doing the former. Thus both approaches
are provided.

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
John Mulligan d3f8f0cf70 cephfs: add StatFS implementing ceph_statfs
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-20 13:36:53 -04:00
Sven Anderson 8b45a01b7d cephfs: make CephFSError type unexported
In order to avoid external dependencies on implementation details,
this change replaces CephFSError with the unexported cephFSError. In case
some application really needs access to the integer value, it can use
the pattern
  var errno interface{ Errno() int }
  if errors.As(err, errno) { ... errno.Errno() ... }

Signed-off-by: Sven Anderson <sven@redhat.com>
2020-07-17 13:47:32 -04:00