35 #include "libdemo_xc.h" 48 else if (!strcmp(op_name,
"ping"))
50 else if (!strcmp(op_name,
"min"))
52 else if (!strcmp(op_name,
"max"))
68 ERR(
"at least 1 segment is required\n");
102 if (greeting ==
NULL)
142 ERR(
"failed to allocate %d of memory for result\n", len);
150 memcpy(
buf,
x->mr_rbuf.b_addr,
x->mr_rbuf.b_nob);
151 buf[
x->mr_rbuf.b_nob] =
'\0';
156 rc = sscanf(
buf,
"%lf%n", &val1, &len);
158 ERR(
"failed to read the resulting xr-value\n");
166 DBG2(
"buf=%s val1=%lf\n",
buf, val1);
174 rc = sscanf(
buf + len,
"%lf", &val2);
176 DBG2(
"val2=%lf\n", val2);
191 else if (y->
mr_val == val1)
193 else if (y->
mr_val == val2)
224 buf =
res->mr_lbuf.b_addr;
226 buf =
res->mr_rbuf.b_addr;
228 if (sscanf(
buf,
"%lf", &
val) < 1) {
229 ERR(
"failed to parse egde value=%s\n",
buf);
235 if (
res->mr_nr == 1) {
266 ERR(
"failed to parse result: rc=%d\n",
rc);
286 if (last_unit && prev !=
NULL) {
287 printf(
"idx=%lu val=%lf\n", prev->
mr_idx, prev->
mr_val);
306 printf (
"Hello-%s @%s\n", (
char*)result->
b_addr, (
char*)
out);
320 Usage: %s OPTIONS COMP OBJ_ID LEN\n\ 322 Supported COMPutations: ping, min, max\n\ 324 OBJ_ID is two uint64 numbers in hi:lo format (dec or hex)\n\ 325 LEN is the length of object (in KiB)\n\ 327 Motr-related mandatory options:\n\ 328 -e <addr> endpoint address\n\ 329 -x <addr> ha-agent (hax) endpoint address\n\ 330 -f <fid> process fid\n\ 331 -p <fid> profile fid\n\ 333 Other non-mandatory options:\n\ 334 -v increase verbosity (-vv to increase even more)\n\ 353 res = sscanf(
s,
"%lli:%lli", &
hi, &lo);
357 }
else if (
res == 2) {
373 static void *out_args =
NULL;
374 const char *conn_addr =
NULL;
381 ERR(
"request allocation failed\n");
386 ERR(
"failed to get plop: rc=%d\n",
rc);
402 DBG(
"req=%d goff=%lu segs=%d\n", reqs_nr, iopl->
iop_goff,
408 ERR(
"input preparation failed: %d\n",
rc);
417 ERR(
"request preparation failed: %d\n",
rc);
424 ERR(
"error from %s received: rc=%d\n",
432 while (reqs_nr-- > 0)
437 iopl =
M0_AMB(iopl,
req->cir_plop, iop_base);
439 if (
rc == 0 &&
req->cir_rc == 0) {
441 out_args = (
void*)conn_addr;
469 int main(
int argc,
char **argv)
489 prog = basename(strdup(argv[0]));
491 while ((opt = getopt(argc, argv,
":vhe:x:f:p:")) != -1) {
520 ERR(
"mandatory parameter is missing\n");
527 if (op_type == -EINVAL)
531 len = atoll(argv[
optind + 2]);
533 ERR(
"object length should be at least 4K\n");
542 fprintf(stderr,
"isc_init() failed: %d\n",
rc);
546 m0_xc_iscservice_demo_libdemo_init();
551 ERR(
"failed to open object: rc=%d\n",
rc);
557 ERR(
"cannot figure out bs to use\n");
562 for (;
rc == 0 && len > 0; len -= len < bs ? len : bs, off += bs) {
564 bs = (len + unit_sz - 1) / unit_sz * unit_sz;
565 units_nr = bs / unit_sz;
566 DBG(
"unit_sz=%d units=%d\n", unit_sz, units_nr);
570 ERR(
"failed to alloc_segs: rc=%d\n",
rc);
577 ERR(
"failed to create op: rc=%d\n",
rc);
583 ERR(
"failed to build access plan\n");
595 return rc != 0 ? 1 : 0;
M0_INTERNAL int m0_buf_copy_aligned(struct m0_buf *dst, const struct m0_buf *src, unsigned shift)
M0_INTERNAL void m0_layout_plop_done(struct m0_layout_plop *plop)
static void check_edge_val(struct mm_result *res, enum elm_order e, enum isc_comp_type type)
M0_INTERNAL int m0_layout_plan_get(struct m0_layout_plan *plan, uint64_t colour, struct m0_layout_plop **plop)
void isc_fid_get(const char *f_name, struct m0_fid *fid)
#define m0_list_teardown(head, pos, type, member)
const m0_time_t M0_TIME_NEVER
void m0_op_fini(struct m0_op *op)
static struct io_request req
void free_segs(struct m0_bufvec *data, struct m0_indexvec *ext, struct m0_bufvec *attr)
static struct m0_realm uber_realm
int32_t m0_rc(const struct m0_op *op)
int launch_comp(struct m0_layout_plan *plan, int op_type, bool last)
M0_INTERNAL void m0_buf_init(struct m0_buf *buf, void *data, uint32_t nob)
static struct mm_result * op_result(struct mm_result *x, struct mm_result *y, enum isc_comp_type op_type)
#define container_of(ptr, type, member)
void isc_req_fini(struct isc_req *req)
int read_id(const char *s, struct m0_uint128 *id)
struct m0_io_indexvec ist_ioiv
int32_t m0_op_wait(struct m0_op *op, uint64_t bits, m0_time_t to)
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 const char * m0_rpc_conn_addr(const struct m0_rpc_conn *conn)
int m0_obj_layout_id_to_unit_size(uint64_t layout_id)
int main(int argc, char **argv)
#define M0_AMB(obj, ptr, field)
static void attr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
static void set_idx(struct mm_result *res, enum elm_order e)
static int input_prepare(struct m0_buf *buf, struct m0_fid *comp_fid, struct m0_layout_io_plop *iop, uint32_t *reply_len, enum isc_comp_type type)
static void * output_process(struct m0_buf *result, bool last, void *out, enum isc_comp_type type)
uint64_t set_exts(struct m0_indexvec *ext, uint64_t off, uint64_t bsz)
static int op_type_parse(const char *op_name)
enum m0_layout_plop_type pl_type
void m0_op_launch(struct m0_op **op, uint32_t nr)
M0_INTERNAL int m0_layout_plop_start(struct m0_layout_plop *plop)
M0_INTERNAL int m0_xcode_obj_enc_to_buf(struct m0_xcode_obj *obj, void **buf, m0_bcount_t *len)
static void * minmax_output_prepare(struct m0_buf *result, bool last_unit, struct mm_result *prev, enum isc_comp_type type)
static void mm_result_free_xcode_bufs(struct mm_result *r)
M0_INTERNAL void m0_buf_free(struct m0_buf *buf)
M0_INTERNAL bool m0_list_is_empty(const struct m0_list *head)
struct m0_layout_plop iop_base
struct m0_rpc_session * iop_session
struct m0_indexvec iop_ext
static struct m0_client cinst
M0_INTERNAL void m0_layout_plan_fini(struct m0_layout_plan *plan)
static int minmax_input_prepare(struct m0_buf *out, struct m0_fid *comp_fid, struct m0_layout_io_plop *iop, uint32_t *reply_len, enum isc_comp_type type)
static int open_entity(struct m0_entity *entity)
M0_INTERNAL int m0_indexvec_mem2wire(struct m0_indexvec *mem_ivec, int max_frags_nr, uint32_t bshift, struct m0_io_indexvec *wire_ivec)
struct m0_semaphore isc_sem
#define M0_ALLOC_PTR(ptr)
int isc_init(struct m0_config *conf, struct m0_client **cinst)
static int ping_input_prepare(struct m0_buf *buf, struct m0_fid *comp_fid, uint32_t *reply_len, enum isc_comp_type type)
M0_INTERNAL int m0_xcode_obj_dec_from_buf(struct m0_xcode_obj *obj, void *buf, m0_bcount_t len)
void m0_obj_init(struct m0_obj *obj, struct m0_realm *parent, const struct m0_uint128 *id, uint64_t layout_id)
M0_INTERNAL struct m0_layout_plan * m0_layout_plan_build(struct m0_op *op)
uint64_t isc_m0gs(struct m0_obj *obj, struct m0_client *cinst)
int alloc_segs(struct m0_bufvec *data, struct m0_indexvec *ext, struct m0_bufvec *attr, uint64_t bsz, uint32_t cnt)
#define M0_XCODE_OBJ(type, ptr)
void isc_fini(struct m0_client *cinst)
M0_INTERNAL void m0_semaphore_down(struct m0_semaphore *semaphore)
void m0_op_free(struct m0_op *op)
int isc_req_prepare(struct isc_req *req, struct m0_buf *args, const struct m0_fid *comp_fid, struct m0_layout_io_plop *iop, uint32_t reply_len)
int m0_entity_open(struct m0_entity *entity, struct m0_op **op)
static struct m0_addb2_source * s
int isc_req_send(struct isc_req *req)
struct m0_rpc_conn * s_conn
static struct m0_addb2_frame_header last