Motr  M0
bulkio_common.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #pragma once
24 
25 #ifndef __MOTR_IOSERVICE_ST_COMMON_H__
26 #define __MOTR_IOSERVICE_ST_COMMON_H__
27 
28 #include "lib/list.h"
29 #include "motr/init.h"
30 #include "lib/memory.h"
31 #include "lib/misc.h"
32 #include "cob/cob.h" /* m0_cob_domain */
33 #include "ioservice/io_fops.h" /* m0_io_fop */
34 #include "rpc/rpc.h" /* m0_rpc_bulk, m0_rpc_bulk_buf */
35 #include "rpc/rpc_opcodes.h" /* M0_RPC_OPCODES */
36 #include "lib/thread.h" /* M0_THREAD_INIT */
37 #include "lib/misc.h" /* M0_SET_ARR0 */
38 
41  IO_SEGS_NR = 16,
42  IO_SEG_SIZE = 4096,
44  IO_FOPS_NR = 16,
51  IO_STR_LEN = 16,
58 };
59 #define IO_CLIENT_DBNAME "bulk_c_db"
60 #define IO_SERVER_DBFILE "bulkio_st.db"
61 #define IO_SERVER_LOGFILE "bulkio_st.log"
62 #define IO_SERVER_STOBFILE "bulk_st_stob"
63 
64 static const struct m0_fid CONF_PVER_FID = M0_FID_TINIT('v', 1, 24);
65 static const struct m0_fid CONF_PVER_FID1 = M0_FID_TINIT('v', 1, 25);
66 static const struct m0_fid CONF_PROFILE_FID = M0_FID_TINIT('p', 1, 0);
67 /* Structure containing data needed for UT. */
68 struct bulkio_params {
69  /* Fids of global files. */
71 
72  /* Tracks offsets for global fids. */
74 
75  /* In-memory fops for read IO. */
76  struct m0_io_fop **bp_rfops;
77 
78  /* In-memory fops for write IO. */
79  struct m0_io_fop **bp_wfops;
80 
83 
84  /* Read buffers to which data will be transferred. */
86 
87  /* Threads to post rpc items to rpc layer. */
89 
90  /*
91  * Standard buffers containing a data pattern.
92  * Primarily used for data verification in read and write IO.
93  */
94  char *bp_readbuf;
95  char *bp_writebuf;
96 
97  /* Structures used by client-side rpc code. */
100 
101  const char *bp_caddr;
102  char *bp_cdbname;
103  const char *bp_saddr;
104  char *bp_slogfile;
105 
108 
110 
114 
117 
118  uint32_t bp_seg_nr;
119 };
120 
121 /* A structure used to pass as argument to io threads. */
122 struct thrd_arg {
123  /* Index in fops array to be posted to rpc layer. */
124  int ta_index;
125  /* Type of fop to be sent (read/write). */
127  /* bulkio_params structure which contains common data. */
129 };
130 
131 /* Common APIs used by bulk client as well as UT code. */
132 int bulkio_client_start(struct bulkio_params *bp, const char *caddr,
133  const char *saddr);
134 
136 
137 int bulkio_server_start(struct bulkio_params *bp, const char *saddr);
138 
140 
141 void bulkio_params_init(struct bulkio_params *bp);
142 
143 void bulkio_params_fini(struct bulkio_params *bp);
144 
145 void bulkio_test(struct bulkio_params *bp, int fids_nr, int fops_nr,
146  int segs_nr);
147 
148 extern int m0_bufvec_alloc_aligned(struct m0_bufvec *bufvec, uint32_t num_segs,
149  m0_bcount_t seg_size, unsigned shift);
150 
158 int io_fsync_send_fop(struct m0_be_tx_remid *remid, struct thrd_arg *t);
159 void io_fops_rpc_submit(struct thrd_arg *t);
160 
161 void io_fops_destroy(struct bulkio_params *bp);
162 
163 void io_fops_create(struct bulkio_params *bp, enum M0_RPC_OPCODES op,
164  int fids_nr, int fops_nr, int segs_nr);
165 
167 #endif /* __MOTR_IOSERVICE_ST_COMMON_H__ */
static m0_bcount_t seg_size
Definition: net.c:118
struct m0_thread ** bp_threads
Definition: bulkio_common.h:88
struct m0_net_xprt * bp_xprt
M0_RPC_OPCODES
Definition: rpc_opcodes.h:41
int bulkio_client_start(struct bulkio_params *bp, const char *caddr, const char *saddr)
struct m0_rpc_server_ctx * bp_sctx
struct m0_fid bp_fids[IO_FIDS_NR]
Definition: bulkio_common.h:70
void io_fops_destroy(struct bulkio_params *bp)
static struct m0_rpc_client_ctx cctx
Definition: rconfc.c:69
struct m0_rm_resource_type bp_flock_rt
uint64_t m0_bcount_t
Definition: types.h:77
struct m0_be_tx_remid bp_remid
int m0_bufvec_alloc_aligned(struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size, unsigned shift)
Definition: vec.c:355
uint64_t bp_offsets[IO_FIDS_NR]
Definition: bulkio_common.h:73
op
Definition: libdemo.c:64
enum M0_RPC_OPCODES ta_op
void bulkio_params_fini(struct bulkio_params *bp)
static const struct m0_fid CONF_PVER_FID1
Definition: bulkio_common.h:65
char * bp_readbuf
Definition: bulkio_common.h:94
#define M0_FID_TINIT(type, container, key)
Definition: fid.h:90
static void attr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:949
struct m0_rpc_client_ctx * bp_cctx
struct m0_rm_domain bp_rdom
char * bp_writebuf
Definition: bulkio_common.h:95
void bulkio_test(struct bulkio_params *bp, int fids_nr, int fops_nr, int segs_nr)
void bulkio_params_init(struct bulkio_params *bp)
static struct m0_thread t[8]
Definition: service_ut.c:1230
IO_UT_VALUES
Definition: bulkio_common.h:39
void io_fops_rpc_submit(struct thrd_arg *t)
struct m0_cob_domain bp_ccbdom
Definition: bulkio_common.h:98
static struct m0_rpc_server_ctx sctx
Definition: console.c:88
struct bulkio_params * ta_bp
void io_fops_create(struct bulkio_params *bp, enum M0_RPC_OPCODES op, int fids_nr, int fops_nr, int segs_nr)
int bulkio_server_start(struct bulkio_params *bp, const char *saddr)
Definition: bulkio_common.c:82
static const struct m0_fid CONF_PROFILE_FID
Definition: bulkio_common.h:66
struct m0_net_buffer ** bp_iobuf
Definition: bulkio_common.h:85
static const struct m0_fid CONF_PVER_FID
Definition: bulkio_common.h:64
void bulkio_client_stop(struct m0_rpc_client_ctx *cctx)
Definition: fid.h:38
struct m0_io_fop ** bp_rfops
Definition: bulkio_common.h:76
struct m0_net_domain bp_cnetdom
Definition: bulkio_common.h:99
void bulkio_server_stop(struct m0_rpc_server_ctx *sctx)
static struct bulkio_params * bp
Definition: bulkio_ut.c:44
void cob_attr_default_fill(struct m0_cob_attr *attr)
Definition: file.h:81
const char * bp_saddr
const char * bp_caddr
char * bp_slogfile
struct m0_io_fop ** bp_wfops
Definition: bulkio_common.h:79
int io_fsync_send_fop(struct m0_be_tx_remid *remid, struct thrd_arg *t)
Definition: vec.h:145
struct m0_file bp_file[IO_FIDS_NR]
uint32_t bp_seg_nr