Motr  M0
tx_group.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 #ifndef __MOTR_BE_TX_GROUP_H__
25 #define __MOTR_BE_TX_GROUP_H__
26 
27 #include "lib/tlist.h" /* m0_tl */
28 
29 #include "be/tx_credit.h" /* m0_be_tx_credit */
30 #include "be/tx_group_format.h" /* m0_be_group_format */
31 #include "be/tx_group_fom.h" /* m0_be_group_fom */
32 #include "be/tx_regmap.h" /* m0_be_reg_area */
33 #include "be/tx.h" /* m0_be_tx_state */
34 
35 struct m0_be_engine;
36 struct m0_be_domain;
37 struct m0_be_tx;
38 struct be_recovering_tx;
39 struct m0_be_op;
40 
53 };
54 
57  unsigned long tgc_tx_nr_max;
59  unsigned long tgc_seg_nr_max;
72  struct m0_be_log *tgc_log;
74  struct m0_be_pd *tgc_pd;
76  struct m0_reqh *tgc_reqh;
79 };
80 
114  uint32_t tg_nr_unclosed;
118  uint32_t tg_nr_unstable;
120  struct m0_tl tg_txs;
125  /* Linkage for engine lists (m0_be_engine::eng_txs). */
127  /* Magic for tg_engine_linkage. */
128  uint64_t tg_magic;
130  struct m0_be_group_format tg_od; /* XXX rename */
131  struct m0_be_log *tg_log;
147 };
148 
149 M0_INTERNAL bool m0_be_tx_group__invariant(struct m0_be_tx_group *gr);
150 
151 /* ------------------------------------------------------------------
152  * Interfaces used by m0_be_engine
153  * ------------------------------------------------------------------ */
154 
155 M0_INTERNAL int m0_be_tx_group_init(struct m0_be_tx_group *gr,
156  struct m0_be_tx_group_cfg *gr_cfg);
157 M0_INTERNAL void m0_be_tx_group_fini(struct m0_be_tx_group *gr);
158 
159 M0_INTERNAL int m0_be_tx_group_start(struct m0_be_tx_group *gr);
160 M0_INTERNAL void m0_be_tx_group_stop(struct m0_be_tx_group *gr);
161 
163 M0_INTERNAL int m0_be_tx_group_tx_add(struct m0_be_tx_group *gr,
164  struct m0_be_tx *tx);
166 M0_INTERNAL size_t m0_be_tx_group_tx_nr(struct m0_be_tx_group *gr);
167 
168 M0_INTERNAL void m0_be_tx_group_tx_closed(struct m0_be_tx_group *gr,
169  struct m0_be_tx *tx);
170 
171 M0_INTERNAL void m0_be_tx_group_close(struct m0_be_tx_group *gr);
172 
177 M0_INTERNAL void m0_be_tx_group_stable(struct m0_be_tx_group *gr);
178 
179 M0_INTERNAL struct m0_sm_group *
181 M0_INTERNAL bool m0_be_tx_group_is_recovering(struct m0_be_tx_group *gr);
182 
183 /* ------------------------------------------------------------------
184  * Interfaces used by m0_be_tx_group_fom
185  * ------------------------------------------------------------------ */
186 
188 M0_INTERNAL void m0_be_tx_group_reset(struct m0_be_tx_group *gr);
189 
190 M0_INTERNAL void m0_be_tx_group_prepare(struct m0_be_tx_group *gr,
191  struct m0_be_op *op);
192 
194 M0_INTERNAL void m0_be_tx_group_tx_del(struct m0_be_tx_group *gr,
195  struct m0_be_tx *tx);
196 M0_INTERNAL void m0_be_tx_group_open(struct m0_be_tx_group *gr);
197 
202 M0_INTERNAL void
204  enum m0_be_tx_state state,
205  bool del_tx_from_group);
206 M0_INTERNAL int m0_be_tx_group__allocate(struct m0_be_tx_group *gr);
207 M0_INTERNAL void m0_be_tx_group__deallocate(struct m0_be_tx_group *gr);
208 
209 M0_INTERNAL void m0_be_tx_group_seg_place_prepare(struct m0_be_tx_group *gr);
210 M0_INTERNAL void m0_be_tx_group_seg_place(struct m0_be_tx_group *gr,
211  struct m0_be_op *op);
212 M0_INTERNAL void m0_be_tx_group_encode(struct m0_be_tx_group *gr);
213 
214 M0_INTERNAL void m0_be_tx_group_log_write(struct m0_be_tx_group *gr,
215  struct m0_be_op *op);
216 
217 /* ------------------------------------------------------------------
218  * Interfaces used by recovery.
219  * ------------------------------------------------------------------ */
220 
221 M0_INTERNAL void m0_be_tx_group_recovery_prepare(struct m0_be_tx_group *gr,
222  struct m0_be_log *log);
223 M0_INTERNAL void m0_be_tx_group_log_read(struct m0_be_tx_group *gr,
224  struct m0_be_op *op);
225 M0_INTERNAL int m0_be_tx_group_decode(struct m0_be_tx_group *gr);
226 M0_INTERNAL int m0_be_tx_group_reconstruct(struct m0_be_tx_group *gr,
227  struct m0_sm_group *sm_grp);
228 M0_INTERNAL void m0_be_tx_group_reconstruct_tx_open(struct m0_be_tx_group *gr,
229  struct m0_be_op *op);
231 M0_INTERNAL void
233  struct m0_be_op *op_gc);
234 M0_INTERNAL int m0_be_tx_group_reapply(struct m0_be_tx_group *gr,
235  struct m0_be_op *op);
236 
237 /* ------------------------------------------------------------------
238  * Interfaces used by domain.
239  * ------------------------------------------------------------------ */
240 
241 M0_INTERNAL void m0_be_tx_group_discard(struct m0_be_log_discard *ld,
242  struct m0_be_log_discard_item *ldi);
243 
244 M0_INTERNAL void
246  struct m0_be_io_credit *io_cred);
247 
248 /* XXX see comment in be/tx_group.c */
249 #if 0
250 M0_INTERNAL void tx_group_init(struct m0_be_tx_group *gr,
251  struct m0_stob *log_stob);
252 M0_INTERNAL void tx_group_fini(struct m0_be_tx_group *gr);
253 
254 M0_INTERNAL void tx_group_add(struct m0_be_tx_engine *eng,
255  struct m0_be_tx_group *gr,
256  struct m0_be_tx *tx);
257 M0_INTERNAL void tx_group_close(struct m0_be_tx_engine *eng,
258  struct m0_be_tx_group *gr);
259 /* Note the absence of tx_group_open(). */
260 #endif
261 
262 #define M0_BE_TX_GROUP_TX_FORALL(gr, tx) \
263  m0_tl_for(grp, &(gr)->tg_txs, (tx))
264 
265 #define M0_BE_TX_GROUP_TX_ENDFOR m0_tl_endfor
266 
267 M0_TL_DESCR_DECLARE(grp, M0_EXTERN);
268 M0_TL_DECLARE(grp, M0_INTERNAL, struct m0_be_tx);
269 
271 #endif /* __MOTR_BE_TX_GROUP_H__ */
272 
273 /*
274  * Local variables:
275  * c-indentation-style: "K&R"
276  * c-basic-offset: 8
277  * tab-width: 8
278  * fill-column: 80
279  * scroll-step: 1
280  * End:
281  */
282 /*
283  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
284  */
m0_bcount_t tgc_payload_max
Definition: tx_group.h:66
struct m0_be_reg_area tg_reg_area
Definition: tx_group.h:135
M0_INTERNAL void m0_be_tx_group_seg_place(struct m0_be_tx_group *gr, struct m0_be_op *op)
Definition: tx_group.c:424
M0_INTERNAL void m0_be_tx_group_discard(struct m0_be_log_discard *ld, struct m0_be_log_discard_item *ldi)
Definition: tx_group.c:635
struct be_recovering_tx * tg_rtxs
Definition: tx_group.h:124
M0_INTERNAL void m0_be_tx_group_seg_io_credit(struct m0_be_tx_group_cfg *gr_cfg, struct m0_be_io_credit *io_cred)
Definition: tx_group.c:642
M0_INTERNAL void m0_be_tx_group_close(struct m0_be_tx_group *gr)
Definition: tx_group.c:147
struct m0_be_group_format tg_od
Definition: tx_group.h:130
struct m0_tl tg_txs_recovering
Definition: tx_group.h:122
M0_INTERNAL int m0_be_tx_group_init(struct m0_be_tx_group *gr, struct m0_be_tx_group_cfg *gr_cfg)
Definition: tx_group.c:201
M0_INTERNAL void m0_be_tx_group_recovery_prepare(struct m0_be_tx_group *gr, struct m0_be_log *log)
Definition: tx_group.c:462
M0_TL_DECLARE(grp, M0_INTERNAL, struct m0_be_tx)
m0_be_tx_state
Definition: tx.h:214
M0_INTERNAL struct m0_sm_group * m0_be_tx_group__sm_group(struct m0_be_tx_group *gr)
Definition: tx_group.c:73
M0_INTERNAL void m0_be_tx_group_tx_closed(struct m0_be_tx_group *gr, struct m0_be_tx *tx)
Definition: tx_group.c:325
struct m0_be_log_discard * tgc_log_discard
Definition: tx_group.h:73
M0_INTERNAL void m0_be_tx_group_reconstruct_tx_close(struct m0_be_tx_group *gr, struct m0_be_op *op_gc)
Definition: tx_group.c:601
static struct m0_sm_group * grp
Definition: bytecount.c:38
uint64_t m0_time_t
Definition: time.h:37
m0_bcount_t tg_payload_prepared
Definition: tx_group.h:110
M0_INTERNAL void m0_be_tx_group__deallocate(struct m0_be_tx_group *gr)
Definition: tx_group.c:408
struct m0_be_domain * tgc_domain
Definition: tx_group.h:68
struct m0_be_domain * tg_domain
Definition: tx_group.h:132
struct m0_sm_timer tg_close_timer
Definition: tx_group.h:141
uint64_t m0_bcount_t
Definition: types.h:77
Definition: sm.h:504
struct m0_be_engine * tg_engine
Definition: tx_group.h:133
M0_INTERNAL int m0_be_tx_group_start(struct m0_be_tx_group *gr)
Definition: tx_group.c:393
struct m0_sm_ast tg_close_timer_arm
Definition: tx_group.h:142
struct m0_be_group_format_cfg tgc_format
Definition: tx_group.h:78
M0_TL_DESCR_DECLARE(grp, M0_EXTERN)
M0_INTERNAL void m0_be_tx_group_reset(struct m0_be_tx_group *gr)
Definition: tx_group.c:178
struct m0_be_pd * tgc_pd
Definition: tx_group.h:74
M0_INTERNAL void m0_be_tx_group_reconstruct_tx_open(struct m0_be_tx_group *gr, struct m0_be_op *op)
Definition: tx_group.c:585
uint64_t tg_magic
Definition: tx_group.h:128
op
Definition: libdemo.c:64
M0_INTERNAL void m0_be_tx_group_log_write(struct m0_be_tx_group *gr, struct m0_be_op *op)
Definition: tx_group.c:435
uint32_t tg_nr_unstable
Definition: tx_group.h:118
M0_INTERNAL void m0_be_tx_group_encode(struct m0_be_tx_group *gr)
Definition: tx_group.c:430
struct m0_be_log * tgc_log
Definition: tx_group.h:72
Definition: stob.h:163
m0_time_t tg_close_deadline
Definition: tx_group.h:144
M0_INTERNAL void m0_be_tx_group__tx_state_post(struct m0_be_tx_group *gr, enum m0_be_tx_state state, bool del_tx_from_group)
Definition: tx_group.c:442
M0_INTERNAL int m0_be_tx_group__allocate(struct m0_be_tx_group *gr)
Definition: tx_group.c:403
struct m0_be_tx_credit tgc_size_max
Definition: tx_group.h:61
struct m0_sm_ast tg_close_timer_disarm
Definition: tx_group.h:143
Definition: tlist.h:251
struct m0_be_tx_credit tg_used
Definition: tx_group.h:107
struct m0_be_tx_credit tg_size
Definition: tx_group.h:108
M0_INTERNAL void m0_be_tx_group_tx_del(struct m0_be_tx_group *gr, struct m0_be_tx *tx)
Definition: tx_group.c:375
M0_INTERNAL bool m0_be_tx_group_is_recovering(struct m0_be_tx_group *gr)
Definition: tx_group.c:78
struct m0_be_tx_group_fom tg_fom
Definition: tx_group.h:134
M0_INTERNAL size_t m0_be_tx_group_tx_nr(struct m0_be_tx_group *gr)
Definition: tx_group.c:383
unsigned long tgc_tx_nr_max
Definition: tx_group.h:57
struct m0_be_tx_credit tg_log_reserved
Definition: tx_group.h:109
struct m0_reqh * tgc_reqh
Definition: tx_group.h:76
struct m0_be_reg_area_merger tg_merger
Definition: tx_group.h:137
Definition: reqh.h:94
m0_be_tx_group_state
Definition: tx_group.h:47
M0_INTERNAL void m0_be_tx_group_log_read(struct m0_be_tx_group *gr, struct m0_be_op *op)
Definition: tx_group.c:470
M0_INTERNAL void m0_be_tx_group_stop(struct m0_be_tx_group *gr)
Definition: tx_group.c:398
M0_INTERNAL bool m0_be_tx_group__invariant(struct m0_be_tx_group *gr)
Definition: tx_group.c:247
M0_INTERNAL int m0_be_tx_group_tx_add(struct m0_be_tx_group *gr, struct m0_be_tx *tx)
Definition: tx_group.c:286
struct m0_be_tx_group_cfg tg_cfg
Definition: tx_group.h:105
M0_INTERNAL void m0_be_tx_group_seg_place_prepare(struct m0_be_tx_group *gr)
Definition: tx_group.c:413
struct m0_tlink tg_engine_linkage
Definition: tx_group.h:126
struct m0_be_engine * tgc_engine
Definition: tx_group.h:70
M0_INTERNAL void m0_be_tx_group_fini(struct m0_be_tx_group *gr)
Definition: tx_group.c:252
Definition: pd.h:64
M0_INTERNAL int m0_be_tx_group_decode(struct m0_be_tx_group *gr)
Definition: tx_group.c:476
M0_INTERNAL int m0_be_tx_group_reapply(struct m0_be_tx_group *gr, struct m0_be_op *op)
Definition: tx_group.c:620
M0_INTERNAL void m0_be_tx_group_stable(struct m0_be_tx_group *gr)
Definition: tx_group.c:65
Definition: log.h:261
M0_INTERNAL int m0_be_tx_group_reconstruct(struct m0_be_tx_group *gr, struct m0_sm_group *sm_grp)
Definition: tx_group.c:577
enum m0_be_tx_group_state tg_state
Definition: tx_group.h:146
struct m0_tl tg_txs
Definition: tx_group.h:120
Definition: op.h:74
unsigned long tgc_seg_nr_max
Definition: tx_group.h:59
M0_INTERNAL void m0_be_tx_group_open(struct m0_be_tx_group *gr)
Definition: tx_group.c:388
uint32_t tg_nr_unclosed
Definition: tx_group.h:114
Definition: tx.h:280
struct m0_be_log * tg_log
Definition: tx_group.h:131
M0_INTERNAL void m0_be_tx_group_prepare(struct m0_be_tx_group *gr, struct m0_be_op *op)
Definition: tx_group.c:195
bool tg_recovering
Definition: tx_group.h:136