Motr  M0
history.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_HISTORY_H__
27 #define __MOTR_DTM_HISTORY_H__
28 
29 #include "lib/tlist.h"
30 #include "lib/queue.h"
31 #include "lib/cookie.h"
32 
33 #include "dtm/nucleus.h"
34 
41 /* import */
42 #include "dtm/operation.h"
43 struct m0_dtm;
44 struct m0_dtm_remote;
45 
46 /* export */
47 struct m0_dtm_history;
48 struct m0_dtm_history_ops;
49 struct m0_dtm_history_type;
51 
56  struct m0_dtm_hi h_hi;
65  const struct m0_dtm_history_ops *h_ops;
66  uint64_t h_gen;
67  uint64_t h_epoch;
70 };
71 M0_INTERNAL bool m0_dtm_history_invariant(const struct m0_dtm_history *history);
72 
76 };
77 
80  const struct m0_uint128 *(*hio_id)(const struct m0_dtm_history *history);
81  void (*hio_persistent)(struct m0_dtm_history *history);
82  void (*hio_fixed )(struct m0_dtm_history *history);
83  int (*hio_update )(struct m0_dtm_history *history, uint8_t id,
84  struct m0_dtm_update *update);
85 };
86 
88  uint8_t hit_id;
89  uint8_t hit_rem_id;
90  const char *hit_name;
92 };
93 
95  int (*hito_find)(struct m0_dtm *dtm,
96  const struct m0_dtm_history_type *ht,
97  const struct m0_uint128 *id,
98  struct m0_dtm_history **out);
99 };
100 
106 };
107 
108 M0_INTERNAL void m0_dtm_history_init(struct m0_dtm_history *history,
109  struct m0_dtm *dtm);
110 M0_INTERNAL void m0_dtm_history_fini(struct m0_dtm_history *history);
111 
112 M0_INTERNAL void m0_dtm_history_persistent(struct m0_dtm_history *history,
113  m0_dtm_ver_t upto);
114 M0_INTERNAL void m0_dtm_history_reset(struct m0_dtm_history *history,
115  m0_dtm_ver_t since);
116 M0_INTERNAL void m0_dtm_history_undo(struct m0_dtm_history *history,
117  m0_dtm_ver_t upto);
118 M0_INTERNAL void m0_dtm_history_close(struct m0_dtm_history *history);
119 
120 M0_INTERNAL void m0_dtm_history_update_get(const struct m0_dtm_history *history,
121  enum m0_dtm_up_rule rule,
122  struct m0_dtm_update_data *data);
123 
124 M0_INTERNAL void
126  const struct m0_dtm_history_type *ht);
127 M0_INTERNAL void
129  const struct m0_dtm_history_type *ht);
130 M0_INTERNAL const struct m0_dtm_history_type *
131 m0_dtm_history_type_find(struct m0_dtm *dtm, uint8_t id);
132 
133 M0_INTERNAL void m0_dtm_history_pack(const struct m0_dtm_history *history,
134  struct m0_dtm_history_id *id);
135 
136 M0_INTERNAL int m0_dtm_history_unpack(struct m0_dtm *dtm,
137  const struct m0_dtm_history_id *id,
138  struct m0_dtm_history **out);
139 
140 M0_INTERNAL void m0_dtm_history_add_nop(struct m0_dtm_history *history,
141  struct m0_dtm_oper *oper,
142  struct m0_dtm_update *cupdate);
143 M0_INTERNAL void m0_dtm_history_add_close(struct m0_dtm_history *history,
144  struct m0_dtm_oper *oper,
145  struct m0_dtm_update *cupdate);
146 
147 M0_INTERNAL void m0_dtm_controlh_init(struct m0_dtm_controlh *ch,
148  struct m0_dtm *dtm);
149 M0_INTERNAL void m0_dtm_controlh_fini(struct m0_dtm_controlh *ch);
150 M0_INTERNAL void m0_dtm_controlh_add(struct m0_dtm_controlh *ch,
151  struct m0_dtm_oper *oper);
152 M0_INTERNAL void m0_dtm_controlh_close(struct m0_dtm_controlh *ch);
153 M0_INTERNAL int m0_dtm_controlh_update(struct m0_dtm_history *history,
154  uint8_t id,
155  struct m0_dtm_update *update);
156 M0_INTERNAL bool
157 m0_dtm_controlh_update_is_close(const struct m0_dtm_update *update);
158 
159 M0_INTERNAL void m0_dtm_controlh_fuse_close(struct m0_dtm_update *update);
160 
163 #endif /* __MOTR_DTM_HISTORY_H__ */
164 
165 
166 /*
167  * Local variables:
168  * c-indentation-style: "K&R"
169  * c-basic-offset: 8
170  * tab-width: 8
171  * fill-column: 80
172  * scroll-step: 1
173  * End:
174  */
175 /*
176  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
177  */
uint64_t id
Definition: cob.h:2380
const struct m0_dtm_history_type_ops * hit_ops
Definition: history.h:91
struct m0_dtm_update * h_known
Definition: history.h:63
m0_dtm_up_rule
Definition: nucleus.h:84
M0_INTERNAL void m0_dtm_controlh_fini(struct m0_dtm_controlh *ch)
Definition: history.c:340
M0_INTERNAL const struct m0_dtm_history_type * m0_dtm_history_type_find(struct m0_dtm *dtm, uint8_t id)
Definition: history.c:234
struct m0_dtm_remote * h_rem
Definition: history.h:59
M0_INTERNAL void m0_dtm_controlh_init(struct m0_dtm_controlh *ch, struct m0_dtm *dtm)
Definition: history.c:328
struct m0_cookie h_remcookie
Definition: history.h:68
uint8_t hit_id
Definition: history.h:88
struct m0_bufvec data
Definition: di.c:40
M0_INTERNAL void m0_dtm_controlh_close(struct m0_dtm_controlh *ch)
Definition: history.c:346
void(* hio_persistent)(struct m0_dtm_history *history)
Definition: history.h:81
m0_dtm_history_flags
Definition: history.h:73
struct m0_dtm_update * h_reint
Definition: history.h:62
struct m0_dtm_hi h_hi
Definition: history.h:56
M0_INTERNAL void m0_dtm_history_fini(struct m0_dtm_history *history)
Definition: history.c:63
int(* hio_update)(struct m0_dtm_history *history, uint8_t id, struct m0_dtm_update *update)
Definition: history.h:83
struct m0_dtm_oper ch_clop
Definition: history.h:103
struct m0_dtm_history ch_history
Definition: history.h:102
M0_INTERNAL void m0_dtm_history_type_register(struct m0_dtm *dtm, const struct m0_dtm_history_type *ht)
Definition: history.c:216
M0_INTERNAL void m0_dtm_history_undo(struct m0_dtm_history *history, m0_dtm_ver_t upto)
Definition: history.c:144
struct m0_dtm_update * h_persistent
Definition: history.h:60
M0_INTERNAL void m0_dtm_history_persistent(struct m0_dtm_history *history, m0_dtm_ver_t upto)
Definition: history.c:107
M0_INTERNAL int m0_dtm_history_unpack(struct m0_dtm *dtm, const struct m0_dtm_history_id *id, struct m0_dtm_history **out)
Definition: history.c:248
uint64_t h_gen
Definition: history.h:66
uint64_t m0_dtm_ver_t
Definition: nucleus.h:48
struct m0_dtm_update * h_reset
Definition: history.h:64
M0_INTERNAL void m0_dtm_history_close(struct m0_dtm_history *history)
Definition: history.c:162
M0_INTERNAL bool m0_dtm_controlh_update_is_close(const struct m0_dtm_update *update)
Definition: history.c:414
const char * hit_name
Definition: history.h:90
struct m0_tlink h_exclink
Definition: history.h:57
M0_INTERNAL void m0_dtm_history_reset(struct m0_dtm_history *history, m0_dtm_ver_t since)
Definition: history.c:125
struct m0_dtm_update ch_clup_rem
Definition: history.h:105
M0_INTERNAL void m0_dtm_history_type_deregister(struct m0_dtm *dtm, const struct m0_dtm_history_type *ht)
Definition: history.c:225
M0_INTERNAL void m0_dtm_history_add_close(struct m0_dtm_history *history, struct m0_dtm_oper *oper, struct m0_dtm_update *cupdate)
Definition: history.c:319
M0_INTERNAL void m0_dtm_history_pack(const struct m0_dtm_history *history, struct m0_dtm_history_id *id)
Definition: history.c:239
struct m0_tlink h_catlink
Definition: history.h:58
M0_INTERNAL bool m0_dtm_history_invariant(const struct m0_dtm_history *history)
Definition: history.c:71
int(* hito_find)(struct m0_dtm *dtm, const struct m0_dtm_history_type *ht, const struct m0_uint128 *id, struct m0_dtm_history **out)
Definition: history.h:95
const struct m0_dtm_history_type * hio_type
Definition: history.h:79
M0_INTERNAL void m0_dtm_controlh_fuse_close(struct m0_dtm_update *update)
Definition: history.c:406
M0_INTERNAL int m0_dtm_controlh_update(struct m0_dtm_history *history, uint8_t id, struct m0_dtm_update *update)
Definition: history.c:393
M0_INTERNAL void m0_dtm_history_update_get(const struct m0_dtm_history *history, enum m0_dtm_up_rule rule, struct m0_dtm_update_data *data)
Definition: history.c:176
uint64_t h_epoch
Definition: history.h:67
M0_INTERNAL void m0_dtm_history_init(struct m0_dtm_history *history, struct m0_dtm *dtm)
Definition: history.c:51
struct m0_dtm_update * h_undo
Definition: history.h:61
Definition: dtm.h:529
struct m0_dtm_update ch_clup
Definition: history.h:104
void(* hio_fixed)(struct m0_dtm_history *history)
Definition: history.h:82
#define out(...)
Definition: gen.c:41
M0_INTERNAL void m0_dtm_controlh_add(struct m0_dtm_controlh *ch, struct m0_dtm_oper *oper)
Definition: history.c:352
M0_INTERNAL void m0_dtm_history_add_nop(struct m0_dtm_history *history, struct m0_dtm_oper *oper, struct m0_dtm_update *cupdate)
Definition: history.c:298
m0_dtm_ver_t h_max_ver
Definition: history.h:69
uint8_t hit_rem_id
Definition: history.h:89
const struct m0_dtm_history_ops * h_ops
Definition: history.h:65