Motr  M0
update.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_UPDATE_H__
27 #define __MOTR_DTM_UPDATE_H__
28 
29 
36 #include "dtm/nucleus.h"
37 
38 /* export */
39 struct m0_dtm_update;
40 struct m0_dtm_update_ops;
41 struct m0_dtm_update_type;
42 struct m0_dtm_update_descr;
43 
44 /* import */
45 struct m0_dtm_history_type;
46 struct m0_dtm_oper;
47 struct m0_dtm_history;
48 struct m0_fop;
49 #include "lib/cookie.h"
50 #include "lib/types_xc.h" /* m0_uint128_xc */
51 #include "lib/cookie_xc.h"
52 #include "xcode/xcode.h" /* struct m0_xcode_obj */
53 
58 };
59 
62 };
63 
66  uint64_t uc_flags;
67  uint64_t uc_instance;
68  struct m0_fop *uc_body;
69 };
70 
71 struct m0_dtm_update {
72  struct m0_dtm_up upd_up;
73  uint32_t upd_label;
74  const struct m0_dtm_update_ops *upd_ops;
76 };
77 M0_INTERNAL bool m0_dtm_update_invariant(const struct m0_dtm_update *update);
78 
79 enum {
81 };
82 
84  int (*updo_redo) (struct m0_dtm_update *updt);
85  int (*updo_undo) (struct m0_dtm_update *updt);
86  void (*updto_replied)(struct m0_dtm_update *updt);
88 };
89 
91  uint8_t updtt_id;
92  const char *updtt_name;
93 };
94 
96  uint64_t da_ver;
97  uint64_t da_orig_ver;
98  uint32_t da_label;
99  uint8_t da_rule;
100 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
101 
102 #define M0_DTM_UPDATE_DATA(label, rule, ver, orig_ver) \
103 (struct m0_dtm_update_data) { \
104  .da_label = (label), \
105  .da_rule = (rule), \
106  .da_ver = (ver), \
107  .da_orig_ver = (orig_ver) \
108 }
109 
114  uint8_t hid_htype;
115 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
116 
120  uint8_t udd_utype;
121 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
122 
123 M0_INTERNAL void m0_dtm_update_init(struct m0_dtm_update *update,
124  struct m0_dtm_history *history,
125  struct m0_dtm_oper *oper,
126  const struct m0_dtm_update_data *data);
127 M0_INTERNAL bool m0_dtm_update_is_user(const struct m0_dtm_update *update);
128 M0_INTERNAL void m0_dtm_update_pack(const struct m0_dtm_update *update,
129  struct m0_dtm_update_descr *updd);
130 M0_INTERNAL void m0_dtm_update_unpack(struct m0_dtm_update *update,
131  const struct m0_dtm_update_descr *updd);
132 M0_INTERNAL int m0_dtm_update_build(struct m0_dtm_update *update,
133  struct m0_dtm_oper *oper,
134  const struct m0_dtm_update_descr *updd);
135 M0_INTERNAL void m0_dtm_update_reint(struct m0_dtm_update *update);
136 M0_INTERNAL void m0_dtm_comm_set (struct m0_dtm_update *update,
137  struct m0_fop *fop);
138 M0_INTERNAL bool
139 m0_dtm_update_matches_descr(const struct m0_dtm_update *update,
140  const struct m0_dtm_update_descr *updd);
141 M0_INTERNAL bool
142 m0_dtm_descr_matches_update(const struct m0_dtm_update *update,
143  const struct m0_dtm_update_descr *updd);
144 M0_INTERNAL void m0_dtm_update_list_init(struct m0_tl *list);
145 M0_INTERNAL void m0_dtm_update_list_fini(struct m0_tl *list);
146 M0_INTERNAL void m0_dtm_update_link(struct m0_tl *list,
147  struct m0_dtm_update *update, uint32_t nr);
148 
151 #endif /* __MOTR_DTM_UPDATE_H__ */
152 
153 
154 /*
155  * Local variables:
156  * c-indentation-style: "K&R"
157  * c-basic-offset: 8
158  * tab-width: 8
159  * fill-column: 80
160  * scroll-step: 1
161  * End:
162  */
163 /*
164  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
165  */
M0_INTERNAL int m0_dtm_update_build(struct m0_dtm_update *update, struct m0_dtm_oper *oper, const struct m0_dtm_update_descr *updd)
Definition: update.c:132
struct m0_dtm_up upd_up
Definition: update.h:72
struct m0_dtm_history_id udd_id
Definition: update.h:119
int(* updo_undo)(struct m0_dtm_update *updt)
Definition: update.h:85
static size_t nr
Definition: dump.c:1505
struct m0_dtm_update_comm upd_comm
Definition: update.h:75
struct m0_dtm_update_data udd_data
Definition: update.h:118
struct m0_fop * uc_body
Definition: update.h:68
static struct m0_list list
Definition: list.c:144
M0_INTERNAL void m0_dtm_update_unpack(struct m0_dtm_update *update, const struct m0_dtm_update_descr *updd)
Definition: update.c:113
uint8_t hid_htype
Definition: update.h:114
const char * updtt_name
Definition: update.h:92
M0_INTERNAL bool m0_dtm_update_invariant(const struct m0_dtm_update *update)
Definition: update.c:65
uint32_t da_label
Definition: update.h:98
struct m0_bufvec data
Definition: di.c:40
M0_INTERNAL bool m0_dtm_update_is_user(const struct m0_dtm_update *update)
Definition: update.c:87
m0_dtm_update_comm_flags
Definition: update.h:60
const struct m0_dtm_update_ops * upd_ops
Definition: update.h:74
uint32_t upd_label
Definition: update.h:73
struct m0_cookie hid_sender
Definition: update.h:112
M0_INTERNAL void m0_dtm_update_link(struct m0_tl *list, struct m0_dtm_update *update, uint32_t nr)
Definition: update.c:221
struct m0_cookie hid_receiver
Definition: update.h:113
uint64_t uc_instance
Definition: update.h:67
struct m0_uint128 hid_id
Definition: update.h:111
M0_INTERNAL bool m0_dtm_descr_matches_update(const struct m0_dtm_update *update, const struct m0_dtm_update_descr *updd)
Definition: update.c:166
Definition: tlist.h:251
M0_INTERNAL void m0_dtm_comm_set(struct m0_dtm_update *update, struct m0_fop *fop)
Definition: update.c:205
#define M0_XCA_DOMAIN(value)
Definition: xcode_attr.h:72
const struct m0_dtm_update_type * updo_type
Definition: update.h:87
uint64_t uc_flags
Definition: update.h:66
uint64_t da_ver
Definition: update.h:96
void(* updto_replied)(struct m0_dtm_update *updt)
Definition: update.h:86
enum m0_dtm_update_comm_state uc_state
Definition: update.h:65
M0_INTERNAL void m0_dtm_update_init(struct m0_dtm_update *update, struct m0_dtm_history *history, struct m0_dtm_oper *oper, const struct m0_dtm_update_data *data)
Definition: update.c:47
M0_INTERNAL void m0_dtm_update_reint(struct m0_dtm_update *update)
Definition: update.c:192
M0_INTERNAL bool m0_dtm_update_matches_descr(const struct m0_dtm_update *update, const struct m0_dtm_update_descr *updd)
Definition: update.c:154
uint8_t da_rule
Definition: update.h:99
M0_INTERNAL void m0_dtm_update_list_fini(struct m0_tl *list)
Definition: update.c:182
M0_INTERNAL void m0_dtm_update_pack(const struct m0_dtm_update *update, struct m0_dtm_update_descr *updd)
Definition: update.c:93
static struct m0_fop * fop
Definition: item.c:57
M0_INTERNAL void m0_dtm_update_list_init(struct m0_tl *list)
Definition: update.c:177
uint8_t updtt_id
Definition: update.h:91
m0_dtm_update_comm_state
Definition: update.h:54
uint8_t udd_utype
Definition: update.h:120
uint64_t da_orig_ver
Definition: update.h:97
Definition: fop.h:79
int(* updo_redo)(struct m0_dtm_update *updt)
Definition: update.h:84