Motr  M0
obj.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 "fid/fid.h"
#include "lib/locality.h"
#include "lib/misc.h"
#include "ioservice/fid_convert.h"
#include "layout/layout.h"
#include "conf/helpers.h"
#include "lib/trace.h"
#include "lib/finject.h"
Include dependency graph for obj.c:

Go to the source code of this file.

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_CLIENT
 

Functions

M0_INTERNAL struct m0_clientm0__oo_instance (struct m0_op_obj *oo)
 
M0_INTERNAL struct m0_objm0__obj_entity (struct m0_entity *entity)
 
static bool m0_op_common_invariant (struct m0_op_common *oc)
 
M0_INTERNAL bool m0_op_obj_ast_rc_invariant (struct m0_ast_rc *ar)
 
M0_INTERNAL bool m0_op_obj_invariant (struct m0_op_obj *oo)
 
static bool obj_op_obj_invariant (struct m0_op_obj *oo)
 
static bool obj_layout_id_invariant (uint64_t layout_id)
 
M0_INTERNAL uint64_t m0__obj_lid (struct m0_obj *obj)
 
M0_INTERNAL enum m0_client_layout_type m0__obj_layout_type (struct m0_obj *obj)
 
M0_INTERNAL void m0__obj_attr_set (struct m0_obj *obj, struct m0_fid pver, uint64_t layout_id)
 
M0_INTERNAL struct m0_fid m0__obj_pver (struct m0_obj *obj)
 
M0_INTERNAL bool m0__obj_pool_version_is_valid (const struct m0_obj *obj)
 
static void obj_namei_cb_cancel (struct m0_op_common *oc)
 
static void obj_namei_cb_launch (struct m0_op_common *oc)
 
static void obj_namei_cb_free (struct m0_op_common *oc)
 
static void obj_namei_cb_fini (struct m0_op_common *oc)
 
M0_INTERNAL int m0__obj_pool_version_get (struct m0_obj *obj, struct m0_pool_version **pv)
 
M0_INTERNAL uint64_t m0__obj_layout_id_get (struct m0_op_obj *oo)
 
M0_INTERNAL int m0__obj_layout_instance_build (struct m0_client *cinst, const uint64_t layout_id, const struct m0_fid *fid, struct m0_layout_instance **linst)
 
static int obj_namei_op_init (struct m0_entity *entity, struct m0_op *op)
 
static void obj_optimal_lid_set (struct m0_obj *obj, struct m0_layout_domain *ldom)
 
static int obj_op_obj_init (struct m0_op_obj *oo)
 
static int obj_op_prepare (struct m0_entity *entity, struct m0_op **op, enum m0_entity_opcode opcode)
 
static int entity_namei_op (struct m0_entity *entity, struct m0_op **op, enum m0_entity_opcode opcode)
 
int m0_entity_create (struct m0_fid *pool, struct m0_entity *entity, struct m0_op **op)
 
int m0_entity_delete (struct m0_entity *entity, struct m0_op **op)
 
uint64_t m0_obj_unit_size_to_layout_id (int unit_size)
 
int m0_obj_layout_id_to_unit_size (uint64_t layout_id)
 
uint64_t m0_client_layout_id (const struct m0_client *instance)
 
enum m0_client_layout_type m0_obj_layout_type (struct m0_obj *obj)
 
int m0_entity_open (struct m0_entity *entity, struct m0_op **op)
 

Macro Definition Documentation

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_CLIENT

Definition at line 37 of file obj.c.

Function Documentation

◆ entity_namei_op()

static int entity_namei_op ( struct m0_entity entity,
struct m0_op **  op,
enum m0_entity_opcode  opcode 
)
static

Sets a entity operation to modify the object namespace. This type of operation on entities allow creating and deleting entities.

Parameters
entityentity to be modified.
oppointer to the operation being set. The caller might pre-allocate this operation.Otherwise, the function will allocate the required memory.
opcodeM0_EO_CREATE or M0_EO_DELETE.
Returns
0 if the function succeeds or an error code otherwise.

Definition at line 743 of file obj.c.

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

◆ m0__obj_attr_set()

M0_INTERNAL void m0__obj_attr_set ( struct m0_obj obj,
struct m0_fid  pver,
uint64_t  layout_id 
)

Definition at line 151 of file obj.c.

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

◆ m0__obj_entity()

M0_INTERNAL struct m0_obj* m0__obj_entity ( struct m0_entity entity)

TODO: doxygen

Definition at line 51 of file obj.c.

Here is the caller graph for this function:

◆ m0__obj_layout_id_get()

M0_INTERNAL uint64_t m0__obj_layout_id_get ( struct m0_op_obj oo)

Gets the default layout identifier from confd.

Parameters
instanceThe client instance containing information of confd.
Returns
Default layout id.

Definition at line 384 of file obj.c.

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

◆ m0__obj_layout_instance_build()

M0_INTERNAL int m0__obj_layout_instance_build ( struct m0_client cinst,
const uint64_t  layout_id,
const struct m0_fid fid,
struct m0_layout_instance **  linst 
)

Builds a layout instance using the supplied layout.

Parameters
cinstclient instance.
layout_idID of the layout.
fid(global) fid of the object this instance is associated to.
[out]linstnew layout instance.
Returns
0 if the operation succeeds or an error code (<0) otherwise.
Remarks
This function might trigger network traffic.

Definition at line 403 of file obj.c.

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

◆ m0__obj_layout_type()

M0_INTERNAL enum m0_client_layout_type m0__obj_layout_type ( struct m0_obj obj)

Definition at line 139 of file obj.c.

Here is the call graph for this function:

◆ m0__obj_lid()

M0_INTERNAL uint64_t m0__obj_lid ( struct m0_obj obj)

Definition at line 126 of file obj.c.

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

◆ m0__obj_pool_version_get()

M0_INTERNAL int m0__obj_pool_version_get ( struct m0_obj obj,
struct m0_pool_version **  pv 
)

Gets current valid pool version from client instance.

Parameters
instanceThe client instance containing information of pool and pool versions.
pvThe returned pool version.

Validate the cached pool version.

Definition at line 346 of file obj.c.

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

◆ m0__obj_pool_version_is_valid()

M0_INTERNAL bool m0__obj_pool_version_is_valid ( const struct m0_obj obj)

Definition at line 169 of file obj.c.

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

◆ m0__obj_pver()

M0_INTERNAL struct m0_fid m0__obj_pver ( struct m0_obj obj)

Definition at line 163 of file obj.c.

Here is the caller graph for this function:

◆ m0__oo_instance()

M0_INTERNAL struct m0_client* m0__oo_instance ( struct m0_op_obj oo)

Returns the client instance associated to an object operation.

Parameters
ooobject operation pointing to the instance.
Returns
a pointer to the client instance associated to the entity.

Definition at line 43 of file obj.c.

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

◆ m0_op_common_invariant()

static bool m0_op_common_invariant ( struct m0_op_common oc)
static

Checks the common part of an operation is not malformed or corrupted.

Parameters
ocoperation common to be checked.
Returns
true if the operation is not malformed or false if some error was detected.

Definition at line 67 of file obj.c.

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

◆ m0_op_obj_ast_rc_invariant()

M0_INTERNAL bool m0_op_obj_ast_rc_invariant ( struct m0_ast_rc ar)

Checks the data struct holding the AST information is not malformed or corrupted.

Parameters
arThe pointer to AST information.
Returns
true if the operation is not malformed or false if some error was detected.

Definition at line 73 of file obj.c.

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

◆ m0_op_obj_invariant()

M0_INTERNAL bool m0_op_obj_invariant ( struct m0_op_obj oo)

Checks an object operation is not malformed or corrupted.

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

Definition at line 79 of file obj.c.

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

◆ obj_layout_id_invariant()

static bool obj_layout_id_invariant ( uint64_t  layout_id)
static

Definition at line 114 of file obj.c.

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

◆ obj_namei_cb_cancel()

static void obj_namei_cb_cancel ( struct m0_op_common oc)
static

Cancels all the fops that are sent during launch operation

Parameters
ocoperation being launched. Note the operation is of type m0_op_common although it has to be allocated as a m0_op_obj.

Definition at line 187 of file obj.c.

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

◆ obj_namei_cb_fini()

static void obj_namei_cb_fini ( struct m0_op_common oc)
static

'op fini entry' on the vtable for entities. This client callback gets invoked when a create/delete operation on an object gets finalised.

Parameters
ocoperation being finalised. Note the operation is of type m0_op_common although it has to be allocated as a m0_op_obj.

Definition at line 311 of file obj.c.

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

◆ obj_namei_cb_free()

static void obj_namei_cb_free ( struct m0_op_common oc)
static

'free entry' on the vtable for obj namespace manipulation. This callback gets invoked when freeing an operation.

Parameters
ocoperation being freed. Note the operation is of type m0_op_common although it has to be allocated as a m0_op_obj.

Definition at line 285 of file obj.c.

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

◆ obj_namei_cb_launch()

static void obj_namei_cb_launch ( struct m0_op_common oc)
static

'launch entry' on the vtable for obj namespace manipulation. This client callback gets invoked when launching a create/delete object operation.

Parameters
ocoperation being launched. Note the operation is of type m0_op_common although it has to be allocated as a m0_op_obj.

Definition at line 219 of file obj.c.

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

◆ obj_namei_op_init()

static int obj_namei_op_init ( struct m0_entity entity,
struct m0_op op 
)
static

Initialises a m0_obj namespace operation. The operation is intended to manage in the backend the object the provided entity is associated to.

Parameters
entityin-memory representation of the object's entity.
opoperation being set. The operation must have been allocated as a m0_op_obj.
Returns
0 if the function completes successfully or an error code otherwise.

Definition at line 462 of file obj.c.

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

◆ obj_op_obj_init()

static int obj_op_obj_init ( struct m0_op_obj oo)
static

Initialises a m0_op_obj (i.e. an operation on an object).

Parameters
ooobject operation to be initialised.
Returns
0 if success or an error code otherwise.

Get the object's pool version and optimal layout id.
TODO: hash the fid to chose a locality

Definition at line 592 of file obj.c.

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

◆ obj_op_obj_invariant()

static bool obj_op_obj_invariant ( struct m0_op_obj oo)
static

Checks an object operation is not malformed or corrupted.

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

Definition at line 95 of file obj.c.

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

◆ obj_op_prepare()

static int obj_op_prepare ( struct m0_entity entity,
struct m0_op **  op,
enum m0_entity_opcode  opcode 
)
static

Prepares a client operation to be executed on an object. Does all the generic stuff common to every operation on objects. Also allocates the operation if it has not been pre-allocated.

Parameters
entityEntity of the obj the operation is targeted to.
[out]opOperation to be prepared. The operation might have been pre-allocated. Otherwise the function allocates extra memory.
opcodeSpecific operation code.
Returns
0 if the operation completes successfully or an error code otherwise.

Definition at line 665 of file obj.c.

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

◆ obj_optimal_lid_set()

static void obj_optimal_lid_set ( struct m0_obj obj,
struct m0_layout_domain ldom 
)
static

Finds optimal layout id according to the object's size and sets it in m0_obj::ob_attr::oa_layout_id if it is not already set.

Definition at line 568 of file obj.c.

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