Motr  M0
dtm_internal.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_DTM_DTM_INTERNAL_H__
27 #define __MOTR_DTM_DTM_INTERNAL_H__
28 
35 /* import */
36 #include "lib/tlist.h"
37 #include "dtm/nucleus.h"
38 struct m0_dtm_oper;
39 struct m0_dtm_update;
40 struct m0_dtm_history;
41 struct m0_dtm_remote;
42 
43 M0_TL_DESCR_DECLARE(hi, M0_EXTERN);
44 M0_TL_DECLARE(hi, M0_EXTERN, struct m0_dtm_up);
45 M0_TL_DESCR_DECLARE(op, M0_EXTERN);
46 M0_TL_DECLARE(op, M0_EXTERN, struct m0_dtm_up);
47 
48 #define up_for(o, up) \
49 do { \
50  struct m0_dtm_up *up; \
51  \
52  m0_tl_for(op, &(o)->op_ups, up)
53 
54 #define up_endfor \
55  m0_tl_endfor; \
56 } while (0)
57 
58 #define hi_for(h, up) \
59 do { \
60  struct m0_dtm_up *up; \
61  \
62  m0_tl_for(hi, &(h)->hi_ups, up)
63 
64 #define hi_endfor \
65  m0_tl_endfor; \
66 } while (0)
67 
68 M0_TL_DESCR_DECLARE(history, M0_EXTERN);
69 M0_TL_DECLARE(history, M0_EXTERN, struct m0_dtm_update);
70 M0_TL_DESCR_DECLARE(oper, M0_EXTERN);
71 M0_TL_DECLARE(oper, M0_EXTERN, struct m0_dtm_update);
72 M0_TL_DESCR_DECLARE(cat, M0_EXTERN);
73 M0_TL_DECLARE(cat, M0_EXTERN, struct m0_dtm_history);
74 M0_TL_DESCR_DECLARE(exc, M0_EXTERN);
75 M0_TL_DECLARE(exc, M0_EXTERN, struct m0_dtm_history);
76 
77 #define oper_for(o, update) \
78 do { \
79  struct m0_dtm_update *update; \
80  \
81  m0_tl_for(oper, &(o)->oprt_op.op_ups, update)
82 
83 #define oper_endfor \
84  m0_tl_endfor; \
85 } while (0)
86 
87 #define history_for(h, update) \
88 do { \
89  struct m0_dtm_update *update; \
90  \
91  m0_tl_for(history, &(h)->h_hi.hi_ups, update)
92 
93 #define history_endfor \
94  m0_tl_endfor; \
95 } while (0)
96 
97 #define UPDATE_UP(update) \
98 ({ \
99  typeof(update) __update = (update); \
100  __update != NULL ? &__update->upd_up : NULL; \
101 })
102 
103 #define UP_HISTORY(up) hi_history((up)->up_hi)
104 #define UPDATE_HISTORY(update) UP_HISTORY(&(update)->upd_up)
105 #define UPDATE_REM(update) (UPDATE_HISTORY(update)->h_rem)
106 #define HISTORY_DTM(history) (nu_dtm((history)->h_hi.hi_nu))
107 
108 M0_INTERNAL struct m0_dtm *nu_dtm(struct m0_dtm_nu *nu);
109 M0_INTERNAL struct m0_dtm_history *hi_history(struct m0_dtm_hi *hi);
110 M0_INTERNAL struct m0_dtm_update *up_update(struct m0_dtm_up *up);
111 M0_INTERNAL m0_dtm_ver_t up_ver(const struct m0_dtm_up *up);
112 M0_INTERNAL bool op_state(const struct m0_dtm_op *op, enum m0_dtm_state state);
113 M0_INTERNAL void advance_try(const struct m0_dtm_op *op);
114 M0_INTERNAL void up_prepared(struct m0_dtm_up *up);
115 M0_INTERNAL void history_close(struct m0_dtm_history *history);
116 M0_INTERNAL void nu_lock(struct m0_dtm_nu *nu);
117 M0_INTERNAL void nu_unlock(struct m0_dtm_nu *nu);
118 M0_INTERNAL void dtm_lock(struct m0_dtm *dtm);
119 M0_INTERNAL void dtm_unlock(struct m0_dtm *dtm);
120 M0_INTERNAL void oper_lock(const struct m0_dtm_oper *oper);
121 M0_INTERNAL void oper_unlock(const struct m0_dtm_oper *oper);
122 M0_INTERNAL void history_lock(const struct m0_dtm_history *history);
123 M0_INTERNAL void history_unlock(const struct m0_dtm_history *history);
124 M0_INTERNAL void update_reint(struct m0_dtm_update *update);
125 
126 M0_INTERNAL struct m0_dtm_up *hi_latest(struct m0_dtm_hi *hi);
127 M0_INTERNAL struct m0_dtm_up *hi_earliest(struct m0_dtm_hi *hi);
128 M0_INTERNAL struct m0_dtm_up *hi_find(struct m0_dtm_hi *hi, m0_dtm_ver_t ver);
129 M0_INTERNAL struct m0_dtm_up *history_latest(struct m0_dtm_history *history);
130 M0_INTERNAL struct m0_dtm_up *history_earliest(struct m0_dtm_history *history);
131 
132 M0_INTERNAL m0_dtm_ver_t update_ver(const struct m0_dtm_update *update);
133 M0_INTERNAL m0_dtm_ver_t up_ver(const struct m0_dtm_up *up);
134 M0_INTERNAL bool up_is_earlier(struct m0_dtm_up *up0, struct m0_dtm_up *up1);
135 M0_INTERNAL bool update_is_earlier(struct m0_dtm_update *update0,
136  struct m0_dtm_update *update1);
137 
138 M0_INTERNAL int m0_dtm_remote_global_init(void);
139 M0_INTERNAL void m0_dtm_remote_global_fini(void);
140 
141 M0_INTERNAL void oper_print(const struct m0_dtm_oper *oper);
142 M0_INTERNAL void update_print(const struct m0_dtm_update *update);
143 M0_INTERNAL void history_print(const struct m0_dtm_history *history);
144 M0_INTERNAL void history_print_header(const struct m0_dtm_history *history,
145  char *buf);
146 M0_INTERNAL void update_print_internal(const struct m0_dtm_update *update,
147  bool history);
148 
149 M0_INTERNAL bool oper_update_unique(const struct m0_dtm_oper *oper,
150  const struct m0_dtm_update *update);
151 
154 #endif /* __MOTR_DTM_DTM_INTERNAL_H__ */
155 
156 
157 /*
158  * Local variables:
159  * c-indentation-style: "K&R"
160  * c-basic-offset: 8
161  * tab-width: 8
162  * fill-column: 80
163  * scroll-step: 1
164  * End:
165  */
166 /*
167  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
168  */
M0_INTERNAL void history_print_header(const struct m0_dtm_history *history, char *buf)
Definition: history.c:425
M0_INTERNAL void update_print_internal(const struct m0_dtm_update *update, bool history)
Definition: update.c:297
M0_INTERNAL m0_dtm_ver_t up_ver(const struct m0_dtm_up *up)
Definition: nucleus.c:405
M0_TL_DECLARE(hi, M0_EXTERN, struct m0_dtm_up)
M0_INTERNAL struct m0_dtm * nu_dtm(struct m0_dtm_nu *nu)
Definition: dtm.c:154
M0_INTERNAL void up_prepared(struct m0_dtm_up *up)
Definition: nucleus.c:222
M0_INTERNAL struct m0_dtm_up * hi_find(struct m0_dtm_hi *hi, m0_dtm_ver_t ver)
Definition: nucleus.c:396
M0_INTERNAL struct m0_dtm_up * history_earliest(struct m0_dtm_history *history)
Definition: history.c:210
M0_INTERNAL struct m0_dtm_update * up_update(struct m0_dtm_up *up)
Definition: update.c:228
M0_INTERNAL void dtm_lock(struct m0_dtm *dtm)
Definition: dtm.c:159
M0_INTERNAL void m0_dtm_remote_global_fini(void)
Definition: remote.c:209
Definition: sock.c:887
M0_INTERNAL struct m0_dtm_history * hi_history(struct m0_dtm_hi *hi)
Definition: history.c:199
op
Definition: libdemo.c:64
M0_INTERNAL void history_lock(const struct m0_dtm_history *history)
Definition: history.c:288
M0_INTERNAL void update_print(const struct m0_dtm_update *update)
Definition: update.c:317
M0_INTERNAL bool update_is_earlier(struct m0_dtm_update *update0, struct m0_dtm_update *update1)
Definition: update.c:234
M0_INTERNAL bool oper_update_unique(const struct m0_dtm_oper *oper, const struct m0_dtm_update *update)
Definition: operation.c:270
uint64_t m0_dtm_ver_t
Definition: nucleus.h:48
static void nu(void)
Definition: nucleus.c:87
M0_INTERNAL void update_reint(struct m0_dtm_update *update)
Definition: update.c:240
M0_INTERNAL m0_dtm_ver_t update_ver(const struct m0_dtm_update *update)
Definition: history.c:194
M0_INTERNAL void history_close(struct m0_dtm_history *history)
Definition: history.c:169
M0_INTERNAL void nu_lock(struct m0_dtm_nu *nu)
Definition: nucleus.c:538
M0_INTERNAL bool up_is_earlier(struct m0_dtm_up *up0, struct m0_dtm_up *up1)
Definition: nucleus.c:410
M0_TL_DESCR_DECLARE(hi, M0_EXTERN)
M0_INTERNAL void oper_unlock(const struct m0_dtm_oper *oper)
Definition: operation.c:288
M0_INTERNAL void nu_unlock(struct m0_dtm_nu *nu)
Definition: nucleus.c:543
M0_INTERNAL void history_unlock(const struct m0_dtm_history *history)
Definition: history.c:293
M0_INTERNAL bool op_state(const struct m0_dtm_op *op, enum m0_dtm_state state)
Definition: nucleus.c:511
M0_INTERNAL void dtm_unlock(struct m0_dtm *dtm)
Definition: dtm.c:164
Definition: dtm.h:529
M0_INTERNAL void oper_print(const struct m0_dtm_oper *oper)
Definition: operation.c:293
M0_INTERNAL struct m0_dtm_up * hi_earliest(struct m0_dtm_hi *hi)
Definition: nucleus.c:390
M0_INTERNAL void advance_try(const struct m0_dtm_op *op)
Definition: nucleus.c:145
M0_INTERNAL int m0_dtm_remote_global_init(void)
Definition: remote.c:195
m0_dtm_state
Definition: nucleus.h:52
static void hi(void)
Definition: nucleus.c:93
M0_INTERNAL void oper_lock(const struct m0_dtm_oper *oper)
Definition: operation.c:283
M0_INTERNAL void history_print(const struct m0_dtm_history *history)
Definition: history.c:438
M0_INTERNAL struct m0_dtm_up * hi_latest(struct m0_dtm_hi *hi)
Definition: nucleus.c:385
M0_INTERNAL struct m0_dtm_up * history_latest(struct m0_dtm_history *history)
Definition: history.c:205