Motr  M0
helper.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/time.h>
#include <getopt.h>
#include "lib/trace.h"
#include "conf/obj.h"
#include "fid/fid.h"
#include "motr/client.h"
#include "motr/client_internal.h"
#include "motr/idx.h"
#include "motr/st/utils/helper.h"
#include "lib/getopts.h"
Include dependency graph for helper.c:

Go to the source code of this file.

Functions

static int noop_lock_init (struct m0_obj *obj)
 
static void noop_lock_fini (struct m0_obj *obj)
 
static int noop_lock_get (struct m0_obj *obj, struct m0_rm_lock_req *req, struct m0_clink *clink)
 
static int noop_lock_get_sync (struct m0_obj *obj, struct m0_rm_lock_req *req)
 
static void noop_lock_put (struct m0_rm_lock_req *req)
 
static uint32_t entity_sm_state (struct m0_obj *obj)
 
static int alloc_vecs (struct m0_indexvec *ext, struct m0_bufvec *data, struct m0_bufvec *attr, uint32_t block_count, uint32_t block_size)
 
static void prepare_ext_vecs (struct m0_indexvec *ext, struct m0_bufvec *attr, uint32_t block_count, uint32_t block_size, uint64_t *last_index)
 
static int alloc_prepare_vecs (struct m0_indexvec *ext, struct m0_bufvec *data, struct m0_bufvec *attr, uint32_t block_count, uint32_t block_size, uint64_t *last_index)
 
static void cleanup_vecs (struct m0_bufvec *data, struct m0_bufvec *attr, struct m0_indexvec *ext)
 
int client_init (struct m0_config *config, struct m0_container *container, struct m0_client **instance)
 
void client_fini (struct m0_client *instance)
 
int m0_obj_id_sscanf (char *idstr, struct m0_uint128 *obj_id)
 
static int open_entity (struct m0_entity *entity)
 
static int create_object (struct m0_entity *entity)
 
static int read_data_from_file (FILE *fp, struct m0_bufvec *data)
 
static int write_data_to_object (struct m0_obj *obj, struct m0_indexvec *ext, struct m0_bufvec *data, struct m0_bufvec *attr)
 
int touch (struct m0_container *container, struct m0_uint128 id, bool take_locks)
 
int m0_write (struct m0_container *container, char *src, struct m0_uint128 id, uint32_t block_size, uint32_t block_count, uint64_t update_offset, int blks_per_io, bool take_locks, bool update_mode)
 
static int read_data_from_object (struct m0_obj *obj, struct m0_indexvec *ext, struct m0_bufvec *data, struct m0_bufvec *attr, uint32_t flags)
 
int m0_read (struct m0_container *container, struct m0_uint128 id, char *dest, uint32_t block_size, uint32_t block_count, uint64_t offset, int blks_per_io, bool take_locks, uint32_t flags, struct m0_fid *read_pver)
 
static int punch_data_from_object (struct m0_obj *obj, struct m0_indexvec *ext)
 
int m0_truncate (struct m0_container *container, struct m0_uint128 id, uint32_t block_size, uint32_t trunc_count, uint32_t trunc_len, int blks_per_io, bool take_locks)
 
int m0_unlink (struct m0_container *container, struct m0_uint128 id, bool take_locks)
 
int m0_write_cc (struct m0_container *container, char **src, struct m0_uint128 id, int *index, uint32_t block_size, uint32_t block_count)
 
int m0_read_cc (struct m0_container *container, struct m0_uint128 id, char **dest, int *index, uint32_t block_size, uint32_t block_count)
 
static bool bsize_valid (uint64_t blk_size)
 
int m0_utility_args_init (int argc, char **argv, struct m0_utility_param *params, struct m0_idx_dix_config *dix_conf, struct m0_config *conf, void(*utility_usage)(FILE *, char *))
 

Variables

struct m0_addb_ctx m0_addb_ctx
 
const struct m0_obj_lock_ops lock_enabled_ops
 
const struct m0_obj_lock_ops lock_disabled_ops
 

Function Documentation

◆ alloc_prepare_vecs()

static int alloc_prepare_vecs ( struct m0_indexvec ext,
struct m0_bufvec data,
struct m0_bufvec attr,
uint32_t  block_count,
uint32_t  block_size,
uint64_t *  last_index 
)
static

Definition at line 145 of file helper.c.

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

◆ alloc_vecs()

static int alloc_vecs ( struct m0_indexvec ext,
struct m0_bufvec data,
struct m0_bufvec attr,
uint32_t  block_count,
uint32_t  block_size 
)
static

Definition at line 98 of file helper.c.

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

◆ bsize_valid()

static bool bsize_valid ( uint64_t  blk_size)
static

Definition at line 909 of file helper.c.

Here is the caller graph for this function:

◆ cleanup_vecs()

static void cleanup_vecs ( struct m0_bufvec data,
struct m0_bufvec attr,
struct m0_indexvec ext 
)
static

Definition at line 161 of file helper.c.

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

◆ client_fini()

void client_fini ( struct m0_client instance)

Definition at line 194 of file helper.c.

Here is the call graph for this function:

◆ client_init()

int client_init ( struct m0_config config,
struct m0_container container,
struct m0_client **  instance 
)

Definition at line 170 of file helper.c.

Here is the call graph for this function:

◆ create_object()

static int create_object ( struct m0_entity entity)
static

Definition at line 236 of file helper.c.

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

◆ entity_sm_state()

static uint32_t entity_sm_state ( struct m0_obj obj)
inlinestatic

Definition at line 93 of file helper.c.

Here is the caller graph for this function:

◆ m0_obj_id_sscanf()

int m0_obj_id_sscanf ( char *  idstr,
struct m0_uint128 obj_id 
)

Definition at line 199 of file helper.c.

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

◆ m0_read()

int m0_read ( struct m0_container container,
struct m0_uint128  id,
char *  dest,
uint32_t  block_size,
uint32_t  block_count,
uint64_t  offset,
int  blks_per_io,
bool  take_locks,
uint32_t  flags,
struct m0_fid read_pver 
)

Definition at line 466 of file helper.c.

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

◆ m0_read_cc()

int m0_read_cc ( struct m0_container container,
struct m0_uint128  id,
char **  dest,
int *  index,
uint32_t  block_size,
uint32_t  block_count 
)

Definition at line 814 of file helper.c.

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

◆ m0_truncate()

int m0_truncate ( struct m0_container container,
struct m0_uint128  id,
uint32_t  block_size,
uint32_t  trunc_count,
uint32_t  trunc_len,
int  blks_per_io,
bool  take_locks 
)

Definition at line 607 of file helper.c.

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

◆ m0_unlink()

int m0_unlink ( struct m0_container container,
struct m0_uint128  id,
bool  take_locks 
)

Definition at line 683 of file helper.c.

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

◆ m0_utility_args_init()

int m0_utility_args_init ( int  argc,
char **  argv,
struct m0_utility_param params,
struct m0_idx_dix_config dix_conf,
struct m0_config conf,
void(*)(FILE *, char *)  utility_usage 
)

Definition at line 915 of file helper.c.

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

◆ m0_write()

int m0_write ( struct m0_container container,
char *  src,
struct m0_uint128  id,
uint32_t  block_size,
uint32_t  block_count,
uint64_t  update_offset,
int  blks_per_io,
bool  take_locks,
bool  update_mode 
)

Definition at line 352 of file helper.c.

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

◆ m0_write_cc()

int m0_write_cc ( struct m0_container container,
char **  src,
struct m0_uint128  id,
int *  index,
uint32_t  block_size,
uint32_t  block_count 
)

Definition at line 741 of file helper.c.

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

◆ noop_lock_fini()

static void noop_lock_fini ( struct m0_obj obj)
static

Definition at line 48 of file helper.c.

◆ noop_lock_get()

static int noop_lock_get ( struct m0_obj obj,
struct m0_rm_lock_req req,
struct m0_clink clink 
)
static

Definition at line 53 of file helper.c.

◆ noop_lock_get_sync()

static int noop_lock_get_sync ( struct m0_obj obj,
struct m0_rm_lock_req req 
)
static

Definition at line 61 of file helper.c.

◆ noop_lock_init()

static int noop_lock_init ( struct m0_obj obj)
static

Definition at line 42 of file helper.c.

◆ noop_lock_put()

static void noop_lock_put ( struct m0_rm_lock_req req)
static

Definition at line 68 of file helper.c.

◆ open_entity()

static int open_entity ( struct m0_entity entity)
static

Definition at line 215 of file helper.c.

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

◆ prepare_ext_vecs()

static void prepare_ext_vecs ( struct m0_indexvec ext,
struct m0_bufvec attr,
uint32_t  block_count,
uint32_t  block_size,
uint64_t *  last_index 
)
static

Definition at line 128 of file helper.c.

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

◆ punch_data_from_object()

static int punch_data_from_object ( struct m0_obj obj,
struct m0_indexvec ext 
)
static

Definition at line 584 of file helper.c.

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

◆ read_data_from_file()

static int read_data_from_file ( FILE *  fp,
struct m0_bufvec data 
)
static

Definition at line 266 of file helper.c.

Here is the caller graph for this function:

◆ read_data_from_object()

static int read_data_from_object ( struct m0_obj obj,
struct m0_indexvec ext,
struct m0_bufvec data,
struct m0_bufvec attr,
uint32_t  flags 
)
static

Definition at line 440 of file helper.c.

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

◆ touch()

int touch ( struct m0_container container,
struct m0_uint128  id,
bool  take_locks 
)

Definition at line 310 of file helper.c.

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

◆ write_data_to_object()

static int write_data_to_object ( struct m0_obj obj,
struct m0_indexvec ext,
struct m0_bufvec data,
struct m0_bufvec attr 
)
static

Create write operation CKSUM_TODO: calculate cksum and pass in attr instead of NULL

Definition at line 282 of file helper.c.

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

Variable Documentation

◆ lock_disabled_ops

const struct m0_obj_lock_ops lock_disabled_ops
Initial value:
= {
.olo_lock_init = noop_lock_init,
.olo_lock_fini = noop_lock_fini,
.olo_write_lock_get = noop_lock_get,
.olo_write_lock_get_sync = noop_lock_get_sync,
.olo_read_lock_get = noop_lock_get,
.olo_read_lock_get_sync = noop_lock_get_sync,
.olo_lock_put = noop_lock_put
}
static int noop_lock_get(struct m0_obj *obj, struct m0_rm_lock_req *req, struct m0_clink *clink)
Definition: helper.c:53
static void noop_lock_put(struct m0_rm_lock_req *req)
Definition: helper.c:68
static int noop_lock_get_sync(struct m0_obj *obj, struct m0_rm_lock_req *req)
Definition: helper.c:61
static void noop_lock_fini(struct m0_obj *obj)
Definition: helper.c:48
static int noop_lock_init(struct m0_obj *obj)
Definition: helper.c:42

Definition at line 83 of file helper.c.

◆ lock_enabled_ops

const struct m0_obj_lock_ops lock_enabled_ops
Initial value:
= {
.olo_lock_init = m0_obj_lock_init,
.olo_lock_fini = m0_obj_lock_fini,
.olo_write_lock_get = m0_obj_write_lock_get,
.olo_write_lock_get_sync = m0_obj_write_lock_get_sync,
.olo_read_lock_get = m0_obj_read_lock_get,
.olo_read_lock_get_sync = m0_obj_read_lock_get_sync,
.olo_lock_put = m0_obj_lock_put
}
void m0_obj_lock_put(struct m0_rm_lock_req *req)
Definition: obj_lock.c:267
int m0_obj_read_lock_get(struct m0_obj *obj, struct m0_rm_lock_req *req, struct m0_clink *clink)
Definition: obj_lock.c:250
int m0_obj_write_lock_get_sync(struct m0_obj *obj, struct m0_rm_lock_req *req)
Definition: obj_lock.c:242
int m0_obj_lock_init(struct m0_obj *obj)
Definition: obj_lock.c:82
int m0_obj_write_lock_get(struct m0_obj *obj, struct m0_rm_lock_req *req, struct m0_clink *clink)
Definition: obj_lock.c:233
void m0_obj_lock_fini(struct m0_obj *obj)
Definition: obj_lock.c:144
int m0_obj_read_lock_get_sync(struct m0_obj *obj, struct m0_rm_lock_req *req)
Definition: obj_lock.c:259

Definition at line 73 of file helper.c.

◆ m0_addb_ctx

struct m0_addb_ctx m0_addb_ctx