Motr  M0
reqh.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-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_REQH_REQH_H__
26 #define __MOTR_REQH_REQH_H__
27 
28 #include "lib/tlist.h"
29 #include "lib/lockers.h"
30 #include "lib/bob.h"
31 
32 #include "conf/confc.h"
33 #include "conf/rconfc.h" /* m0_rconfc */
34 #include "sm/sm.h"
35 #include "fop/fom.h"
36 #include "layout/layout.h"
37 #include "ha/epoch.h"
38 #include "rpc/session.h"
39 
63 enum {
65  DEFAULT_ADDB2_RECORD_SIZE = 128ULL << 20,
67  MIN_ADDB2_RECORD_SIZE = 10ULL << 20,
69  MAX_ADDB2_RECORD_SIZE = 10ULL << 30,
72 };
73 
74 struct m0_fop;
75 struct m0_rpc_machine;
76 struct m0_addb2_storage;
77 struct m0_confc_args;
78 
79 M0_LOCKERS_DECLARE(M0_EXTERN, m0_reqh, 256);
80 
89 };
90 
94 struct m0_reqh {
96  uint64_t rh_magic;
97 
99  struct m0_sm rh_sm;
100 
108 
109  struct m0_dtm *rh_dtm;
110 
113 
116 
117  /* Initialized pools */
119 
121  struct m0_fol rh_fol;
141 
144 
149 
154 
157 
161  struct m0_reqh_lockers rh_lockers;
162 
167 
172 
175 
177  struct m0_fid rh_fid;
178 
181 
184 
195 
206 
228 
231 };
232 
237  struct m0_dtm *rhia_dtm;
242  const struct m0_fid *rhia_fid; /* fid of m0_conf_process */
243 };
244 
255 M0_INTERNAL int m0_reqh_init(struct m0_reqh *reqh,
256  const struct m0_reqh_init_args *args);
257 
258 M0_INTERNAL bool m0_reqh_invariant(const struct m0_reqh *reqh);
259 
262 #define M0_REQH_INIT(reqh, ...) \
263  m0_reqh_init((reqh), &(const struct m0_reqh_init_args) { \
264  __VA_ARGS__ })
265 
274 M0_INTERNAL void m0_reqh_fini(struct m0_reqh *reqh);
275 
279 M0_INTERNAL int m0_reqh_be_init(struct m0_reqh *reqh,
280  struct m0_be_seg *seg);
281 
285 M0_INTERNAL void m0_reqh_be_fini(struct m0_reqh *reqh);
286 
290 M0_INTERNAL void m0_reqh_layouts_cleanup(struct m0_reqh *reqh);
291 
292 M0_INTERNAL int m0_reqh_addb2_init(struct m0_reqh *reqh, const char *location,
293  uint64_t key, bool mkfs, bool force,
294  m0_bcount_t size);
295 M0_INTERNAL void m0_reqh_addb2_fini(struct m0_reqh *reqh);
296 
297 M0_INTERNAL int m0_reqh_addb2_submit(struct m0_reqh *reqh,
298  struct m0_addb2_trace_obj *tobj);
299 
303 M0_INTERNAL int m0_reqh_state_get(struct m0_reqh *reqh);
304 
310 M0_INTERNAL int m0_reqh_fop_allow(struct m0_reqh *reqh, struct m0_fop *fop);
311 
325 M0_INTERNAL int m0_reqh_fop_handle(struct m0_reqh *reqh, struct m0_fop *fop);
326 
335 M0_INTERNAL void m0_reqh_idle_wait(struct m0_reqh *reqh);
336 
340 M0_INTERNAL void m0_reqh_idle_wait_for(struct m0_reqh *reqh,
341  struct m0_reqh_service *service);
342 
352 M0_INTERNAL void m0_reqh_start(struct m0_reqh *reqh);
353 
361 M0_INTERNAL int m0_reqh_services_state_count(struct m0_reqh *reqh, int state);
362 
366 M0_INTERNAL void m0_reqh_services_prepare_to_stop(struct m0_reqh *reqh,
367  unsigned level);
368 
377 M0_INTERNAL void m0_reqh_shutdown(struct m0_reqh *reqh);
378 
388 M0_INTERNAL void m0_reqh_shutdown_wait(struct m0_reqh *reqh);
389 
399 M0_INTERNAL void m0_reqh_services_terminate(struct m0_reqh *reqh);
400 M0_INTERNAL void m0_reqh_pre_storage_fini_svcs_stop(struct m0_reqh *reqh);
401 M0_INTERNAL void m0_reqh_post_storage_fini_svcs_stop(struct m0_reqh *reqh);
402 
408 M0_INTERNAL int m0_reqhs_init(void);
409 
413 M0_INTERNAL void m0_reqhs_fini(void);
414 
416 M0_INTERNAL uint64_t m0_reqh_nr_localities(const struct m0_reqh *reqh);
417 
421 M0_INTERNAL int m0_reqh_conf_setup(struct m0_reqh *reqh,
422  struct m0_confc_args *args);
423 
425 M0_TL_DESCR_DECLARE(m0_reqh_svc, M0_EXTERN);
426 M0_TL_DECLARE(m0_reqh_svc, M0_INTERNAL, struct m0_reqh_service);
427 M0_BOB_DECLARE(M0_EXTERN, m0_reqh_service);
428 
430 M0_TL_DESCR_DECLARE(m0_reqh_rpc_mach, extern);
431 M0_TL_DECLARE(m0_reqh_rpc_mach, , struct m0_rpc_machine);
432 
433 M0_INTERNAL int m0_reqh_mdpool_layout_build(struct m0_reqh *reqh);
440 M0_INTERNAL struct m0_rpc_session *
442  const struct m0_fid *gfid,
443  uint32_t index);
444 
445 M0_INTERNAL struct m0_confc *m0_reqh2confc(struct m0_reqh *reqh);
446 M0_INTERNAL struct m0_fid *m0_reqh2profile(struct m0_reqh *reqh);
447 
450 /* __MOTR_REQH_REQH_H__ */
451 #endif
452 
453 /*
454  * Local variables:
455  * c-indentation-style: "K&R"
456  * c-basic-offset: 8
457  * tab-width: 8
458  * fill-column: 80
459  * scroll-step: 1
460  * End:
461  */
Definition: fol.h:140
M0_INTERNAL void m0_reqh_be_fini(struct m0_reqh *reqh)
Definition: reqh.c:289
struct m0_be_seg * rhia_db
Definition: reqh.h:239
M0_INTERNAL void m0_reqh_services_terminate(struct m0_reqh *reqh)
Definition: reqh.c:675
struct m0_ha_domain rh_hadom
Definition: reqh.h:156
struct m0_pools_common * rhia_pc
Definition: reqh.h:241
struct m0_mdstore * rh_mdstore
Definition: reqh.h:115
struct m0_chan rh_conf_cache_ready_async
Definition: reqh.h:227
M0_INTERNAL void m0_reqh_layouts_cleanup(struct m0_reqh *reqh)
Definition: reqh.c:169
M0_INTERNAL int m0_reqh_fop_handle(struct m0_reqh *reqh, struct m0_fop *fop)
Definition: reqh.c:546
enum m0_trace_level level
Definition: trace.c:111
struct m0_chan rh_conf_cache_ready
Definition: reqh.h:205
M0_INTERNAL void m0_reqhs_fini(void)
Definition: reqh.c:328
uint64_t m0_bcount_t
Definition: types.h:77
struct m0_tl rh_services
Definition: reqh.h:127
Definition: sm.h:504
Definition: ub.c:49
M0_INTERNAL void m0_reqh_fini(struct m0_reqh *reqh)
Definition: reqh.c:320
struct m0_rwlock rh_rwlock
Definition: reqh.h:143
struct m0_reqh_service * rh_rpc_service
Definition: reqh.h:140
M0_INTERNAL int m0_reqh_addb2_init(struct m0_reqh *reqh, const char *location, uint64_t key, bool mkfs, bool force, m0_bcount_t size)
Definition: reqh.c:341
const char * location
Definition: storage.c:50
M0_INTERNAL int m0_reqh_addb2_submit(struct m0_reqh *reqh, struct m0_addb2_trace_obj *tobj)
M0_INTERNAL void m0_reqh_shutdown_wait(struct m0_reqh *reqh)
Definition: reqh.c:647
struct m0_mutex rh_guard
Definition: reqh.h:180
M0_INTERNAL struct m0_fid * m0_reqh2profile(struct m0_reqh *reqh)
Definition: reqh.c:758
M0_INTERNAL bool m0_reqh_invariant(const struct m0_reqh *reqh)
Definition: reqh.c:136
struct m0_mutex rh_guard_async
Definition: reqh.h:183
struct m0_dtm * rh_dtm
Definition: reqh.h:109
M0_INTERNAL struct m0_confc * m0_reqh2confc(struct m0_reqh *reqh)
Definition: reqh.c:753
M0_INTERNAL int m0_reqh_conf_setup(struct m0_reqh *reqh, struct m0_confc_args *args)
Definition: reqh.c:729
Definition: tlist.h:251
M0_INTERNAL struct m0_rpc_session * m0_reqh_mdpool_service_index_to_session(const struct m0_reqh *reqh, const struct m0_fid *gob_fid, uint32_t index)
Definition: reqh.c:177
M0_INTERNAL int m0_reqh_init(struct m0_reqh *reqh, const struct m0_reqh_init_args *reqh_args)
Definition: reqh.c:227
struct m0_tl rh_rpc_machines
Definition: reqh.h:135
M0_INTERNAL void m0_reqh_shutdown(struct m0_reqh *reqh)
Definition: reqh.c:636
M0_INTERNAL int m0_reqh_mdpool_layout_build(struct m0_reqh *reqh)
Definition: reqh.c:145
bool rh_oostore
Definition: reqh.h:171
M0_INTERNAL uint64_t m0_reqh_nr_localities(const struct m0_reqh *reqh)
Definition: reqh.c:723
M0_INTERNAL int m0_reqhs_init(void)
Definition: reqh.c:333
M0_TL_DESCR_DECLARE(m0_reqh_svc, M0_EXTERN)
Definition: reqh.h:94
struct m0_layout_domain rh_ldom
Definition: reqh.h:153
struct m0_mdstore * rhia_mdstore
Definition: reqh.h:240
Definition: chan.h:229
M0_INTERNAL void m0_reqh_post_storage_fini_svcs_stop(struct m0_reqh *reqh)
Definition: reqh.c:704
M0_INTERNAL int m0_reqh_fop_allow(struct m0_reqh *reqh, struct m0_fop *fop)
Definition: reqh.c:437
struct m0_sm rh_sm
Definition: reqh.h:99
Definition: seg.h:66
M0_LOCKERS_DECLARE(M0_EXTERN, m0_reqh, 256)
M0_INTERNAL void m0_reqh_idle_wait(struct m0_reqh *reqh)
Definition: reqh.c:606
struct m0_sm_ast rh_conf_cache_ast
Definition: reqh.h:230
M0_INTERNAL int m0_reqh_state_get(struct m0_reqh *reqh)
Definition: reqh.c:398
M0_BOB_DECLARE(M0_EXTERN, m0_reqh_service)
M0_INTERNAL void m0_reqh_start(struct m0_reqh *reqh)
Definition: reqh.c:711
struct m0_reqh reqh
Definition: rm_foms.c:48
struct m0_dtm * rhia_dtm
Definition: reqh.h:237
M0_TL_DECLARE(m0_reqh_svc, M0_INTERNAL, struct m0_reqh_service)
Definition: fid.h:38
struct m0_chan rh_conf_cache_exp
Definition: reqh.h:194
struct m0_reqh_lockers rh_lockers
Definition: reqh.h:161
struct m0_sm_group rh_sm_grp
Definition: reqh.h:107
Definition: sm.h:301
m0_bcount_t size
Definition: di.c:39
struct m0_pools_common * rh_pools
Definition: reqh.h:118
M0_INTERNAL void m0_reqh_pre_storage_fini_svcs_stop(struct m0_reqh *reqh)
Definition: reqh.c:681
static struct m0_fop * fop
Definition: item.c:57
struct m0_fol rh_fol
Definition: reqh.h:121
M0_INTERNAL void m0_reqh_idle_wait_for(struct m0_reqh *reqh, struct m0_reqh_service *service)
Definition: reqh.c:591
struct m0_be_seg * rh_beseg
Definition: reqh.h:112
struct m0_semaphore rh_addb2_stor_idle
Definition: reqh.h:146
struct m0_fid rh_fid
Definition: reqh.h:177
static struct m0_be_seg * seg
Definition: btree.c:40
M0_INTERNAL void m0_reqh_services_prepare_to_stop(struct m0_reqh *reqh, unsigned level)
Definition: reqh.c:620
Definition: dtm.h:529
struct m0_semaphore rh_addb2_net_idle
Definition: reqh.h:148
struct m0_rconfc rh_rconfc
Definition: reqh.h:166
struct m0_fid gfid
Definition: dir.c:626
struct m0_addb2_storage * rh_addb2_stor
Definition: reqh.h:145
M0_INTERNAL void m0_reqh_addb2_fini(struct m0_reqh *reqh)
Definition: reqh.c:383
M0_INTERNAL int m0_reqh_be_init(struct m0_reqh *reqh, struct m0_be_seg *seg)
Definition: reqh.c:269
Definition: mutex.h:47
M0_INTERNAL int m0_reqh_services_state_count(struct m0_reqh *reqh, int state)
Definition: reqh.c:413
static struct m0_reqh_service * service[REQH_IN_UT_MAX]
Definition: long_lock_ut.c:46
struct m0_addb2_net * rh_addb2_net
Definition: reqh.h:147
Definition: fop.h:79
struct m0_reqh_service_ctx * rh_ha_rsctx
Definition: reqh.h:174
uint64_t rh_magic
Definition: reqh.h:96
m0_reqh_states
Definition: reqh.h:82
Definition: idx_mock.c:47
const struct m0_fid * rhia_fid
Definition: reqh.h:242