Motr  M0
engine.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 
24 #pragma once
25 
26 #ifndef __MOTR_BE_ENGINE_H__
27 #define __MOTR_BE_ENGINE_H__
28 
29 #include "lib/types.h" /* bool */
30 #include "lib/mutex.h" /* m0_mutex */
31 #include "lib/tlist.h" /* m0_tl */
32 #include "lib/semaphore.h" /* m0_semaphore */
33 
34 #include "be/log.h" /* m0_be_log */
35 #include "be/tx.h" /* m0_be_tx */
36 #include "be/tx_credit.h" /* m0_be_tx_credit */
37 #include "be/tx_group.h" /* m0_be_tx_group_cfg */
38 
39 struct m0_reqh_service;
40 struct m0_be_tx_group;
41 struct m0_be_domain;
42 struct m0_be_engine;
43 struct m0_reqh;
44 struct m0_stob;
45 struct m0_be_log_discard;
46 struct m0_be_pd;
47 
61  size_t bec_group_nr;
76  /*
77  * The following 3 parameters define group freeze timeout.
78  * @see be_engine_group_timer_arm().
79  */
84  struct m0_reqh *bec_reqh;
90  struct m0_be_pd *bec_pd;
94  struct m0_mutex *bec_lock;
95 };
96 
97 struct m0_be_engine {
103  struct m0_tl eng_txs[M0_BTS_NR + 1];
109  size_t eng_group_nr;
111  uint64_t eng_tx_id_next;
121 };
122 
123 M0_INTERNAL bool m0_be_engine__invariant(struct m0_be_engine *en);
124 
125 M0_INTERNAL int m0_be_engine_init(struct m0_be_engine *en,
126  struct m0_be_domain *dom,
127  struct m0_be_engine_cfg *en_cfg);
128 M0_INTERNAL void m0_be_engine_fini(struct m0_be_engine *en);
129 
130 M0_INTERNAL int m0_be_engine_start(struct m0_be_engine *en);
131 M0_INTERNAL void m0_be_engine_stop(struct m0_be_engine *en);
132 
133 /* next functions should be called from m0_be_tx implementation */
134 M0_INTERNAL void m0_be_engine__tx_init(struct m0_be_engine *en,
135  struct m0_be_tx *tx,
136  enum m0_be_tx_state state);
137 
138 M0_INTERNAL void m0_be_engine__tx_fini(struct m0_be_engine *en,
139  struct m0_be_tx *tx);
140 
141 M0_INTERNAL void m0_be_engine__tx_state_set(struct m0_be_engine *en,
142  struct m0_be_tx *tx,
143  enum m0_be_tx_state state);
148 M0_INTERNAL void m0_be_engine__tx_force(struct m0_be_engine *en,
149  struct m0_be_tx *tx);
150 
151 M0_INTERNAL void m0_be_engine__tx_group_ready(struct m0_be_engine *en,
152  struct m0_be_tx_group *gr);
153 M0_INTERNAL void m0_be_engine__tx_group_discard(struct m0_be_engine *en,
154  struct m0_be_tx_group *gr);
155 
156 M0_INTERNAL void m0_be_engine_got_log_space_cb(struct m0_be_log *log);
157 M0_INTERNAL void m0_be_engine_full_log_cb(struct m0_be_log *log);
158 
159 M0_INTERNAL struct m0_be_tx *m0_be_engine__tx_find(struct m0_be_engine *en,
160  uint64_t id);
161 M0_INTERNAL int
163  struct m0_be_tx *excl);
164 
165 M0_INTERNAL void m0_be_engine_tx_size_max(struct m0_be_engine *en,
166  struct m0_be_tx_credit *cred,
167  m0_bcount_t *payload_size);
168 
169 M0_INTERNAL void m0_be_engine__group_limits(struct m0_be_engine *en,
170  uint32_t *group_nr,
171  uint32_t *tx_per_group);
172 
174 #endif /* __MOTR_BE_ENGINE_H__ */
175 
176 /*
177  * Local variables:
178  * c-indentation-style: "K&R"
179  * c-basic-offset: 8
180  * tab-width: 8
181  * fill-column: 80
182  * scroll-step: 1
183  * End:
184  */
185 /*
186  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
187  */
M0_INTERNAL void m0_be_engine_fini(struct m0_be_engine *en)
Definition: engine.c:171
struct m0_be_domain * bec_domain
Definition: engine.h:88
m0_time_t bec_group_freeze_timeout_max
Definition: engine.h:81
struct m0_semaphore eng_recovery_wait_sem
Definition: engine.h:119
bool bec_wait_for_recovery
Definition: engine.h:86
M0_INTERNAL struct m0_be_tx * m0_be_engine__tx_find(struct m0_be_engine *en, uint64_t id)
Definition: engine.c:887
m0_be_tx_state
Definition: tx.h:214
M0_INTERNAL void m0_be_engine__tx_group_ready(struct m0_be_engine *en, struct m0_be_tx_group *gr)
Definition: engine.c:738
uint64_t m0_time_t
Definition: time.h:37
struct m0_mutex * bec_lock
Definition: engine.h:94
M0_INTERNAL int m0_be_engine_start(struct m0_be_engine *en)
Definition: engine.c:792
uint64_t m0_bcount_t
Definition: types.h:77
struct m0_be_engine_cfg * eng_cfg
Definition: engine.h:98
struct m0_be_tx_credit bec_tx_size_max
Definition: engine.h:73
M0_INTERNAL int m0_be_engine__exclusive_open_invariant(struct m0_be_engine *en, struct m0_be_tx *excl)
Definition: engine.c:921
uint64_t bec_tx_active_max
Definition: engine.h:59
struct m0_be_log eng_log
Definition: engine.h:106
struct m0_tl eng_groups[M0_BGS_NR]
Definition: engine.h:104
m0_time_t bec_group_freeze_timeout_limit
Definition: engine.h:82
struct m0_reqh * bec_reqh
Definition: engine.h:84
struct m0_be_pd * bec_pd
Definition: engine.h:90
M0_INTERNAL void m0_be_engine_got_log_space_cb(struct m0_be_log *log)
Definition: engine.c:860
uint64_t eng_tx_id_next
Definition: engine.h:111
struct m0_be_tx_group * eng_group
Definition: engine.h:108
M0_INTERNAL void m0_be_engine__tx_state_set(struct m0_be_engine *en, struct m0_be_tx *tx, enum m0_be_tx_state state)
Definition: engine.c:639
Definition: stob.h:163
struct m0_be_log_discard * bec_log_discard
Definition: engine.h:89
Definition: tlist.h:251
static struct m0_stob_domain * dom
Definition: storage.c:38
struct m0_be_domain * eng_domain
Definition: engine.h:118
M0_INTERNAL bool m0_be_engine__invariant(struct m0_be_engine *en)
Definition: engine.c:612
bool eng_exclusive_mode
Definition: engine.h:117
Definition: reqh.h:94
M0_INTERNAL void m0_be_engine__tx_group_discard(struct m0_be_engine *en, struct m0_be_tx_group *gr)
struct m0_tl eng_txs[M0_BTS_NR+1]
Definition: engine.h:103
M0_INTERNAL void m0_be_engine__tx_fini(struct m0_be_engine *en, struct m0_be_tx *tx)
Definition: engine.c:631
M0_INTERNAL void m0_be_engine_tx_size_max(struct m0_be_engine *en, struct m0_be_tx_credit *cred, m0_bcount_t *payload_size)
Definition: engine.c:937
M0_INTERNAL void m0_be_engine__group_limits(struct m0_be_engine *en, uint32_t *group_nr, uint32_t *tx_per_group)
Definition: engine.c:947
struct m0_reqh_service * eng_service
Definition: engine.h:110
M0_INTERNAL void m0_be_engine_stop(struct m0_be_engine *en)
Definition: engine.c:847
size_t bec_group_nr
Definition: engine.h:61
m0_time_t bec_group_freeze_timeout_min
Definition: engine.h:80
Definition: pd.h:64
M0_INTERNAL void m0_be_engine__tx_force(struct m0_be_engine *en, struct m0_be_tx *tx)
Definition: engine.c:684
M0_INTERNAL int m0_be_engine_init(struct m0_be_engine *en, struct m0_be_domain *dom, struct m0_be_engine_cfg *en_cfg)
Definition: engine.c:103
struct m0_be_tx_group_cfg bec_group_cfg
Definition: engine.h:71
M0_INTERNAL void m0_be_engine_full_log_cb(struct m0_be_log *log)
Definition: engine.c:874
struct m0_be_tx_group_cfg * bec_groups_cfg
Definition: engine.h:92
Definition: log.h:261
Definition: tx.h:270
Definition: mutex.h:47
bool eng_recovery_finished
Definition: engine.h:120
size_t eng_group_nr
Definition: engine.h:109
M0_INTERNAL void m0_be_engine__tx_init(struct m0_be_engine *en, struct m0_be_tx *tx, enum m0_be_tx_state state)
Definition: engine.c:623
Definition: tx.h:280
m0_bcount_t bec_tx_payload_max
Definition: engine.h:75