95 return obj->ob_entity.en_sm.sm_state;
130 uint32_t block_count, uint32_t block_size,
131 uint64_t *last_index)
135 for (
i = 0;
i < block_count; ++
i) {
138 *last_index += block_size;
141 attr->ov_vec.v_count[
i] = 0;
148 uint32_t block_count, uint32_t block_size,
149 uint64_t *last_index)
156 block_size, last_index);
179 fprintf(stderr,
"config parameters not initialized.\n");
203 if (strchr(idstr,
':') ==
NULL) {
210 fprintf(stderr,
"can't m0_fid_sscanf() %s, rc:%d", idstr,
rc);
273 for (
i = 0;
i < nr_blocks; ++
i) {
275 if (
rc != 1 || feof(
fp))
354 uint32_t block_count, uint64_t update_offset,
355 int blks_per_io,
bool take_locks,
bool update_mode)
370 fp = fopen(
src,
"r");
394 last_index = update_offset;
396 if (blks_per_io == 0)
403 while (block_count > 0) {
404 bcount = (block_count > blks_per_io)?
405 blks_per_io:block_count;
406 if (bcount < blks_per_io) {
414 block_size, &last_index);
423 fprintf(stderr,
"Writing to object failed!\n");
426 block_count -= bcount;
468 uint32_t block_size, uint32_t block_count,
469 uint64_t
offset,
int blks_per_io,
bool take_locks,
475 uint64_t last_index = 0;
513 obj.ob_attr.oa_pver = *read_pver;
524 if (blks_per_io == 0)
529 while (block_count > 0) {
531 bcount = (block_count > blks_per_io) ?
532 blks_per_io : block_count;
533 if (bcount < blks_per_io) {
541 block_size, &last_index);
545 fprintf(stderr,
"Reading from object failed!\n");
550 for (
i = 0;
i < bcount; ++
i) {
554 if (bytes_read != bcount * block_size) {
556 fprintf(stderr,
"Writing to destination " 562 for (
i = 0;
i < bcount; ++
i) {
567 block_count -= bcount;
609 uint32_t trunc_count, uint32_t trunc_len,
int blks_per_io,
638 goto open_entity_error;
640 if (blks_per_io == 0)
645 goto open_entity_error;
647 last_index = trunc_count * block_size;
648 while (trunc_len > 0) {
649 bcount = (trunc_len > blks_per_io) ?
650 blks_per_io : trunc_len;
652 if (bcount < blks_per_io) {
656 goto open_entity_error;
658 for (
i = 0;
i < bcount; ++
i) {
661 last_index += block_size;
665 fprintf(stderr,
"Truncate failed!\n");
710 goto open_entity_error;
743 uint32_t block_size, uint32_t block_count)
780 while (block_count > 0) {
784 block_size, &last_index);
795 fprintf(stderr,
"Writing to object failed!\n");
800 block_count -= bcount;
816 uint32_t block_size, uint32_t block_count)
821 uint64_t last_index = 0;
832 block_size, &last_index);
880 for (
i = 0;
i < block_count; ++
i) {
885 if (
rc != block_count) {
891 for (
i = 0;
i < block_count; ++
i) {
919 void (*utility_usage) (FILE*,
char*))
921 int option_index = 0;
928 params->cup_take_locks =
false;
929 params->cup_update_mode =
false;
932 conf->mc_is_read_verify =
false;
945 static struct option l_opts[] = {
946 {
"local", required_argument,
NULL,
'l'},
947 {
"ha", required_argument,
NULL,
'H'},
948 {
"profile", required_argument,
NULL,
'p'},
949 {
"process", required_argument,
NULL,
'P'},
950 {
"object", required_argument,
NULL,
'o'},
951 {
"block-size", required_argument,
NULL,
's'},
952 {
"block-count", required_argument,
NULL,
'c'},
953 {
"trunc-len", required_argument,
NULL,
't'},
954 {
"layout-id", required_argument,
NULL,
'L'},
955 {
"pver", required_argument,
NULL,
'v'},
956 {
"n_obj", required_argument,
NULL,
'n'},
957 {
"msg_size", required_argument,
NULL,
'S'},
958 {
"min_queue", required_argument,
NULL,
'q'},
959 {
"blks-per-io", required_argument,
NULL,
'b'},
960 {
"offset", required_argument,
NULL,
'O'},
961 {
"update_mode", no_argument,
NULL,
'u'},
962 {
"enable-locks", no_argument,
NULL,
'e'},
963 {
"read-verify", no_argument,
NULL,
'r'},
964 {
"help", no_argument,
NULL,
'h'},
965 {
"no-hole", no_argument,
NULL,
'N'},
968 while ((
c = getopt_long(argc, argv,
":l:H:p:P:o:s:c:t:L:v:n:S:q:b:O:uerhN",
969 l_opts, &option_index)) != -1)
982 utility_usage(stderr, basename(argv[0]));
986 utility_usage(stderr, basename(argv[0]));
991 &
params->cup_block_size) ==
995 fprintf(stderr,
"Invalid value for -%c." 997 "should be multiple of " 998 "4k and in the range of" 1000 utility_usage(stderr,
1004 utility_usage(stderr, basename(argv[0]));
1006 case 'b':
if ((
params->cup_blks_per_io = atoi(
optarg)) < 0)
1008 fprintf(stderr,
"Invalid value " 1010 "Blocks per io should " 1012 utility_usage(stderr,
1018 &
params->cup_block_count) ==
1020 if (
params->cup_block_count < 0) {
1021 fprintf(stderr,
"Invalid value " 1022 "%lu for -%c. Block " 1023 "count should be > 0\n",
1026 utility_usage(stderr,
1033 utility_usage(stderr, basename(argv[0]));
1036 &
params->cup_trunc_len) ==
1038 if (
params->cup_trunc_len <= 0) {
1039 fprintf(stderr,
"Invalid value " 1040 "%lu for -%c. Truncate " 1045 utility_usage(stderr,
1052 utility_usage(stderr, basename(argv[0]));
1055 if (
conf->mc_layout_id <= 0 ||
1056 conf->mc_layout_id >= 15) {
1057 fprintf(stderr,
"Invalid layout id" 1059 "range: [1-14]\n",
c);
1060 utility_usage(stderr,
1066 &
params->cup_pver) < 0) {
1067 utility_usage(stderr, basename(argv[0]));
1073 case 'e':
params->cup_take_locks =
true;
1082 fprintf(stderr,
"Invalid value for " 1083 "-%c. offset should be " 1084 "multiple of 4k\n",
c);
1085 utility_usage(stderr,
1089 utility_usage(stderr, basename(argv[0]));
1091 case 'r':
conf->mc_is_read_verify =
true;
1093 case 'S': temp = atoi(
optarg);
1094 conf->mc_max_rpc_msg_size = temp;
1096 case 'q': temp = atoi(
optarg);
1097 conf->mc_tm_recv_queue_min_len = temp;
1099 case 'u':
params->cup_update_mode =
true;
1101 case 'h': utility_usage(stderr, basename(argv[0]));
1105 case '?': fprintf(stderr,
"Unsupported option '%c'\n",
1107 utility_usage(stderr, basename(argv[0]));
1109 case ':': fprintf(stderr,
"No argument given for '%c'\n",
1111 utility_usage(stderr, basename(argv[0]));
1113 default: fprintf(stderr,
"Unsupported option '%c'\n",
c);
1116 conf->mc_is_oostore =
true;
M0_INTERNAL void m0_chan_wait(struct m0_clink *link)
void m0_entity_fini(struct m0_entity *entity)
M0_INTERNAL int m0_indexvec_alloc(struct m0_indexvec *ivec, uint32_t len)
void m0_obj_lock_put(struct m0_rm_lock_req *req)
int const char const void size_t int flags
static void cleanup_vecs(struct m0_bufvec *data, struct m0_bufvec *attr, struct m0_indexvec *ext)
M0_INTERNAL void m0_clink_init(struct m0_clink *link, m0_chan_cb_t cb)
const struct m0_obj_lock_ops lock_enabled_ops
M0_INTERNAL bool entity_id_is_valid(const struct m0_uint128 *id)
static int open_entity(struct m0_entity *entity)
const m0_time_t M0_TIME_NEVER
void m0_op_fini(struct m0_op *op)
static struct io_request req
static int punch_data_from_object(struct m0_obj *obj, struct m0_indexvec *ext)
int m0_obj_read_lock_get(struct m0_obj *obj, struct m0_rm_lock_req *req, struct m0_clink *clink)
#define M0_LOG(level,...)
struct m0_container container
static int alloc_vecs(struct m0_indexvec *ext, struct m0_bufvec *data, struct m0_bufvec *attr, uint32_t block_count, uint32_t block_size)
void(* olo_lock_fini)(struct m0_obj *obj)
int m0_obj_id_sscanf(char *idstr, struct m0_uint128 *obj_id)
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)
int m0_obj_write_lock_get_sync(struct m0_obj *obj, struct m0_rm_lock_req *req)
int32_t m0_rc(const struct m0_op *op)
void m0_client_fini(struct m0_client *m0c, bool fini_m0)
void(* olo_lock_put)(struct m0_rm_lock_req *req)
int m0_obj_lock_init(struct m0_obj *obj)
int m0_obj_write_lock_get(struct m0_obj *obj, struct m0_rm_lock_req *req, struct m0_clink *clink)
uint64_t m0_client_layout_id(const struct m0_client *instance)
static bool bsize_valid(uint64_t blk_size)
M0_INTERNAL void m0_indexvec_free(struct m0_indexvec *ivec)
M0_INTERNAL int m0_pageshift_get(void)
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 void prepare_ext_vecs(struct m0_indexvec *ext, struct m0_bufvec *attr, uint32_t block_count, uint32_t block_size, uint64_t *last_index)
int m0_client_init(struct m0_client **m0c, struct m0_config *conf, bool init_m0)
const struct m0_uint128 M0_UBER_REALM
void m0_obj_lock_fini(struct m0_obj *obj)
M0_INTERNAL bool m0_fid_is_set(const struct m0_fid *fid)
const struct m0_uint128 M0_ID_APP
int m0_bufvec_alloc_aligned(struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size, unsigned shift)
M0_INTERNAL int m0_bufvec_alloc(struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size)
int32_t m0_op_wait(struct m0_op *op, uint64_t bits, m0_time_t to)
static int noop_lock_get(struct m0_obj *obj, struct m0_rm_lock_req *req, struct m0_clink *clink)
struct m0_addb_ctx m0_addb_ctx
int m0_obj_op(struct m0_obj *obj, enum m0_obj_opcode opcode, struct m0_indexvec *ext, struct m0_bufvec *data, struct m0_bufvec *attr, uint64_t mask, uint32_t flags, struct m0_op **op)
M0_INTERNAL struct m0_obj * m0__obj_entity(struct m0_entity *entity)
M0_INTERNAL void m0_bufvec_free(struct m0_bufvec *bufvec)
int(* olo_write_lock_get)(struct m0_obj *obj, struct m0_rm_lock_req *req, struct m0_clink *clink)
int(* olo_read_lock_get_sync)(struct m0_obj *obj, struct m0_rm_lock_req *req)
int m0_obj_read_lock_get_sync(struct m0_obj *obj, struct m0_rm_lock_req *req)
return M0_ERR(-EOPNOTSUPP)
int m0_write_cc(struct m0_container *container, char **src, struct m0_uint128 id, int *index, uint32_t block_size, uint32_t block_count)
#define M0_AMB(obj, ptr, field)
static void attr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
struct m0_entity re_entity
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 *))
int touch(struct m0_container *container, struct m0_uint128 id, bool take_locks)
int client_init(struct m0_config *config, struct m0_container *container, struct m0_client **instance)
static struct m0_addb2_callback c
static int create_object(struct m0_entity *entity)
void m0_op_launch(struct m0_op **op, uint32_t nr)
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 struct m0_idx_dix_config dix_conf
static m0_bindex_t offset
void client_fini(struct m0_client *instance)
static struct m0_clink clink[RDWR_REQUEST_MAX]
M0_INTERNAL int m0_fid_sscanf(const char *s, struct m0_fid *fid)
int(* olo_lock_init)(struct m0_obj *obj)
struct m0_op_common oo_oc
static void noop_lock_put(struct m0_rm_lock_req *req)
int m0_entity_create(struct m0_fid *pool, struct m0_entity *entity, struct m0_op **op)
static int noop_lock_get_sync(struct m0_obj *obj, struct m0_rm_lock_req *req)
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 noop_lock_fini(struct m0_obj *obj)
struct m0_entity * op_entity
M0_INTERNAL int m0_bcount_get(const char *arg, m0_bcount_t *out)
int(* olo_write_lock_get_sync)(struct m0_obj *obj, struct m0_rm_lock_req *req)
static int noop_lock_init(struct m0_obj *obj)
M0_INTERNAL void m0_clink_fini(struct m0_clink *link)
void m0_obj_init(struct m0_obj *obj, struct m0_realm *parent, const struct m0_uint128 *id, uint64_t layout_id)
static struct m0 instance
int m0_entity_delete(struct m0_entity *entity, struct m0_op **op)
void m0_container_init(struct m0_container *con, struct m0_realm *parent, const struct m0_uint128 *id, struct m0_client *instance)
struct m0_client * re_instance
void m0_op_free(struct m0_op *op)
int m0_entity_open(struct m0_entity *entity, struct m0_op **op)
static uint32_t entity_sm_state(struct m0_obj *obj)
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)
int m0_unlink(struct m0_container *container, struct m0_uint128 id, bool take_locks)
struct m0_pdclust_src_addr src
static int write_data_to_object(struct m0_obj *obj, struct m0_indexvec *ext, struct m0_bufvec *data, struct m0_bufvec *attr)
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)
static int read_data_from_file(FILE *fp, struct m0_bufvec *data)
const struct m0_obj_lock_ops lock_disabled_ops