Motr
M0
|
Data Structures | |
struct | creq_niter |
struct | m0_cas_req |
struct | m0_cas_rec_reply |
struct | m0_cas_ilist_reply |
struct | m0_cas_get_reply |
struct | m0_cas_next_reply |
Macros | |
#define | CASREQ_FOP_DATA(fop) ((struct m0_cas_op *)m0_fop_data(fop)) |
Enumerations | |
enum | m0_cas_req_state { CASREQ_INVALID, CASREQ_INIT, CASREQ_SENT, CASREQ_FRAGM_SENT, CASREQ_ASSEMBLY, CASREQ_FINAL, CASREQ_FAILURE, CASREQ_NR } |
Functions | |
static void | cas_req_replied_cb (struct m0_rpc_item *item) |
static void | creq_asmbl_replied_cb (struct m0_rpc_item *item) |
static int | cas_req_fragmentation (struct m0_cas_req *req) |
static int | cas_req_fragment_continue (struct m0_cas_req *req, struct m0_cas_op *op) |
static void | creq_recv_fini (struct m0_cas_recv *recv, bool op_is_meta) |
static void | cas_to_rpc_map (const struct m0_cas_req *creq, const struct m0_rpc_item *item) |
static bool | fid_is_meta (struct m0_fid *fid) |
static int | creq_op_alloc (uint64_t recs_nr, struct m0_cas_op **out) |
static void | creq_op_free (struct m0_cas_op *op) |
M0_INTERNAL void | m0_cas_req_init (struct m0_cas_req *req, struct m0_rpc_session *sess, struct m0_sm_group *grp) |
static struct m0_rpc_conn * | creq_rpc_conn (const struct m0_cas_req *req) |
static struct m0_rpc_machine * | creq_rpc_mach (const struct m0_cas_req *req) |
static struct m0_sm_group * | cas_req_smgrp (const struct m0_cas_req *req) |
M0_INTERNAL void | m0_cas_req_lock (struct m0_cas_req *req) |
M0_INTERNAL void | m0_cas_req_unlock (struct m0_cas_req *req) |
M0_INTERNAL bool | m0_cas_req_is_locked (const struct m0_cas_req *req) |
static void | cas_req_state_set (struct m0_cas_req *req, enum m0_cas_req_state state) |
static void | cas_req_reply_fini (struct m0_cas_req *req) |
static void | cas_req_fini (struct m0_cas_req *req) |
M0_INTERNAL void | m0_cas_req_fini (struct m0_cas_req *req) |
M0_INTERNAL void | m0_cas_req_fini_lock (struct m0_cas_req *req) |
static void | creq_kv_hold_down (struct m0_cas_rec *rec) |
static void | creq_fop_destroy (struct m0_cas_req *req) |
static void | creq_fop_release (struct m0_ref *ref) |
static void | creq_asmbl_fop_release (struct m0_ref *ref) |
static int | creq_fop_create (struct m0_cas_req *req, struct m0_fop_type *ftype, struct m0_cas_op *op) |
static int | creq_fop_create_and_prepare (struct m0_cas_req *req, struct m0_fop_type *ftype, struct m0_cas_op *op, enum m0_cas_req_state *next_state) |
static struct m0_cas_req * | item_to_cas_req (struct m0_rpc_item *item) |
static struct m0_rpc_item * | cas_req_to_item (const struct m0_cas_req *req) |
static struct m0_cas_rep * | cas_rep (struct m0_rpc_item *reply) |
M0_INTERNAL int | m0_cas_req_generic_rc (const struct m0_cas_req *req) |
static bool | cas_rep_val_is_valid (struct m0_rpc_at_buf *val, struct m0_fid *idx_fid) |
static int | cas_rep__validate (const struct m0_fop_type *ftype, struct m0_cas_op *op, struct m0_cas_rep *rep) |
static int | cas_rep_validate (const struct m0_cas_req *req) |
static void | cas_req_failure (struct m0_cas_req *req, int32_t rc) |
static void | cas_req_failure_ast (struct m0_sm_group *grp, struct m0_sm_ast *ast) |
static void | cas_req_failure_ast_post (struct m0_cas_req *req, int32_t rc) |
static void | creq_item_prepare (const struct m0_cas_req *req, struct m0_rpc_item *item, const struct m0_rpc_item_ops *ops) |
static void | cas_fop_send (struct m0_cas_req *req) |
static int | creq_kv_buf_add (const struct m0_cas_req *req, const struct m0_bufvec *kv, uint32_t idx, struct m0_rpc_at_buf *buf) |
static void | creq_asmbl_fop_init (struct m0_cas_req *req, struct m0_fop_type *ftype, struct m0_cas_op *op) |
static int | greq_asmbl_add (struct m0_cas_req *req, struct m0_cas_rec *rec, uint64_t idx, uint64_t orig_idx, uint64_t vlen) |
static uint64_t | greq_asmbl_count (const struct m0_cas_req *req) |
static int | greq_asmbl_fill (struct m0_cas_req *req, struct m0_cas_op *op) |
static bool | greq_asmbl_post (struct m0_cas_req *req) |
static bool | creq_niter_invariant (struct creq_niter *it) |
static void | creq_niter_init (struct creq_niter *it, struct m0_cas_op *op, struct m0_cas_rep *rep) |
static int | creq_niter_next (struct creq_niter *it) |
static void | creq_niter_fini (struct creq_niter *it) |
static int | nreq_asmbl_prep (struct m0_cas_req *req, struct m0_cas_op *op) |
static int | nreq_asmbl_fill (struct m0_cas_req *req, struct m0_cas_op *op) |
static bool | nreq_asmbl_post (struct m0_cas_req *req) |
static void | creq_rep_override (struct m0_cas_rec *orig, struct m0_cas_rec *new) |
static void | nreq_asmbl_accept (struct m0_cas_req *req) |
static void | greq_asmbl_accept (struct m0_cas_req *req) |
static void | cas_req_fsync_remid_copy (struct m0_cas_req *req) |
static int | cas_req_reply_handle (struct m0_cas_req *req, bool *fragm_continue) |
static void | creq_asmbl_replied_ast (struct m0_sm_group *grp, struct m0_sm_ast *ast) |
static void | cas_req_replied_ast (struct m0_sm_group *grp, struct m0_sm_ast *ast) |
static int | cas_index_op_prepare (const struct m0_cas_req *req, const struct m0_cas_id *cids, uint64_t cids_nr, bool recv_val, uint32_t flags, struct m0_cas_op **out) |
static void | addb2_add_cas_req_attrs (const struct m0_cas_req *req) |
static int | cas_index_req_prepare (struct m0_cas_req *req, const struct m0_cas_id *cids, uint64_t cids_nr, uint64_t max_replies_nr, bool recv_val, uint32_t flags, struct m0_cas_op **op) |
M0_INTERNAL uint64_t | m0_cas_req_nr (const struct m0_cas_req *req) |
M0_INTERNAL int | m0_cas_req_wait (struct m0_cas_req *req, uint64_t states, m0_time_t to) |
M0_INTERNAL int | m0_cas_index_create (struct m0_cas_req *req, const struct m0_cas_id *cids, uint64_t cids_nr, struct m0_dtx *dtx) |
static void | cas_rep_copy (const struct m0_cas_req *req, uint64_t idx, struct m0_cas_rec_reply *rep) |
M0_INTERNAL void | m0_cas_index_create_rep (const struct m0_cas_req *req, uint64_t idx, struct m0_cas_rec_reply *rep) |
M0_INTERNAL int | m0_cas_index_delete (struct m0_cas_req *req, const struct m0_cas_id *cids, uint64_t cids_nr, struct m0_dtx *dtx, uint32_t flags) |
M0_INTERNAL void | m0_cas_index_delete_rep (const struct m0_cas_req *req, uint64_t idx, struct m0_cas_rec_reply *rep) |
M0_INTERNAL int | m0_cas_index_lookup (struct m0_cas_req *req, const struct m0_cas_id *cids, uint64_t cids_nr) |
M0_INTERNAL void | m0_cas_index_lookup_rep (const struct m0_cas_req *req, uint64_t idx, struct m0_cas_rec_reply *rep) |
M0_INTERNAL int | m0_cas_index_list (struct m0_cas_req *req, const struct m0_fid *start_fid, uint32_t indices_nr, uint32_t flags) |
static int | cas_next_rc (int64_t service_rc) |
M0_INTERNAL void | m0_cas_index_list_rep (struct m0_cas_req *req, uint32_t idx, struct m0_cas_ilist_reply *rep) |
static int | cas_records_op_prepare (const struct m0_cas_req *req, const struct m0_cas_id *index, const struct m0_bufvec *keys, const struct m0_bufvec *values, uint32_t flags, struct m0_cas_op **out) |
static int | cas_req_prep (struct m0_cas_req *req, const struct m0_cas_id *index, const struct m0_bufvec *keys, const struct m0_bufvec *values, uint64_t max_replies_nr, uint32_t flags, struct m0_cas_op **op) |
M0_INTERNAL int | m0_cas_put (struct m0_cas_req *req, struct m0_cas_id *index, const struct m0_bufvec *keys, const struct m0_bufvec *values, struct m0_dtx *dtx, uint32_t flags) |
M0_INTERNAL void | m0_cas_put_rep (struct m0_cas_req *req, uint64_t idx, struct m0_cas_rec_reply *rep) |
static int | m0_cas__get (struct m0_cas_req *req, struct m0_cas_id *index, const struct m0_bufvec *keys, int flags) |
M0_INTERNAL int | m0_cas_get (struct m0_cas_req *req, struct m0_cas_id *index, const struct m0_bufvec *keys) |
M0_INTERNAL int | m0_cas_versioned_get (struct m0_cas_req *req, struct m0_cas_id *index, const struct m0_bufvec *keys) |
M0_INTERNAL void | m0_cas_get_rep (const struct m0_cas_req *req, uint64_t idx, struct m0_cas_get_reply *rep) |
M0_INTERNAL int | m0_cas_next (struct m0_cas_req *req, struct m0_cas_id *index, struct m0_bufvec *start_keys, uint32_t *recs_nr, uint32_t flags) |
M0_INTERNAL void | m0_cas_rep_mlock (const struct m0_cas_req *req, uint64_t idx) |
M0_INTERNAL void | m0_cas_next_rep (const struct m0_cas_req *req, uint32_t idx, struct m0_cas_next_reply *rep) |
M0_INTERNAL int | m0_cas_del (struct m0_cas_req *req, struct m0_cas_id *index, struct m0_bufvec *keys, struct m0_dtx *dtx, uint32_t flags) |
M0_INTERNAL void | m0_cas_del_rep (struct m0_cas_req *req, uint64_t idx, struct m0_cas_rec_reply *rep) |
M0_INTERNAL int | m0_cas_sm_conf_init (void) |
M0_INTERNAL void | m0_cas_sm_conf_fini (void) |
Variables | |
static const struct m0_rpc_item_ops | cas_item_ops |
static const struct m0_rpc_item_ops | asmbl_item_ops |
static struct m0_sm_state_descr | cas_req_states [] |
static struct m0_sm_trans_descr | cas_req_trans [] |
struct m0_sm_conf | cas_req_sm_conf |
CAS client provides an interface to make queries to CAS service. It's a thin layer that hides network communication details with CAS service. CAS client doesn't provide distribution of requests over remote CAS services, user explicitly specify destination of every request.
Request to CAS service instance is represented by m0_cas_req structure. General workflow with the request is:
Available requests:
If one of the functions above returns non-zero return code, then further request processing is impossible and the request should be finalised using m0_cas_req_fini(). All requests are vectorised. CAS client doesn't copy values of vector items for index records, so they should be accessible until the request is processed. It is not needed for requests made for operations over indices.
For every request there is corresponding function to obtain the result of request execution (m0_cas_*_rep() family). After the request is processed, return code can be obtained for operation against every input vector's item. If m0_cas_req_generic_rc() returns 0 for the request, then number and order of items obtained via m0_cas_*_rep() is guaranteed to be the same as in original request. The exceptions are m0_cas_index_list_rep() and m0_cas_next_rep() functions, which can return less records than requested.
Indices are uniquely identified by their FIDs, which are m0_fid values with m0_cas_index_fid_type as a FID type. Note, that FID (0,0) is reserved by implementation and shouldn't be used in requests (see m0_cas_meta_fid).
In order to meet atomicity and durability requirements, modification requests should be executed as part of a distributed transaction.
Request has associated state machine executed in a state machine group provided during initialisation. All requests should be invoked with state machine group mutex held. There are helpers to lock/unlock this state machine group (m0_cas_lock(), m0_cas_unlock()). All request state transitions are done in the context of this state machine group.
There is no restriction on the size of keys and values.
#define CASREQ_FOP_DATA | ( | fop | ) | ((struct m0_cas_op *)m0_fop_data(fop)) |
enum m0_cas_req_state |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Fills outgoing record 'rec' that is a part of an assembly FOP.
Key/value data is assigned from original GET request. Indices of records in original and assembly requests may be different, 'idx' is an index of a record in assembly request and 'orig_idx' is an index of a record in original GET request that should be re-requested.
Definition at line 623 of file client.c.
|
static |
|
static |
|
static |
|
static |
|
static |
M0_INTERNAL int m0_cas_del | ( | struct m0_cas_req * | req, |
struct m0_cas_id * | index, | ||
struct m0_bufvec * | keys, | ||
struct m0_dtx * | dtx, | ||
uint32_t | flags | ||
) |
Deletes records with given keys from the index.
Keys buffers (m0_bufvec::ov_vec[i]) should be accessible until request is processed.
'Flags' argument is a bitmask of m0_cas_op_flags values. COF_DEL_LOCK is the only possible flag for now.
Definition at line 1842 of file client.c.
M0_INTERNAL void m0_cas_del_rep | ( | struct m0_cas_req * | req, |
uint64_t | idx, | ||
struct m0_cas_rec_reply * | rep | ||
) |
Gets execution result of m0_cas_del() request.
Definition at line 1873 of file client.c.
M0_INTERNAL int m0_cas_get | ( | struct m0_cas_req * | req, |
struct m0_cas_id * | index, | ||
const struct m0_bufvec * | keys | ||
) |
Gets values for provided keys.
Keys buffers (m0_bufvec::ov_vec[i]) should be accessible until request is processed.
Definition at line 1741 of file client.c.
M0_INTERNAL void m0_cas_get_rep | ( | const struct m0_cas_req * | req, |
uint64_t | idx, | ||
struct m0_cas_get_reply * | rep | ||
) |
Gets execution result of m0_cas_get() request.
Function fills rep->cge_val. Value data buffer is deallocated in m0_cas_req_fini(), unless m0_cas_rep_mlock() is called by user.
Definition at line 1755 of file client.c.
M0_INTERNAL int m0_cas_index_create | ( | struct m0_cas_req * | req, |
const struct m0_cas_id * | cids, | ||
uint64_t | cids_nr, | ||
struct m0_dtx * | dtx | ||
) |
Creates new indices.
It is not needed to keep CAS ids array accessible until request is processed.
Definition at line 1321 of file client.c.
M0_INTERNAL void m0_cas_index_create_rep | ( | const struct m0_cas_req * | req, |
uint64_t | idx, | ||
struct m0_cas_rec_reply * | rep | ||
) |
Gets execution result of m0_cas_index_create() request.
Definition at line 1357 of file client.c.
M0_INTERNAL int m0_cas_index_delete | ( | struct m0_cas_req * | req, |
const struct m0_cas_id * | cids, | ||
uint64_t | cids_nr, | ||
struct m0_dtx * | dtx, | ||
uint32_t | flags | ||
) |
Delete indices with all records they contain.
It is not needed to keep CAS ids array accessible until request is processed. Flag m0_cas_op_flags::COF_CROW can be set in flags to be a no-op if the catalogue to be deleted does not exist.
Definition at line 1366 of file client.c.
M0_INTERNAL void m0_cas_index_delete_rep | ( | const struct m0_cas_req * | req, |
uint64_t | idx, | ||
struct m0_cas_rec_reply * | rep | ||
) |
Gets execution result of m0_cas_index_delete() request.
Definition at line 1394 of file client.c.
M0_INTERNAL int m0_cas_index_list | ( | struct m0_cas_req * | req, |
const struct m0_fid * | start_fid, | ||
uint32_t | indices_nr, | ||
uint32_t | flags | ||
) |
Gets identifiers of the next 'indices_nr' indices starting with index having 'start_fid' identifier.
Zero FID (0,0) (see m0_cas_meta_fid) can be used as a 'start_fid' in order to start iteration from the first index. Note, that zero FID is also included in the result.
Definition at line 1435 of file client.c.
M0_INTERNAL void m0_cas_index_list_rep | ( | struct m0_cas_req * | req, |
uint32_t | idx, | ||
struct m0_cas_ilist_reply * | rep | ||
) |
Gets execution result of m0_cas_index_list() request.
The fact that there are no more indices to return on CAS service side (end of list is reached) is denoted by special reply record with -ENOENT return code.
Definition at line 1488 of file client.c.
M0_INTERNAL int m0_cas_index_lookup | ( | struct m0_cas_req * | req, |
const struct m0_cas_id * | cids, | ||
uint64_t | cids_nr | ||
) |
Checks whether indices with given identifiers exist.
It is not needed to keep CAS ids array accessible until request is processed.
Definition at line 1403 of file client.c.
M0_INTERNAL void m0_cas_index_lookup_rep | ( | const struct m0_cas_req * | req, |
uint64_t | idx, | ||
struct m0_cas_rec_reply * | rep | ||
) |
Gets execution result of m0_cas_index_lookup() request.
Return code meaning in m0_cas_rec_reply: 0 - index exists; -ENOENT - index doesn't exist; other - some error during request processing.
Definition at line 1426 of file client.c.
M0_INTERNAL int m0_cas_next | ( | struct m0_cas_req * | req, |
struct m0_cas_id * | index, | ||
struct m0_bufvec * | start_keys, | ||
uint32_t * | recs_nr, | ||
uint32_t | flags | ||
) |
Gets next 'recs_nr[i]' records for each i-th key in 'start_keys'.
Size of recs_nr array should be >= start_keys->ov_vec.v_nr.
Requested record ranges may overlap. Duplicates in a result are not filtered.
Records with 'start_keys' keys are also accounted and included in the result unless COF_EXCLUDE_START_KEY flag is specified.
In order to start iteration from the first record user may specify 1-byte zero start key and specify COF_SLANT flag. COF_SLANT flag is also useful if start key may be not found in the index. In this case iteration starts with the smallest key following the start key.
'Flags' argument is a bitmask of m0_cas_op_flags values.
Definition at line 1775 of file client.c.
M0_INTERNAL void m0_cas_next_rep | ( | const struct m0_cas_req * | req, |
uint32_t | idx, | ||
struct m0_cas_next_reply * | rep | ||
) |
Gets execution result of m0_cas_next() request.
The fact that there are no more records to return on CAS service side (end of index is reached) is denoted by special reply record with -ENOENT return code.
Function doesn't copy key/value data buffers, only assign pointers to received buffers. They are deallocated in m0_cas_req_fini(), unless m0_cas_rep_mlock() is called by user.
Definition at line 1825 of file client.c.
M0_INTERNAL int m0_cas_put | ( | struct m0_cas_req * | req, |
struct m0_cas_id * | index, | ||
const struct m0_bufvec * | keys, | ||
const struct m0_bufvec * | values, | ||
struct m0_dtx * | dtx, | ||
uint32_t | flags | ||
) |
Inserts records to the index.
Keys and values buffers (m0_bufvec::ov_vec[i]) should be accessible until request is processed. Also, it's user responsibility to manage these buffers after request is processed.
'Flags' argument is a bitmask of m0_cas_op_flags values. COF_CREATE and COF_OVERWRITE flags can't be specified together.
Definition at line 1643 of file client.c.
M0_INTERNAL void m0_cas_put_rep | ( | struct m0_cas_req * | req, |
uint64_t | idx, | ||
struct m0_cas_rec_reply * | rep | ||
) |
Gets execution result of m0_cas_put() request.
Definition at line 1685 of file client.c.
M0_INTERNAL void m0_cas_rep_mlock | ( | const struct m0_cas_req * | req, |
uint64_t | idx | ||
) |
Prevents deallocation of key/value buffers during request finalisation.
Applicable only for GET, NEXT requests. In case of GET request m0_cas_get_reply::cge_val::b_addr pointer, obtained by corresponding 'idx' will be locked in memory and user is responsible to deallocate it afterwards. In case of NEXT request both key and value buffers in m0_cas_next_reply buffer are locked and user is responsible to deallocate them.
Definition at line 1816 of file client.c.
M0_INTERNAL void m0_cas_req_fini | ( | struct m0_cas_req * | req | ) |
Finalises CAS client request.
It's not allowed to call it when request is in progress. Once one of request functions is called, user should wait until SM reaches CASREQ_FINAL or CASREQ_FAILURE state. There is no way to cancel current operation.
Definition at line 288 of file client.c.
M0_INTERNAL void m0_cas_req_fini_lock | ( | struct m0_cas_req * | req | ) |
The same as m0_cas_req_fini(), but takes CAS request lock internally.
Definition at line 295 of file client.c.
M0_INTERNAL int m0_cas_req_generic_rc | ( | const struct m0_cas_req * | req | ) |
Gets request execution return code.
Should be called only after request processing is finished, i.e. CAS request is in CASREQ_FINAL or CASREQ_FAILURE state.
This return code is generic in sense that it doesn't take into account return codes of operations on individual request records. These codes can be obtained via m0_cas_*_rep() functions.
Definition at line 457 of file client.c.
M0_INTERNAL void m0_cas_req_init | ( | struct m0_cas_req * | req, |
struct m0_rpc_session * | sess, | ||
struct m0_sm_group * | grp | ||
) |
Initialises CAS client request.
Initialisation should be done always before sending specific request. RPC session 'sess' to CAS service should be already established.
Definition at line 195 of file client.c.
M0_INTERNAL bool m0_cas_req_is_locked | ( | const struct m0_cas_req * | req | ) |
M0_INTERNAL void m0_cas_req_lock | ( | struct m0_cas_req * | req | ) |
M0_INTERNAL uint64_t m0_cas_req_nr | ( | const struct m0_cas_req * | req | ) |
Returns the number of results.
For the following requests it's guaranteed that if m0_cas_req_generic_rc(req) == 0, then m0_cas_req_nr() equals to the number of requested items:
Definition at line 1308 of file client.c.
M0_INTERNAL void m0_cas_req_unlock | ( | struct m0_cas_req * | req | ) |
M0_INTERNAL int m0_cas_req_wait | ( | struct m0_cas_req * | req, |
uint64_t | states, | ||
m0_time_t | to | ||
) |
Synchronously waits until CAS request reaches a desired state.
The 'states' argument is a bitmask based on m0_cas_req_state. M0_BITS() macro should be used to build a bitmask.
to | absolute timeout to wait. |
Definition at line 1313 of file client.c.
M0_INTERNAL void m0_cas_sm_conf_fini | ( | void | ) |
M0_INTERNAL int m0_cas_sm_conf_init | ( | void | ) |
M0_INTERNAL int m0_cas_versioned_get | ( | struct m0_cas_req * | req, |
struct m0_cas_id * | index, | ||
const struct m0_bufvec * | keys | ||
) |
A version-aware version of m0_cas_get. It returns the values associated with the given keys only if this values do not have tombstones set (i.e., they have not been removed). See COF_VERSIONED.
TODO: This function may be disolved if m0_cas_get gets an extra argument (flags).
Definition at line 1748 of file client.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
struct m0_sm_conf cas_req_sm_conf |
|
static |
|
static |