Motr  M0
workload.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2017-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_M0CRATE_WORKLOAD_H__
26 #define __MOTR_M0CRATE_WORKLOAD_H__
27 
34 #include <sys/param.h> /* MAXPATHLEN */
35 #include "lib/memory.h"
37 
38 /* used for both file offsets and file sizes. */
39 
40 
41 /*
42  * Fundamental data-types.
43  */
44 
45 /*
46  * Workloads.
47  */
48 
49 enum {
52 };
53 
55  CWT_HPCS, /* HPCS type file creation workload */
56  CWT_CSUM, /* checksumming workload */
60 };
61 
62 
63 enum swab_type {
64  ST_NONE = 0,
65  ST_32 = 1,
66  ST_32W = 2,
67  ST_64 = 3,
68  ST_64W = 4,
70 };
71 
72 /* description of the whole workload */
73 struct workload {
75  const char *cw_name;
76  unsigned cw_ops;
77  unsigned cw_done;
78  unsigned cw_nr_thread;
79  unsigned cw_rstate;
83  char *cw_buf;
85  int cw_header;
86  int cw_oflag;
87  int cw_usage;
89  int cw_bound;
91  char *cw_fpattern; /* "/mnt/m0/dir%d/f%d.%d" */
92  unsigned cw_nr_dir;
93  short cw_read_frac;
94  struct timeval cw_rate;
95  pthread_mutex_t cw_lock;
96 
97  union {
98  void *cw_io;
99  void *cw_index;
100  struct cr_hpcs {
101  } cw_hpcs;
102  struct cr_csum {
104  struct csum_dev {
105  char *d_name;
106  char *d_csum_name;
107  int d_fd;
110  int c_async;
111  unsigned c_blocksize;
113  int c_csum;
115  int c_swab;
116  } cw_csum;
117 
118  } u;
119 };
120 
125 };
126 
127 /* description of a single task (thread) executing workload */
129  struct workload *wt_load;
130  unsigned wt_thread;
131  pthread_t wt_pid;
133  unsigned wt_ops;
134  union {
135  struct task_hpcs {
136  struct timeval th_open;
137  struct timeval th_write;
138  int th_bind;
139  } wt_hpcs;
140  struct task_csum {
141  struct aiocb *tc_cb;
142  struct aiocb **tc_rag;
143  char *tc_csum_buf;
144  char *tc_buf;
145  } wt_csum;
146  void *m0_task;
147  // void *index_task;
148  } u;
149 };
150 
151 /* particular operation from a workload */
152 struct workload_op {
155  union {
156  struct op_hpcs {
157  unsigned oh_dirno;
158  unsigned oh_opno;
160  } wo_hpcs;
161  struct op_csum {
164  } wo_csum;
165  } u;
166 };
167 
169  int (*wto_init)(struct workload *w);
170  int (*wto_fini)(struct workload *w);
171 
172  void (*wto_run)(struct workload *w, struct workload_task *task);
173  void (*wto_op_get)(struct workload *w, struct workload_op *op);
174  void (*wto_op_run)(struct workload *w, struct workload_task *task, const struct workload_op *op);
175  int (*wto_parse)(struct workload *w, char ch, const char *optarg);
176  void (*wto_check)(struct workload *w);
177 };
178 int workload_init(struct workload *w, enum cr_workload_type wtype);
179 void workload_start(struct workload *w, struct workload_task *task);
180 void workload_join(struct workload *w, struct workload_task *task);
181 
183 #endif /* __MOTR_M0CRATE_WORKLOAD_H__ */
184 
185 /*
186  * Local variables:
187  * c-indentation-style: "K&R"
188  * c-basic-offset: 8
189  * tab-width: 8
190  * fill-column: 80
191  * scroll-step: 1
192  * End:
193  */
194 /*
195  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
196  */
struct workload_op::@330::op_csum wo_csum
unsigned oh_dirno
Definition: workload.h:157
void * cw_index
Definition: workload.h:99
struct aiocb * tc_cb
Definition: workload.h:141
#define MAXPATHLEN
Definition: stob.h:41
const char * cw_name
Definition: workload.h:75
struct workload::@328::cr_csum cw_csum
csum_op_type
Definition: workload.h:121
Definition: workload.h:67
struct workload * wt_load
Definition: workload.h:129
bcnt_t wo_size
Definition: workload.h:153
pthread_t wt_pid
Definition: workload.h:131
bcnt_t cw_avg
Definition: workload.h:80
Definition: workload.h:65
struct workload::@328::cr_csum::csum_dev c_dev[CR_CSUM_DEV_MAX]
unsigned wt_thread
Definition: workload.h:130
char * optarg
short cw_read_frac
Definition: workload.h:93
Definition: workload.h:69
unsigned cw_rstate
Definition: workload.h:79
int cw_directio
Definition: workload.h:88
struct workload_task * wo_task
Definition: workload.h:154
char * cw_fpattern
Definition: workload.h:91
int cw_log_level
Definition: workload.h:90
void(* wto_op_run)(struct workload *w, struct workload_task *task, const struct workload_op *op)
Definition: workload.h:174
op
Definition: libdemo.c:64
unsigned oh_opno
Definition: workload.h:158
char * tc_csum_buf
Definition: workload.h:143
unsigned cw_ops
Definition: workload.h:76
union workload::@328 u
pthread_mutex_t cw_lock
Definition: workload.h:95
void * cw_io
Definition: workload.h:98
unsigned wt_ops
Definition: workload.h:133
bcnt_t c_dev_size
Definition: workload.h:112
int cw_progress
Definition: workload.h:84
bcnt_t cw_block
Definition: workload.h:82
int d_csum_fd
Definition: workload.h:108
union workload_task::@329 u
struct workload_task::@329::task_csum wt_csum
int cw_oflag
Definition: workload.h:86
union workload_op::@330 u
struct workload_task::@329::task_hpcs wt_hpcs
unsigned cw_nr_dir
Definition: workload.h:92
int c_csum
Definition: workload.h:113
char * d_csum_name
Definition: workload.h:106
struct workload_op::@330::op_hpcs wo_hpcs
char * cw_buf
Definition: workload.h:83
int cw_header
Definition: workload.h:85
struct timeval th_write
Definition: workload.h:137
int(* wto_init)(struct workload *w)
Definition: workload.h:169
int workload_init(struct workload *w, enum cr_workload_type wtype)
Definition: crate.c:216
unsigned long long bcnt_t
Definition: crate_utils.h:44
enum csum_op_type oc_type
Definition: workload.h:162
int cw_bound
Definition: workload.h:89
void(* wto_run)(struct workload *w, struct workload_task *task)
Definition: workload.h:172
char oh_fname[MAXPATHLEN]
Definition: workload.h:159
void(* wto_check)(struct workload *w)
Definition: workload.h:176
void * m0_task
Definition: workload.h:146
cr_workload_type
Definition: workload.h:54
int c_async
Definition: workload.h:110
unsigned cw_nr_thread
Definition: workload.h:78
void workload_start(struct workload *w, struct workload_task *task)
Definition: crate.c:340
void(* wto_op_get)(struct workload *w, struct workload_op *op)
Definition: workload.h:173
struct timeval th_open
Definition: workload.h:136
int(* wto_fini)(struct workload *w)
Definition: workload.h:170
bcnt_t cw_max
Definition: workload.h:81
char * tc_buf
Definition: workload.h:144
bcnt_t wt_total
Definition: workload.h:132
int d_fd
Definition: workload.h:107
int c_nr_devs
Definition: workload.h:103
unsigned c_blocksize
Definition: workload.h:111
struct aiocb ** tc_rag
Definition: workload.h:142
int(* wto_parse)(struct workload *w, char ch, const char *optarg)
Definition: workload.h:175
enum cr_workload_type cw_type
Definition: workload.h:74
int c_swab
Definition: workload.h:115
struct timeval cw_rate
Definition: workload.h:94
swab_type
Definition: workload.h:63
bcnt_t oc_offset
Definition: workload.h:163
unsigned cw_done
Definition: workload.h:77
char * d_name
Definition: workload.h:105
void workload_join(struct workload *w, struct workload_task *task)
Definition: crate.c:363
bcnt_t c_csum_size
Definition: workload.h:114
struct workload::@328::cr_hpcs cw_hpcs
int cw_usage
Definition: workload.h:87