Commit Graph

172 Commits

Author SHA1 Message Date
John Mulligan c91f54ef25 rados: add test cases for ReadOp type and functions
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-12 14:47:30 +00:00
John Mulligan 0a67ff8f5a rados: add an initial set of tests for WriteOp operations
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-12 14:47:30 +00:00
John Mulligan 315188eaef rados: add AssertExists function to ReadOp
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-12 14:47:30 +00:00
John Mulligan c8d8d8c364 rados: add Write, WriteFull, and WriteSame WriteOp functions
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>
2021-01-12 14:47:30 +00:00
John Mulligan e4e1257768 rados: add AssertExists WriteOp function
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-12 14:47:30 +00:00
John Mulligan 570738b24c rados: add CleanOmap WriteOp function
Reimplement CleanOmap in term of a new CleanOmap function on the
WriteOp.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-12 14:47:30 +00:00
John Mulligan f4e0730b8f rados: add RmOmapKeys WriteOp function
Reimplement RmOmapKeys in term of a new RmOmapKeys function on the
WriteOp.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-12 14:47:30 +00:00
John Mulligan 701bb74897 rados: add GetOmapValues function to the ReadOp
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>
2021-01-12 14:47:30 +00:00
John Mulligan bc6cabbe9f rados: add SetOmap WriteOp function
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>
2021-01-12 14:47:30 +00:00
John Mulligan 614806ad01 rados: add withRefs type
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-12 14:47:30 +00:00
John Mulligan 1d6366f008 rados: add an error to be used if data is requested too early
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>
2021-01-12 14:47:30 +00:00
John Mulligan dffdc11f1f rados: add an initial ReadOp type for rados read operations
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-12 14:47:30 +00:00
John Mulligan 557390fb1d rados: make ioctx create internally based on WriteOp Create
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-12 14:47:30 +00:00
John Mulligan 926e101171 rados: create a new WriteOp type around rados_write_op_t
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>
2021-01-12 14:47:30 +00:00
John Mulligan 2a31d6a411 rados: add a function for use as a finalizer for any opStep
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>
2021-01-12 14:47:30 +00:00
John Mulligan f1934a5513 rados: add a file to expose librados operation flags to our rados pkg
These flags are passed to the *_op_operate calls in the C API.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-12 14:47:30 +00:00
John Mulligan c96da54878 rados: add test cases for basic operation types
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-12 14:47:30 +00:00
John Mulligan 53d2d83bc4 rados: add generic operation type for basis of data handling in op types
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-12 14:47:30 +00:00
Niels de Vos 460837e900 rados: add LIBRADOS_OP_FLAG_* constants
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>
2020-11-12 12:50:03 +00:00
John Mulligan b756c84956 rados: add GetNamespace implementing rados_ioctx_get_namespace
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-11-03 17:50:44 +00:00
John Mulligan bd77bccc68 rados: add implements section to doc comment for SetNamespace
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-11-03 17:50:44 +00:00
John Mulligan b6dff699e4 rados: use FormatErrorCode for formatting rados errors
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
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
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
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
Sven Anderson e77ecf68f6 rados: make RadosError type unexported
In order to avoid external dependencies on implementation details,
this change replaces RadosError with the unexported radosError. 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
John Mulligan 861747663b rados: test functions for MonCommandTarget
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-05-27 13:38:07 -04:00
John Mulligan 665611d054 rados: add MonCommandTarget & MonCommandTargetWithInputBuffer functions
These functions wrap rados_mon_command_target and allow the user to send
"command JSON" to specific MONs.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-05-27 13:38:07 -04:00
John Mulligan 2202a2c32d rados: add test functions for OsdCommand
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-05-27 13:38:07 -04:00
John Mulligan 40f80cc846 rados: add OsdCommand & OsdCommandWithInputBuffer functions
These functions wrap rados_osd_command and allow the user to send
"command JSON" to OSDs.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-05-27 13:38:07 -04:00
John Mulligan 4b24a7849e rados: remove redundant private xxxCommand functions
These private functions with names like monCommand and pgCommand were no
different from the public xxxCommandWithInputBuffer commands. Thus the
redundant private functions are removed to simplify the file. As private
functions these can be added back later w/o fuss if the behavior of
the xxxCommand and xxxCommandWithInputBuffer calls need to differ more
in the future.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-05-27 13:38:07 -04:00
John Mulligan e2a78eec02 cutil: allow passing free functions to command output type
The *_command functions in librados and libcephfs document the use
of specific free functions for data allocated. These functions are
currently just wrappers around C's free() function. However, to be
more strictly compliant this change adds a free-function callback
to the CommandOutput type and the specific free functions are now
used outside the unit tests.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-05-12 17:18:08 -04:00
John Mulligan 817b6b68c2 rados: replace copy-n-paste *_command functions argument handling
Replace the argument handling (wrangling?) around *_command functions,
such as MonCommand, with the new command input and output helper types
from the internal/cutil package.
No external change should be visible.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-05-12 17:18:08 -04:00
root e89344cae1 fix typos 2020-05-01 09:37:09 -04:00
John Mulligan fb2736dd0a rados: add MgrCommand and MgrCommandWithInputBuffer functions
Add functions for issuing commands to ceph mgrs with
MgrCommand and MgrCommandWithInputBuffer, implemented simliarly
to the other *Command style functions.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-27 14:38:16 -04:00
John Mulligan ff805ee1e1 rados: remove named return values in command.go
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-27 14:38:16 -04:00
John Mulligan 79dfe8e631 rados: move *Command functions into a separate file
Organize the rados package a bit more by moving functions that wrap
rados_xyz_command functions into a dedicated file. Move related test to
a separate file as well.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-27 14:38:16 -04:00