Motr  M0
cob.c File Reference
#include "motr/client.h"
#include "motr/client_internal.h"
#include "motr/layout.h"
#include "motr/idx.h"
#include "motr/sync.h"
#include "lib/errno.h"
#include "lib/finject.h"
#include "fid/fid.h"
#include "fop/fom_generic.h"
#include "ioservice/fid_convert.h"
#include "mdservice/md_fops.h"
#include "rpc/rpclib.h"
#include "rpc/rpc_opcodes.h"
#include "motr/addb.h"
#include "lib/trace.h"
Include dependency graph for cob.c:

Go to the source code of this file.

Data Structures

struct  ios_cob_req
 
struct  cob_req
 

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_CLIENT
 
#define OSYNC
 

Enumerations

enum  cob_request_flags { COB_REQ_ASYNC = (1 << 1), COB_REQ_SYNC = (1 << 2) }
 
enum  { IOS_COB_REQ_DEADLINE = 2000000 }
 

Functions

 M0_BOB_DEFINE (M0_INTERNAL, &cr_bobtype, cob_req)
 
 M0_BOB_DEFINE (static, &icr_bobtype, ios_cob_req)
 
static void cob_ios_fop_fini (struct m0_fop *ios_fop)
 
static void cob_ast_ios_io_send (struct m0_sm_group *grp, struct m0_sm_ast *ast)
 
static int cob_mds_send (struct cob_req *cr)
 
static int cob_ios_md_send (struct cob_req *cr)
 
static void to_cob_req_map (const struct m0_op *op, const struct cob_req *cr)
 
static void cob_req_to_rpc_map (const struct cob_req *cr, const struct m0_rpc_item *item)
 
static bool ios_cob_req_invariant (struct ios_cob_req *icr)
 
static int cob_name_mem2wire (struct m0_fop_str *tgt, const struct m0_buf *name)
 
static void cob_body_mem2wire (struct m0_fop_cob *body, struct m0_cob_attr *attr, int valid, struct cob_req *cr)
 
static void cob_body_wire2mem (struct m0_cob_attr *attr, const struct m0_fop_cob *body)
 
static void cob_attr_init (struct cob_req *cr, struct m0_cob_attr *attr, int *valid)
 
static void cob_req_release (struct cob_req *cr)
 
static void cob_req_ref_release (struct m0_ref *ref)
 
M0_INTERNAL struct cob_reqcob_req_ref_get (struct cob_req *cr)
 
M0_INTERNAL void cob_req_ref_put (struct cob_req *cr)
 
static struct cob_reqcob_req_alloc (struct m0_pool_version *pv)
 
static void cob_req_free (struct cob_req *cr)
 
static int cob_req_send (struct cob_req *cr)
 
static int cob_make_name (struct cob_req *cr)
 
static void cob_entity_sm_move (struct m0_op *op)
 
static void cob_complete_op (struct m0_op *op)
 
static void cob_fail_op (struct m0_op *op, int rc)
 
M0_INTERNAL void cob_rep_attr_copy (struct cob_req *cr)
 
static void cob_rep_process (struct cob_req *cr)
 
static void cob_ast_complete_cr (struct m0_sm_group *grp, struct m0_sm_ast *ast)
 
static void cob_fail_cr (struct cob_req *cr, int rc)
 
static void cob_ast_fail_cr (struct m0_sm_group *grp, struct m0_sm_ast *ast)
 
static struct ios_cob_reqrpc_item_to_icr (struct m0_rpc_item *item)
 
static void icrs_complete (struct cob_req *cr)
 
static void icrs_fail (struct cob_req *cr, int rc)
 
static int icrs_rc (struct cob_req *cr)
 
static void icr_ast (struct m0_sm_group *grp, struct m0_sm_ast *ast)
 
static void cob_ios_rio_replied (struct m0_rpc_item *item)
 
M0_INTERNAL struct m0_rpc_sessionm0_obj_container_id_to_session (struct m0_pool_version *pver, uint64_t container_id)
 
static int cob_ios_fop_populate (struct cob_req *cr, struct m0_fop *fop, struct m0_fid *cob_fid, uint32_t cob_idx)
 
static void cob_ios_fop_release (struct m0_ref *ref)
 
static int cob_ios_fop_get (struct cob_req *cr, uint32_t i, uint32_t cob_type, struct m0_rpc_session *session)
 
static int cob_ios_prepare (struct cob_req *cr, uint32_t idx)
 
static int cob_ios_send (struct cob_req *cr, uint32_t idx)
 
static int cob_ios_req_send_sync (struct cob_req *cr)
 
static int cob_ios_req_send_async (struct cob_req *cr)
 
static struct cob_reqrpc_item_to_cr (struct m0_rpc_item *item)
 
static void cob_mds_rio_replied (struct m0_rpc_item *item)
 
static int cob_mds_fop_populate (struct cob_req *cr, struct m0_fop *fop)
 
static struct m0_rpc_sessionfid_to_mds_session (struct m0_client *cinst, const struct m0_fid *fid)
 
M0_INTERNAL int m0__obj_namei_send (struct m0_op_obj *oo)
 
M0_INTERNAL int m0__obj_namei_cancel (struct m0_op *op)
 
static int cob_getattr_rep_rc (struct cob_req *cr)
 
M0_INTERNAL int m0__obj_attr_get_sync (struct m0_obj *obj)
 
M0_INTERNAL int m0__obj_layout_send (struct m0_obj *obj, struct m0_op_layout *ol)
 

Variables

const struct m0_bob_type cr_bobtype
 
static const struct m0_bob_type icr_bobtype
 
static const struct m0_rpc_item_ops cob_ios_ri_ops
 
static const struct m0_rpc_item_ops cob_mds_ri_ops
 

Macro Definition Documentation

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_CLIENT

Definition at line 39 of file cob.c.

◆ OSYNC

#define OSYNC

Definition at line 42 of file cob.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Cob create/delete fop send deadline (in ns). Used to utilize RPC formation when too many fops are sending to one ioservice.

Enumerator
IOS_COB_REQ_DEADLINE 

Definition at line 89 of file cob.c.

◆ cob_request_flags

Enumerator
COB_REQ_ASYNC 
COB_REQ_SYNC 

Definition at line 51 of file cob.c.

Function Documentation

◆ cob_ast_complete_cr()

static void cob_ast_complete_cr ( struct m0_sm_group grp,
struct m0_sm_ast ast 
)
static

AST callback to complete a whole object operation.

Parameters
grpgroup the AST is executed in.
astcallback being executed.

Definition at line 618 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_ast_fail_cr()

static void cob_ast_fail_cr ( struct m0_sm_group grp,
struct m0_sm_ast ast 
)
static

AST callback to fail a whole object operation.

Parameters
grpgroup the AST is executed in.
astcallback being executed.

Definition at line 661 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_ast_ios_io_send()

static void cob_ast_ios_io_send ( struct m0_sm_group grp,
struct m0_sm_ast ast 
)
static

AST callback that contacts multiple ioservices to the cobs that form an object.

Parameters
grpgroup the AST is executed in.
astcallback being executed.

Definition at line 1352 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_attr_init()

static void cob_attr_init ( struct cob_req cr,
struct m0_cob_attr attr,
int *  valid 
)
static

Definition at line 216 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_body_mem2wire()

static void cob_body_mem2wire ( struct m0_fop_cob body,
struct m0_cob_attr attr,
int  valid,
struct cob_req cr 
)
static

Fills a m0_fop_cob so it can be sent to a mdservice.

Parameters
bodycob fop to be filled.
ooobj operation the information is retrieved from.

Definition at line 178 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_body_wire2mem()

static void cob_body_wire2mem ( struct m0_cob_attr attr,
const struct m0_fop_cob body 
)
static

Definition at line 200 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_complete_op()

static void cob_complete_op ( struct m0_op op)
static

Completes an object operation by moving the state of all its state machines to successful states.

Parameters
ooobject operation being completed.

Definition at line 457 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_entity_sm_move()

static void cob_entity_sm_move ( struct m0_op op)
static

Definition at line 409 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_fail_cr()

static void cob_fail_cr ( struct cob_req cr,
int  rc 
)
static

Definition at line 642 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_fail_op()

static void cob_fail_op ( struct m0_op op,
int  rc 
)
static

Fails a whole operation and moves the state of its state machine. Note that when failing an operation, an error code is stored in m0_op::op_rc and its state is set to STABLE if the op has already been launched (in LAUNCHED state).

Parameters
ooobject operation to be failed.
rcerror code that explains why the operation is being failed.

Definition at line 489 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_getattr_rep_rc()

static int cob_getattr_rep_rc ( struct cob_req cr)
static

Definition at line 1953 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_ios_fop_fini()

static void cob_ios_fop_fini ( struct m0_fop ios_fop)
static

Definition at line 1002 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_ios_fop_get()

static int cob_ios_fop_get ( struct cob_req cr,
uint32_t  i,
uint32_t  cob_type,
struct m0_rpc_session session 
)
static

Allocates a cob fop to an ioservice.

Parameters
ooobject operation being processed.
iindex of the cob.

Definition at line 1044 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_ios_fop_populate()

static int cob_ios_fop_populate ( struct cob_req cr,
struct m0_fop fop,
struct m0_fid cob_fid,
uint32_t  cob_idx 
)
static

Populates a fop with the information contained within an object operation. The fop will be sent to an ioservice to request the creation or deletion of a cob.

Parameters
ooobject operation.
fopfop being populated.
cob_fidfid of the cob being created/deleted.
cob_idxindex of the cob inside the object's layout.

Definition at line 957 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_ios_fop_release()

static void cob_ios_fop_release ( struct m0_ref ref)
static

Definition at line 1017 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_ios_md_send()

static int cob_ios_md_send ( struct cob_req cr)
static

Sends entity namespace fops to a io services(oostore mode only), as part of the processing of a create/delete object operation.

Parameters
crCOB request being processed.
Returns
0 if success or an error code otherwise.

Definition at line 1406 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_ios_prepare()

static int cob_ios_prepare ( struct cob_req cr,
uint32_t  idx 
)
static

Prepares a COB fop to be sent.

It is important to prepare all fops before sending them in ASYNC mode, because a race possible otherwise. If a reply is received before all values are set to cr->cr_ios_fop array, icr_ast() can finish cob request early and cause a panic. See MOTR-2887 for details.

This functions is intended to be used in pair with cob_ios_send().

Definition at line 1135 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_ios_req_send_async()

static int cob_ios_req_send_async ( struct cob_req cr)
static

Definition at line 1307 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_ios_req_send_sync()

static int cob_ios_req_send_sync ( struct cob_req cr)
static

Definition at line 1276 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_ios_rio_replied()

static void cob_ios_rio_replied ( struct m0_rpc_item item)
static

rio_replied RPC callback to be executed whenever a reply to a create/delete cob fop is received from an ioservice.

Parameters
itemRPC item used to communicate to the ioservice.

Definition at line 873 of file cob.c.

Here is the call graph for this function:

◆ cob_ios_send()

static int cob_ios_send ( struct cob_req cr,
uint32_t  idx 
)
static

Sends a COB fop to an ioservice.

Parameters
crCOB request being processed.
idxindex of the cob.
Remarks
This function gets called from an AST. Do not call it from a RPC callback.
This function might be used to re-send fop to an ioservice.

Definition at line 1236 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_make_name()

static int cob_make_name ( struct cob_req cr)
static

Definition at line 383 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_mds_fop_populate()

static int cob_mds_fop_populate ( struct cob_req cr,
struct m0_fop fop 
)
static

Populates a COB fop for the namespace operation. This type of fop is sent to the mdservice to create/delete new objects.

Parameters
ooobject operation whose processing triggers this call. Contains the info to populate the fop with.
fopfop being stuffed.

Definition at line 1595 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_mds_rio_replied()

static void cob_mds_rio_replied ( struct m0_rpc_item item)
static

rio_replied RPC callback to be executed whenever a reply to an object namespace request is received. The mdservice gets contacted as a first step when creating/deleting an object. This callback gets executed when a reply arrives from the mdservice. It also gets executed if the RPC component has detected any error.

Parameters
itemRPC item used to communicate to the mdservice.

Definition at line 1472 of file cob.c.

Here is the call graph for this function:

◆ cob_mds_send()

static int cob_mds_send ( struct cob_req cr)
static

Sends COB fops to a mdservice, as part of the processing of a object operation.

Parameters
ooobject operation being processed.
Returns
0 if success or an error code otherwise.

Definition at line 1721 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_name_mem2wire()

static int cob_name_mem2wire ( struct m0_fop_str tgt,
const struct m0_buf name 
)
static

Copies a name into a m0_fop_str.

Parameters
tgtdest buffer.
namesrc buffer.
Returns
0 if success or -ENOMEM if the dest buffer could not be initialised.

Definition at line 154 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_rep_attr_copy()

M0_INTERNAL void cob_rep_attr_copy ( struct cob_req cr)

Definition at line 555 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_rep_process()

static void cob_rep_process ( struct cob_req cr)
static

Definition at line 585 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_req_alloc()

static struct cob_req* cob_req_alloc ( struct m0_pool_version pv)
static

Allocates and initializes object of cob_req structures.

Parameters
cinstclient instance.
Returns
instance of cob_req if operation succeeds, NULL otherwise.

Definition at line 305 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_req_free()

static void cob_req_free ( struct cob_req cr)
static

Put reference of cob_req. During cob request alloc, reference on cob request is taken, during cob request free, reference is released. when there are no references to cob request, cob_req_release is called which will free the cob request structure.

For index operations cr_op is not set.

Definition at line 342 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_req_ref_get()

M0_INTERNAL struct cob_req* cob_req_ref_get ( struct cob_req cr)

Definition at line 285 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_req_ref_put()

M0_INTERNAL void cob_req_ref_put ( struct cob_req cr)

Definition at line 292 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_req_ref_release()

static void cob_req_ref_release ( struct m0_ref ref)
static

Definition at line 275 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_req_release()

static void cob_req_release ( struct cob_req cr)
static

Definition at line 246 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_req_send()

static int cob_req_send ( struct cob_req cr)
static

Definition at line 363 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cob_req_to_rpc_map()

static void cob_req_to_rpc_map ( const struct cob_req cr,
const struct m0_rpc_item item 
)
static

Definition at line 128 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fid_to_mds_session()

static struct m0_rpc_session* fid_to_mds_session ( struct m0_client cinst,
const struct m0_fid fid 
)
static

Retrieves the rpc session for the mdservice to contact when creating/deleting an object. Client selects the mdservice to contact using the object's fid.

Parameters
cinstclient instance.
fidfid of the object.
Returns
rpc session established with the mdservice.

Definition at line 1694 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icr_ast()

static void icr_ast ( struct m0_sm_group grp,
struct m0_sm_ast ast 
)
static

AST callback to an IOS cob request. No action is taken before all IOS cob request are received.

Parameters
grpgroup the AST is executed in.
astcallback being executed.

Definition at line 806 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icrs_complete()

static void icrs_complete ( struct cob_req cr)
static

Definition at line 712 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icrs_fail()

static void icrs_fail ( struct cob_req cr,
int  rc 
)
static

Definition at line 748 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icrs_rc()

static int icrs_rc ( struct cob_req cr)
static

Definition at line 763 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ios_cob_req_invariant()

static bool ios_cob_req_invariant ( struct ios_cob_req icr)
static

Checks an IOS COB request is not malformed or corrupted.

Parameters
icrIOS COB request to be checked.
Returns
true if the operation is not malformed or false if some error was detected.

Definition at line 141 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0__obj_attr_get_sync()

M0_INTERNAL int m0__obj_attr_get_sync ( struct m0_obj obj)

Get object's attributes from services synchronously.

Parameters
objobject to be queried for.
Returns
0 if success or an error code otherwise.

Definition at line 1974 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0__obj_layout_send()

M0_INTERNAL int m0__obj_layout_send ( struct m0_obj obj,
struct m0_op_layout ol 
)

Definition at line 2043 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0__obj_namei_cancel()

M0_INTERNAL int m0__obj_namei_cancel ( struct m0_op op)

Cancels fops sent during namei launch operation

Parameters
opoperation to be cancelled
Returns
0 if success ot an error code otherwise

Definition at line 1915 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0__obj_namei_send()

M0_INTERNAL int m0__obj_namei_send ( struct m0_op_obj oo)

Sends COB fops to mdservices or ioservices depending on COB operation's protocol.

Parameters
ooobject operation being processed.
Returns
0 if success or an error code otherwise.

save cr in op structure, will be used in op cancel operation priv_lock can be skipped because it is just initialized. set referenced flag in cob request required during free

Skip meta-data lookup if obj.ob_attr.oa_pver is not empty. pver is not empty that means calling application has capability to store meta-data(pver) and has sent pver to open/delete entity.

For DELETE entity we skipped md cob if M0_ENF_META is set, but we still wants to send data cob. This case is handled here by posting cob_ast_ios_io_send AST.

Definition at line 1804 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ M0_BOB_DEFINE() [1/2]

M0_BOB_DEFINE ( M0_INTERNAL  ,
cr_bobtype,
cob_req   
)

◆ M0_BOB_DEFINE() [2/2]

M0_BOB_DEFINE ( static  ,
icr_bobtype,
ios_cob_req   
)

◆ m0_obj_container_id_to_session()

M0_INTERNAL struct m0_rpc_session* m0_obj_container_id_to_session ( struct m0_pool_version pv,
uint64_t  container_id 
)

Retrieves the ios session corresponding to a container_id. The ioservice for an object is calculated from the container id.

Parameters
cinstclient instance.
container_idcontainer ID.
Returns
the session associated to the
Remarks
container_id == 0 is not valid.

Definition at line 925 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rpc_item_to_cr()

static struct cob_req* rpc_item_to_cr ( struct m0_rpc_item item)
static

Returns the object operation associated to a given RPC item.Items are sent to services when processing an operation. This function provides a pointer to the original object operation that triggered the communication.

Parameters
itemRPC item.
Returns
a pointer to the object operation that triggered the creation of the item.

Definition at line 1448 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rpc_item_to_icr()

static struct ios_cob_req* rpc_item_to_icr ( struct m0_rpc_item item)
static

----------------------------------------------------------------------——*

COB FOP's for ioservice *

Retrieves the ios_cob_req an rpc item is associated to. This allows figuring out which slot inside the object operation corresponds to the communication with a specific ioservice.

Parameters
itemRPC item used to communicate to a specific ioservice. It contains both the request sent from client and the reply received from the ioservice.
Returns
a ios_cob_req, which points to a slot within an object operation.

Definition at line 697 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_cob_req_map()

static void to_cob_req_map ( const struct m0_op op,
const struct cob_req cr 
)
static

Definition at line 115 of file cob.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ cob_ios_ri_ops

const struct m0_rpc_item_ops cob_ios_ri_ops
static
Initial value:
= {
.rio_replied = cob_ios_rio_replied,
}
static void cob_ios_rio_replied(struct m0_rpc_item *item)
Definition: cob.c:873

RPC callbacks for the posting of COB FOPs to ioservices.

Definition at line 920 of file cob.c.

◆ cob_mds_ri_ops

const struct m0_rpc_item_ops cob_mds_ri_ops
static
Initial value:
= {
.rio_replied = cob_mds_rio_replied,
}
static void cob_mds_rio_replied(struct m0_rpc_item *item)
Definition: cob.c:1472

RPC callbacks for the posting of COB fops to mdservices.

Definition at line 1583 of file cob.c.

◆ cr_bobtype

const struct m0_bob_type cr_bobtype
Initial value:
= {
.bt_name = "cr_bobtype",
.bt_magix_offset = offsetof(struct cob_req, cr_magic),
.bt_magix = M0_CR_MAGIC,
.bt_check = NULL,
}
#define NULL
Definition: misc.h:38
Definition: dir.c:58
#define offsetof(typ, memb)
Definition: misc.h:29

Definition at line 91 of file cob.c.

◆ icr_bobtype

static const struct m0_bob_type icr_bobtype
static
Initial value:
= {
.bt_name = "icr_bobtype",
.bt_magix_offset = offsetof(struct ios_cob_req, icr_magic),
.bt_magix = M0_ICR_MAGIC,
.bt_check = NULL,
}
#define NULL
Definition: misc.h:38
#define offsetof(typ, memb)
Definition: misc.h:29

Definition at line 100 of file cob.c.