Motr  M0
dtx0.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 #pragma once
23 
24 #ifndef __MOTR___DTM0_DTX0_H__
25 #define __MOTR___DTM0_DTX0_H__
26 
27 #include "sm/sm.h" /* m0_sm */
28 
35 /*
36  * DTX0 overview
37  * -------------
38  * DTX0 is a component that serves as the public API of DTM0.
39  * It is used by other "external" Motr components (CAS/DIX)
40  * to add DTM0 semantics to their operations.
41  * DTX0 receives REDO message (for example, a serialised CAS request)
42  * as incoming data, and notifies when a distributed
43  * transaction becomes STABLE (client side). Everything else is hidden
44  * from the user.
45  *
46  * Concurrency
47  * -----------
48  * On the client side a dtx belongs to the sm group of the Motr
49  * client operation that uses this dtx. The relation between sm group
50  * of dtx0 and the context of DTM0 log is not defined yet (TODO).
51  *
52  * Lifetime
53  * --------
54  * The lifetime of dtx is related to the lifetime of the corresponding
55  * user operation. dtx cannot be destroyed until it reached STABLE state.
56  *
57  * States
58  * ------
59  * A dtx has only one state transition exposed to the user: transition
60  * to the STABLE state.
61  *
62  * Failures
63  * --------
64  *
65  * When one of the participants of a dtx becomes T (TRANSIENT) then
66  * dtx receives this information from the user. dtx itself does not subscribe
67  * to HA events. Once a dtx gets enough P (PERSISTENT) messages, it moves
68  * to STABLE state (enough == as per the durability requirements).
69  *
70  * Integration
71  * -----------
72  *
73  * +--------+ +------+ +----------+
74  * | Client | --- REDO ---> | DTX0 | --- log record ---> | DTM0 log |
75  * | (DIX) | <--- stable - | | <--- persistent --- | |
76  * +--------+ +------+ +----------+
77  *
78  * +--------+ +------+ +----------+
79  * | Server | --- REDO ---> | DTX0 | --- log record ---> | DTM0 log |
80  * | (CAS) | --- be_tx --> | | --- be_tx ---> | |
81  * +--------+ +------+ +----------+
82  *
83  */
84 
85 
86 struct m0_dtm0_domain;
87 struct m0_dtm0_tx_desc;
88 struct m0_fid;
89 struct m0_buf;
90 struct m0_be_tx_credit;
91 struct m0_be_tx;
92 struct m0_be_op;
93 
94 struct m0_dtx0 {
96  struct m0_sm dtx0_sm;
97 };
98 
103 };
104 
105 M0_INTERNAL int m0_dtx0_init(struct m0_dtx0 *dtx0,
106  struct m0_dtm0_domain *dod);
107 M0_INTERNAL void m0_dtx0_fini(struct m0_dtx0 *dtx0);
108 
109 M0_INTERNAL int m0_dtx0_set(struct m0_dtx0 *dtx0,
110  const struct m0_dtm0_tx_desc *txd,
111  const struct m0_buf *buf);
112 
113 M0_INTERNAL void m0_dtx0_timestamp_set(struct m0_dtx0 *dtx0);
114 
115 M0_INTERNAL int m0_dtx0_participants_set(struct m0_dtx0 *dtx0,
116  const struct m0_fid *rdtm_svcs,
117  int rdtm_svcs_nr);
118 
119 M0_INTERNAL int m0_dtx0_buf_set(struct m0_dtx0 *dtx0,
120  const struct m0_buf *buf);
121 
122 M0_INTERNAL void m0_dtx0_credit(struct m0_dtx0 *dtx0,
123  struct m0_be_tx_credit *accum);
124 
125 M0_INTERNAL int m0_dtx0_log_update(struct m0_dtx0 *dtx0,
126  struct m0_be_tx *tx,
127  struct m0_be_op *op,
128  bool is_redo);
129 
130 /* TODO */
131 M0_INTERNAL void m0_dtx0_cancel(struct m0_dtx0 *dtx0);
132 
134 #endif /* __MOTR___DTM0_DTX0_H__ */
135 
136 /*
137  * Local variables:
138  * c-indentation-style: "K&R"
139  * c-basic-offset: 8
140  * tab-width: 8
141  * fill-column: 80
142  * scroll-step: 1
143  * End:
144  */
145 /*
146  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
147  */
M0_INTERNAL int m0_dtx0_set(struct m0_dtx0 *dtx0, const struct m0_dtm0_tx_desc *txd, const struct m0_buf *buf)
M0_INTERNAL void m0_dtx0_timestamp_set(struct m0_dtx0 *dtx0)
Definition: sock.c:887
op
Definition: libdemo.c:64
Definition: buf.h:37
M0_INTERNAL int m0_dtx0_buf_set(struct m0_dtx0 *dtx0, const struct m0_buf *buf)
m0_dtx0_state
Definition: dtx0.h:99
M0_INTERNAL void m0_dtx0_cancel(struct m0_dtx0 *dtx0)
M0_INTERNAL int m0_dtx0_init(struct m0_dtx0 *dtx0, struct m0_dtm0_domain *dod)
Definition: dtx0.c:33
M0_INTERNAL int m0_dtx0_participants_set(struct m0_dtx0 *dtx0, const struct m0_fid *rdtm_svcs, int rdtm_svcs_nr)
struct m0_sm dtx0_sm
Definition: dtx0.h:96
M0_INTERNAL void m0_dtx0_credit(struct m0_dtx0 *dtx0, struct m0_be_tx_credit *accum)
Definition: fid.h:38
Definition: sm.h:301
M0_INTERNAL void m0_dtx0_fini(struct m0_dtx0 *dtx0)
Definition: dtx0.c:39
Definition: op.h:74
Definition: dtx0.h:94
Definition: tx.h:280
M0_INTERNAL int m0_dtx0_log_update(struct m0_dtx0 *dtx0, struct m0_be_tx *tx, struct m0_be_op *op, bool is_redo)