Motr  M0
dtx.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2021 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 #pragma once
23 
24 #ifndef __MOTR_DTM0_DTX_H__
25 #define __MOTR_DTM0_DTX_H__
26 
27 #include "dtm0/tx_desc.h" /* m0_dtm0_tx_desc */
28 #include "sm/sm.h" /* m0_sm */
29 #include "dtm/dtm.h" /* m0_dtx */
30 
34  /* dtx has a valid tx record. */
36  /* dtx got one reply. */
38  /* dtx got all replies. */
40  /* dtx got enough PERSISTENT messages. */
42  /* dtx can be released when this state reached. */
44  /* dtx can fail. */
47 };
48 
49 struct m0_dtm0_dtx {
60  /* see m0_dtm0_dtx_state */
61  struct m0_sm dd_sm;
64  uint32_t dd_nr_executed;
66 
67  /*
68  * XXX: The implementation is very simple and it relies on the idea
69  * of fully replicated requests. Therefore, all FOP submitted
70  * as a part of this DTX should to be identical (at least
71  * from the REDO mechanism standpoint). So that we do not use
72  * any lists here. But we will have to some time later.
73  */
74  const struct m0_fop *dd_fop;
75 };
76 
80  struct m0_sm_ast p_ast;
82  struct m0_fop *p_fop;
84  struct m0_dtm0_dtx *p_dtx;
85 };
86 
87 M0_INTERNAL void m0_dtm0_dtx_domain_init(void);
88 M0_INTERNAL void m0_dtm0_dtx_domain_fini(void);
89 
90 /*
91  * The API below extends the existing m0_dtx API. Since it operates
92  * on m0_dtx structure in the "DTM0"-way, the naming convention here is
93  * a bit different (m0_dtx + dtm0 => m0_dtx0).
94  */
95 
96 M0_INTERNAL struct m0_dtx* m0_dtx0_alloc(struct m0_dtm0_service *svc,
97  struct m0_sm_group *grp);
98 
100 M0_INTERNAL void m0_dtx0_prepare(struct m0_dtx *dtx);
101 
107 M0_INTERNAL int m0_dtx0_open(struct m0_dtx *dtx, uint32_t nr_pa);
108 
114 M0_INTERNAL int m0_dtx0_fid_assign(struct m0_dtx *dtx,
115  uint32_t pa_idx,
116  const struct m0_fid *pa_sfid);
117 
119 M0_INTERNAL void m0_dtx0_fop_assign(struct m0_dtx *dtx,
120  uint32_t pa_idx,
121  const struct m0_fop *pa_fop);
122 
130 M0_INTERNAL int m0_dtx0_close(struct m0_dtx *dtx);
131 
137 M0_INTERNAL void m0_dtx0_executed(struct m0_dtx *dtx, uint32_t pa_idx);
138 
146 M0_INTERNAL void m0_dtx0_done(struct m0_dtx *dtx);
147 
153 M0_INTERNAL void m0_dtm0_dtx_pmsg_post(struct m0_dtm0_dtx *dtx,
154  struct m0_fop *fop);
155 
161 M0_INTERNAL int m0_dtx0_txd_copy(const struct m0_dtx *dtx,
162  struct m0_dtm0_tx_desc *dst);
163 
164 M0_INTERNAL enum m0_dtm0_dtx_state m0_dtx0_sm_state(const struct m0_dtx *dtx);
165 
166 #endif /* __MOTR_DTM0_DTX_H__ */
167 
168 /*
169  * Local variables:
170  * c-indentation-style: "K&R"
171  * c-basic-offset: 8
172  * tab-width: 8
173  * fill-column: 80
174  * scroll-step: 1
175  * End:
176  */
177 /*
178  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
179  */
Definition: dtm.h:554
struct m0_dtx dd_ancient_dtx
Definition: dtx.h:59
M0_INTERNAL int m0_dtx0_open(struct m0_dtx *dtx, uint32_t nr_pa)
Definition: dtx.c:469
static struct m0_bufvec dst
Definition: xform.c:61
struct m0_fop * p_fop
Definition: dtx.h:82
M0_INTERNAL void m0_dtm0_dtx_pmsg_post(struct m0_dtm0_dtx *dtx, struct m0_fop *fop)
Definition: dtx.c:371
Definition: dtx.h:46
static struct m0_sm_group * grp
Definition: bytecount.c:38
M0_INTERNAL void m0_dtx0_done(struct m0_dtx *dtx)
Definition: dtx.c:504
M0_INTERNAL int m0_dtx0_txd_copy(const struct m0_dtx *dtx, struct m0_dtm0_tx_desc *dst)
Definition: dtx.c:510
M0_INTERNAL int m0_dtx0_close(struct m0_dtx *dtx)
Definition: dtx.c:492
M0_INTERNAL void m0_dtx0_prepare(struct m0_dtx *dtx)
Definition: dtx.c:463
Definition: sm.h:504
struct m0_sm dd_sm
Definition: dtx.h:61
struct m0_sm_ast p_ast
Definition: dtx.h:80
M0_INTERNAL struct m0_dtx * m0_dtx0_alloc(struct m0_dtm0_service *svc, struct m0_sm_group *grp)
Definition: dtx.c:456
M0_INTERNAL void m0_dtm0_dtx_domain_init(void)
Definition: dtx.c:90
m0_dtm0_dtx_state
Definition: dtx.h:31
M0_INTERNAL void m0_dtm0_dtx_domain_fini(void)
Definition: dtx.c:98
const struct m0_fop * dd_fop
Definition: dtx.h:74
M0_INTERNAL void m0_dtx0_executed(struct m0_dtx *dtx, uint32_t pa_idx)
Definition: dtx.c:498
M0_INTERNAL int m0_dtx0_fid_assign(struct m0_dtx *dtx, uint32_t pa_idx, const struct m0_fid *pa_sfid)
Definition: dtx.c:475
Definition: fid.h:38
M0_INTERNAL void m0_dtx0_fop_assign(struct m0_dtx *dtx, uint32_t pa_idx, const struct m0_fop *pa_fop)
Definition: dtx.c:483
struct m0_dtm0_service * dd_dtms
Definition: dtx.h:63
struct m0_dtm0_dtx * p_dtx
Definition: dtx.h:84
static struct m0_net_test_service svc
Definition: service.c:34
Definition: sm.h:301
M0_INTERNAL enum m0_dtm0_dtx_state m0_dtx0_sm_state(const struct m0_dtx *dtx)
Definition: dtx.c:522
static struct m0_fop * fop
Definition: item.c:57
uint32_t dd_nr_executed
Definition: dtx.h:64
struct m0_sm_ast dd_exec_all_ast
Definition: dtx.h:65
Definition: fop.h:79
struct m0_dtm0_tx_desc dd_txd
Definition: dtx.h:62