Motr  M0
m0t1fs_test.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2020 Seagate Technology LLC and/or its Affiliates
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * For any questions about this software or licensing,
17  * please email opensource@seagate.com or cortx-questions@seagate.com.
18  *
19  */
20 
21 
22 #include "motr/init.h"
23 #include "lib/thread.h" /* LAMBDA */
24 #include "lib/getopts.h"
25 
26 #include "desim/sim.h"
27 #include "desim/storage.h"
28 #include "desim/chs.h"
29 #include "desim/net.h"
30 #include "desim/m0t1fs.h"
31 #include "desim/elevator.h"
32 
38 static struct net_conf net = {
39  .nc_frag_size = 4*1024,
40  .nc_rpc_size = 1024,
41  .nc_rpc_delay_min = 1000, /* microsecond */
42  .nc_rpc_delay_max = 5000,
43  .nc_frag_delay_min = 100,
44  .nc_frag_delay_max = 1000,
45  .nc_rate_min = 750000000,
46  .nc_rate_max = 1000000000, /* 1GB/sec QDR Infiniband */
47  .nc_nob_max = ~0UL,
48  .nc_msg_max = ~0UL,
49 };
50 
51 static struct net_srv srv0 = {
52  .ns_nr_threads = 64,
53  .ns_pre_bulk_min = 0,
54  .ns_pre_bulk_max = 1000,
55  .ns_file_size = 1024*1024
56 };
57 
58 static struct m0t1fs_conf m0t1fs = {
59  .ct_nr_clients = 0,
60  .ct_nr_threads = 0,
61  .ct_nr_servers = 0,
62  .ct_nr_devices = 0,
63  .ct_N = 8,
64  .ct_K = 2,
65  .ct_S = 2,
66  .ct_unitsize = 4*1024*1024,
67  .ct_client_step = 0,
68  .ct_thread_step = 0,
69  .ct_inflight_max = 8,
70  .ct_total = 1024*1024*1024,
71  .ct_delay_min = 0,
72  .ct_delay_max = 1000000, /* millisecond */
73  .ct_net = &net,
74  .ct_srv0 = &srv0
75 };
76 
77 static struct chs_conf ST31000640SS = { /* Barracuda ES.2 */
78  .cc_storage = {
79  .sc_sector_size = 512,
80  },
81  .cc_heads = 4*2, /* sginfo */
82  .cc_cylinders = 153352, /* sginfo */
83  .cc_track_skew = 160, /* sginfo */
84  .cc_cylinder_skew = 76, /* sginfo */
85  .cc_sectors_min = 1220, /* sginfo */
86  .cc_sectors_max = 1800, /* guess */
87  .cc_cyl_in_zone = 48080, /* sginfo */
88 
89  .cc_seek_avg = 8500000, /* data sheet */
90  .cc_seek_track_to_track = 800000, /* data sheet */
91  .cc_seek_full_stroke = 16000000, /* guess */
92  .cc_write_settle = 500000, /* guess */
93  .cc_head_switch = 500000, /* guess */
94  .cc_command_latency = 0, /* unknown */
95 
96  .cc_rps = 7200/60
97 };
98 
99 static void workload_init(struct sim *s, int argc, char **argv)
100 {
101  unsigned i;
102  unsigned j;
103 
104  net_init(&net);
105  m0t1fs_init(s, &m0t1fs);
107 
108  for (i = 0; i < m0t1fs.ct_nr_servers; ++i) {
109  for (j = 0; j < m0t1fs.ct_nr_devices; ++j) {
110  struct chs_dev *disc;
111 
112  disc = sim_alloc(sizeof *disc);
113  sim_name_set(&disc->cd_storage.sd_name, "%u:%u", i, j);
116  &disc->cd_storage);
117  }
118  }
119 }
120 
121 static void workload_fini(void)
122 {
123  unsigned i;
124  unsigned j;
125 
126  for (i = 0; i < m0t1fs.ct_nr_servers; ++i) {
127  for (j = 0; j < m0t1fs.ct_nr_devices; ++j) {
128  struct elevator *el;
129  struct chs_dev *disc;
130 
131  el = &m0t1fs.ct_srv[i].ns_el[j];
133  struct chs_dev, cd_storage);
134  elevator_fini(el);
136  }
137  }
140  net_fini(&net);
141 }
142 
143 int main(int argc, char **argv)
144 {
145  struct sim s;
146  int result;
147 
148  result = m0_init(NULL);
149  M0_ASSERT(result == 0);
150 
151  result = M0_GETOPTS(argv[0], argc, argv,
152  M0_HELPARG('h'),
153  M0_FORMATARG('c', "clients", "%u", &m0t1fs.ct_nr_clients),
154  M0_FORMATARG('s', "servers", "%u", &m0t1fs.ct_nr_servers),
155  M0_FORMATARG('S', "server threads", "%u", &srv0.ns_nr_threads),
156  M0_FORMATARG('d', "devices", "%u", &m0t1fs.ct_nr_devices),
157  M0_FORMATARG('t', "threads", "%u", &m0t1fs.ct_nr_threads),
158  M0_FORMATARG('C', "client step", "%u", &m0t1fs.ct_client_step),
159  M0_FORMATARG('T', "thread step", "%u", &m0t1fs.ct_thread_step),
160  M0_FORMATARG('N', "N", "%u", &m0t1fs.ct_N),
161  M0_FORMATARG('K', "K", "%u", &m0t1fs.ct_K),
162  M0_FORMATARG('S', "S", "%u", &m0t1fs.ct_S),
163  M0_FORMATARG('u', "unit size", "%lu", &m0t1fs.ct_unitsize),
164  M0_FORMATARG('n', "total", "%lu", &m0t1fs.ct_total),
165  M0_FORMATARG('f', "file size", "%llu", &srv0.ns_file_size),
166  M0_VOIDARG('v', "increase verbosity",
167  LAMBDA(void, (void){ sim_log_level++; } )));
168 
169  M0_ASSERT(result == 0);
170 
171  sim_init(&s);
172  workload_init(&s, argc, argv);
173  sim_run(&s);
174  cnt_dump_all();
175  workload_fini();
176  sim_log(&s, SLL_WARN, "%10.2f\n",
177  1000.0 * m0t1fs.ct_nr_clients *
178  m0t1fs.ct_nr_threads * m0t1fs.ct_total / s.ss_bolt);
179  sim_fini(&s);
180  m0_fini();
181  return 0;
182 }
183 
186 /*
187  * Local variables:
188  * c-indentation-style: "K&R"
189  * c-basic-offset: 8
190  * tab-width: 8
191  * fill-column: 80
192  * scroll-step: 1
193  * End:
194  */
unsigned long ct_client_step
Definition: m0t1fs.h:74
#define M0_GETOPTS(progname, argc, argv,...)
Definition: getopts.h:169
unsigned ct_nr_devices
Definition: m0t1fs.h:65
Definition: sim.h:152
unsigned ct_nr_clients
Definition: m0t1fs.h:62
M0_INTERNAL void sim_init(struct sim *state)
Definition: sim.c:106
static struct chs_conf ST31000640SS
Definition: m0t1fs_test.c:77
struct elevator * ns_el
Definition: net.h:65
#define NULL
Definition: misc.h:38
static struct net_srv srv0
Definition: m0t1fs_test.c:51
unsigned sc_sector_size
Definition: storage.h:39
struct chs_dev disc
Definition: net_test.c:96
uint32_t ct_K
Definition: m0t1fs.h:71
void m0_fini(void)
Definition: init.c:318
M0_INTERNAL void chs_dev_fini(struct chs_dev *dev)
Definition: chs.c:147
M0_INTERNAL void chs_conf_fini(struct chs_conf *conf)
Definition: chs.c:123
M0_INTERNAL void elevator_init(struct elevator *el, struct storage_dev *dev)
Definition: elevator.c:77
Definition: sim.h:285
unsigned ct_nr_servers
Definition: m0t1fs.h:64
static struct m0t1fs_conf m0t1fs
Definition: m0t1fs_test.c:58
static void workload_fini(void)
Definition: m0t1fs_test.c:121
Definition: net.h:57
M0_INTERNAL void sim_log(struct sim *s, enum sim_log_level level, const char *format,...)
Definition: sim.c:527
Definition: chs.h:41
static struct net_conf net
Definition: m0t1fs_test.c:38
int m0_init(struct m0 *instance)
Definition: init.c:310
#define container_of(ptr, type, member)
Definition: misc.h:33
unsigned ct_nr_threads
Definition: m0t1fs.h:63
#define M0_VOIDARG(ch, desc, func)
Definition: getopts.h:177
unsigned long ct_thread_step
Definition: m0t1fs.h:75
Definition: net.h:39
M0_INTERNAL void sim_run(struct sim *state)
Definition: sim.c:129
int i
Definition: dir.c:1033
#define LAMBDA(T,...)
Definition: thread.h:153
M0_INTERNAL void chs_conf_init(struct chs_conf *conf)
Definition: chs.c:43
#define M0_FORMATARG(ch, desc, fmt, ptr)
Definition: getopts.h:218
#define M0_ASSERT(cond)
M0_INTERNAL void m0t1fs_fini(struct m0t1fs_conf *conf)
Definition: m0t1fs.c:237
uint32_t ct_N
Definition: m0t1fs.h:70
M0_INTERNAL void m0t1fs_init(struct sim *s, struct m0t1fs_conf *conf)
Definition: m0t1fs.c:173
char * sd_name
Definition: storage.h:59
m0_bcount_t ct_total
Definition: m0t1fs.h:77
M0_INTERNAL void * sim_alloc(size_t size)
Definition: sim.c:85
Definition: chs.h:76
int main(int argc, char **argv)
Test server for m0console.
Definition: dump.c:195
M0_INTERNAL void net_init(struct net_conf *net)
Definition: net.c:129
struct storage_dev * e_dev
Definition: elevator.h:37
struct storage_conf cc_storage
Definition: chs.h:42
static void workload_init(struct sim *s, int argc, char **argv)
Definition: m0t1fs_test.c:99
M0_INTERNAL void elevator_fini(struct elevator *el)
Definition: elevator.c:87
M0_INTERNAL void cnt_dump_all(void)
Definition: cnt.c:74
#define M0_HELPARG(ch)
Definition: getopts.h:242
M0_INTERNAL void chs_dev_init(struct chs_dev *dev, struct sim *sim, struct chs_conf *conf)
Definition: chs.c:129
unsigned nc_frag_size
Definition: net.h:40
unsigned long long ns_file_size
Definition: net.h:66
sim_log_level
Definition: sim.h:284
struct storage_dev cd_storage
Definition: chs.h:77
uint32_t ct_S
Definition: m0t1fs.h:72
static struct elevator el
Definition: chs_test.c:102
unsigned ns_nr_threads
Definition: net.h:58
struct net_srv * ct_srv
Definition: m0t1fs.h:82
M0_INTERNAL void sim_name_set(char **name, const char *format,...)
Definition: sim.c:500
M0_INTERNAL void sim_fini(struct sim *state)
Definition: sim.c:116
uint64_t ct_unitsize
Definition: m0t1fs.h:73
static struct m0_addb2_source * s
Definition: consumer.c:39
M0_INTERNAL void net_fini(struct net_conf *net)
Definition: net.c:136