Motr  M0
st_kmain.c
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 #include <linux/module.h>
24 #include <linux/moduleparam.h>
25 #include <linux/kernel.h>
26 #include <linux/init.h>
27 #include <linux/sched.h>
28 #include <linux/mm.h>
29 
30 #include "motr/client.h"
31 #include "motr/st/st.h"
32 #include "motr/st/st_assert.h"
33 
34 /*
35  * We are using Apache license for complete motr code but for MODULE_LICENSE
36  * marker there is no provision to mention Apache for this marker. But as this
37  * marker is necessary to remove the warnings, keeping this blank to make
38  * compiler happy.
39  */
41 
43  IDX_MOTR = 1,
45 };
46 
47 /* Module parameters */
48 static char *local_addr;
49 static char *ha_addr;
50 static char *prof;
51 static char *proc_fid;
52 static char *tests;
53 static int index_service;
54 static struct m0_config conf;
56 
57 module_param(local_addr, charp, S_IRUGO);
58 MODULE_PARM_DESC(local_addr, "Local Address");
59 
60 module_param(ha_addr, charp, S_IRUGO);
61 MODULE_PARM_DESC(ha_addr, "HA Address");
62 
63 module_param(prof, charp, S_IRUGO);
64 MODULE_PARM_DESC(prof, "Profile Opt");
65 
66 module_param(proc_fid, charp, S_IRUGO);
67 MODULE_PARM_DESC(proc_fid, "Process FID for rmservice");
68 
69 module_param(index_service, int, S_IRUGO);
70 MODULE_PARM_DESC(index_service, "Index service");
71 
72 module_param(tests, charp, S_IRUGO);
73 MODULE_PARM_DESC(tests, "ST tests");
74 
75 static int st_init_instance(void)
76 {
77  int rc;
78  struct m0_client *instance = NULL;
79 
80  conf.mc_is_oostore = true;
81  conf.mc_is_read_verify = false;
82  conf.mc_local_addr = local_addr;
83  conf.mc_ha_addr = ha_addr;
84  conf.mc_profile = prof;
85  conf.mc_process_fid = proc_fid;
86  conf.mc_tm_recv_queue_min_len = M0_NET_TM_RECV_QUEUE_DEF_LEN;
87  conf.mc_max_rpc_msg_size = M0_RPC_DEF_MAX_RPC_MSG_SIZE;
88 
89  /* TODO: ST for index APIs are disabled in kernel mode.
90  * Motr KVS need to implement a new feature demanded by MOTR-2210
91  * System tests for Index will be enabled again after that feature
92  * is implemented in KVS backend.
93  */
94  conf.mc_idx_service_id = M0_IDX_DIX;
95  dix_conf.kc_create_meta = false;
96  conf.mc_idx_service_conf = &dix_conf;
97 
98  rc = m0_client_init(&instance, &conf, true);
99  if (rc != 0)
100  goto exit;
101 
103 
104 exit:
105  return rc;
106 }
107 
108 static void st_fini_instance(void)
109 {
110  struct m0_client *instance;
111 
113  m0_client_fini(instance, true);
114 }
115 
116 static int __init st_module_init(void)
117 {
118  int rc;
119 
121 
122  /* Initilises MOTR ST. */
123  st_init();
124  st_add_suites();
125 
126  /*
127  * Set tests to be run. If tests == NULL, all ST will
128  * be executed.
129  */
131 
132  /* Currently, all threads share the same instance. */
133  rc = st_init_instance();
134  if (rc < 0) {
135  printk(KERN_INFO"init failed!\n");
136  return rc;
137  }
138 
139  /*
140  * Start worker threads.
141  */
143  st_cleaner_init();
144  return st_start_workers();
145 }
146 
147 static void __exit st_module_fini(void)
148 {
150  st_stop_workers();
151  st_cleaner_fini();
153  st_fini();
154 }
155 
158 
159 /*
160  * Local variables:
161  * c-indentation-style: "K&R"
162  * c-basic-offset: 8
163  * tab-width: 8
164  * fill-column: 80
165  * scroll-step: 1
166  * End:
167  */
static char * local_addr
Definition: st_kmain.c:48
#define NULL
Definition: misc.h:38
int st_stop_workers(void)
Definition: st_worker.c:258
static int index_service
Definition: st_kmain.c:53
static char * tests
Definition: st_kmain.c:52
void m0_client_fini(struct m0_client *m0c, bool fini_m0)
Definition: client_init.c:1711
Definition: idx.h:70
Definition: conf.py:1
static char * prof
Definition: st_kmain.c:50
int m0_client_init(struct m0_client **m0c, struct m0_config *conf, bool init_m0)
Definition: client_init.c:1533
void st_set_instance(struct m0_client *instance)
Definition: st.c:52
static char * ha_addr
Definition: st_kmain.c:49
void st_fini(void)
Definition: st.c:490
static struct m0_idx_dix_config dix_conf
Definition: st_kmain.c:55
void st_set_nr_workers(int nr)
Definition: st.c:95
void st_add_suites()
Definition: st.c:541
module_param(local_addr, charp, S_IRUGO)
module_init(motr_init)
int st_init(void)
Definition: st.c:448
static void st_fini_instance(void)
Definition: st_kmain.c:108
void st_set_tests(const char *tests)
Definition: st.c:75
void st_cleaner_fini()
Definition: st_assert.c:307
MODULE_LICENSE()
int st_cleaner_init()
Definition: st_assert.c:259
module_exit(motr_exit)
static int st_init_instance(void)
Definition: st_kmain.c:75
idx_service
Definition: st_kmain.c:42
struct m0_client * st_get_instance()
Definition: st.c:57
MODULE_PARM_DESC(local_addr, "Local Address")
bool kc_create_meta
Definition: idx.h:183
#define M0_CLIENT_THREAD_ENTER
static void __exit st_module_fini(void)
Definition: st_kmain.c:147
static int __init st_module_init(void)
Definition: st_kmain.c:116
static struct m0 instance
Definition: main.c:78
static char * proc_fid
Definition: st_kmain.c:51
int st_start_workers(void)
Definition: st_worker.c:226
int32_t rc
Definition: trigger_fop.h:47