Motr  M0
ag.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 #pragma once
24 
25 #ifndef __MOTR_CM_AG_H__
26 #define __MOTR_CM_AG_H__
27 
28 #include "lib/atomic.h"
29 #include "lib/types.h"
30 #include "lib/types_xc.h"
31 #include "lib/tlist.h"
32 #include "lib/mutex.h"
33 #include "lib/refs.h"
34 
35 #include "sm/sm.h"
36 
44 struct m0_cm_cp;
45 struct m0_cm_proxy;
46 struct m0_cm_sw;
47 
49 struct m0_cm_ag_id {
50  struct m0_uint128 ai_hi;
51  struct m0_uint128 ai_lo;
52 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
53 
54 #define M0_AG_F U128X_F "::" U128X_F
55 #define M0_AG_P(ag) U128_P(&((ag)->ai_hi)), U128_P(&((ag)->ai_lo))
56 
57 #define ID_LOG(prefix, id) M0_LOG(M0_DEBUG, prefix "=["M0_AG_F"]", M0_AG_P(id))
58 #define ID_INCOMING_LOG(prefix, id, has_incoming) \
59  M0_LOG(M0_DEBUG, prefix "=["M0_AG_F"] has incoming: %d", \
60  M0_AG_P(id), !!(has_incoming));
61 
62 #define GRP_END_MARK_ID (struct m0_cm_ag_id) { \
63  .ai_hi = M0_UINT128((uint64_t)-1, (uint64_t)-1), \
64  .ai_lo = M0_UINT128((uint64_t)-1, (uint64_t)-1) \
65 }
66 
70  struct m0_cm *cag_cm;
71 
73 
75 
77 
79 
80  uint64_t cag_ref;
81 
86  uint64_t cag_cp_global_nr;
87 
92  uint64_t cag_cp_local_nr;
93 
96 
98  uint64_t cag_freed_cp_nr;
99 
102 
104 
107 
117 
125 
126  int cag_rc;
127 
128  uint64_t cag_magic;
129 };
130 
137  bool (*cago_ag_can_fini) (const struct m0_cm_aggr_group *ag);
138 
140  void (*cago_fini)(struct m0_cm_aggr_group *ag);
141 
146  uint64_t (*cago_local_cp_nr)(const struct m0_cm_aggr_group *ag);
147 
149  struct m0_cm_proxy *proxy);
150 
157  bool (*cago_is_frozen_on)(struct m0_cm_aggr_group *ag, struct m0_cm_proxy *proxy);
158 };
159 
160 extern struct m0_bob_type aggr_grps_bob;
161 
162 M0_INTERNAL void m0_cm_aggr_group_init(struct m0_cm_aggr_group *ag,
163  struct m0_cm *cm,
164  const struct m0_cm_ag_id *id,
165  bool has_incoming,
166  const struct m0_cm_aggr_group_ops
167  *ag_ops);
168 
169 M0_INTERNAL void m0_cm_aggr_group_fini(struct m0_cm_aggr_group *ag);
170 
171 /*
172  * Finalises the given aggregation group and also updates the sliding window.
173  * If there is no more data to be restructured, marks the operation as complete
174  * by invoking m0_cm_ops::cmo_complete().
175  */
176 M0_INTERNAL void m0_cm_aggr_group_fini_and_progress(struct m0_cm_aggr_group *ag);
184 M0_INTERNAL int m0_cm_ag_id_cmp(const struct m0_cm_ag_id *id0,
185  const struct m0_cm_ag_id *id1);
186 
187 M0_INTERNAL void m0_cm_ag_id_copy(struct m0_cm_ag_id *dst,
188  const struct m0_cm_ag_id *src);
189 
190 M0_INTERNAL bool m0_cm_ag_id_is_set(const struct m0_cm_ag_id *id);
191 
214 M0_INTERNAL struct m0_cm_aggr_group *m0_cm_aggr_group_locate(struct m0_cm *cm,
215  const struct
216  m0_cm_ag_id *id,
217  bool has_incoming);
218 
225 M0_INTERNAL int m0_cm_aggr_group_alloc(struct m0_cm *cm,
226  const struct m0_cm_ag_id *id,
227  bool has_incoming,
228  struct m0_cm_aggr_group **out);
229 
242 M0_INTERNAL void m0_cm_aggr_group_add(struct m0_cm *cm,
243  struct m0_cm_aggr_group *ag,
244  bool has_incoming);
245 
252 M0_INTERNAL struct m0_cm_aggr_group *m0_cm_ag_in_hi(const struct m0_cm *cm);
253 
260 M0_INTERNAL struct m0_cm_aggr_group *m0_cm_ag_in_lo(const struct m0_cm *cm);
261 
262 M0_INTERNAL struct m0_cm_aggr_group *m0_cm_ag_out_hi(const struct m0_cm *cm);
263 
264 M0_INTERNAL struct m0_cm_aggr_group *m0_cm_ag_out_lo(const struct m0_cm *cm);
265 
272 M0_INTERNAL void m0_cm_ag_in_interval(const struct m0_cm *cm,
273  struct m0_cm_sw *in_interval);
274 
281 M0_INTERNAL void m0_cm_ag_out_interval(const struct m0_cm *cm,
282  struct m0_cm_sw *out_interval);
290 M0_INTERNAL int m0_cm_ag_advance(struct m0_cm *cm);
291 
292 M0_INTERNAL bool m0_cm_aggr_group_tlists_are_empty(struct m0_cm *cm);
293 
294 M0_INTERNAL void m0_cm_ag_lock(struct m0_cm_aggr_group *ag);
295 M0_INTERNAL void m0_cm_ag_unlock(struct m0_cm_aggr_group *ag);
296 M0_INTERNAL bool m0_cm_ag_is_locked(struct m0_cm_aggr_group *ag);
297 M0_INTERNAL void m0_cm_ag_get(struct m0_cm_aggr_group *ag);
298 M0_INTERNAL void m0_cm_ag_put(struct m0_cm_aggr_group *ag);
299 
300 M0_INTERNAL void m0_cm_ag_cp_add_locked(struct m0_cm_aggr_group *ag,
301  struct m0_cm_cp *cp);
302 M0_INTERNAL void m0_cm_ag_cp_add(struct m0_cm_aggr_group *ag, struct m0_cm_cp *cp);
303 M0_INTERNAL void m0_cm_ag_cp_del(struct m0_cm_aggr_group *ag, struct m0_cm_cp *cp);
304 M0_INTERNAL bool m0_cm_ag_has_pending_cps(struct m0_cm_aggr_group *ag);
305 M0_INTERNAL void m0_cm_ag_fini_post(struct m0_cm_aggr_group *ag);
306 M0_INTERNAL bool m0_cm_ag_can_fini(struct m0_cm_aggr_group *ag);
307 
308 M0_TL_DESCR_DECLARE(aggr_grps_in, M0_EXTERN);
309 M0_TL_DECLARE(aggr_grps_in, M0_INTERNAL, struct m0_cm_aggr_group);
310 
311 M0_TL_DESCR_DECLARE(aggr_grps_out, M0_EXTERN);
312 M0_TL_DECLARE(aggr_grps_out, M0_INTERNAL, struct m0_cm_aggr_group);
313 
316 #endif
317 /*
318  * Local variables:
319  * c-indentation-style: "K&R"
320  * c-basic-offset: 8
321  * tab-width: 8
322  * fill-column: 80
323  * scroll-step: 1
324  * End:
325  */
M0_INTERNAL void m0_cm_ag_id_copy(struct m0_cm_ag_id *dst, const struct m0_cm_ag_id *src)
Definition: ag.c:83
M0_INTERNAL struct m0_cm_aggr_group * m0_cm_ag_out_lo(const struct m0_cm *cm)
Definition: ag.c:420
M0_INTERNAL void m0_cm_ag_unlock(struct m0_cm_aggr_group *ag)
Definition: ag.c:63
M0_INTERNAL void m0_cm_ag_get(struct m0_cm_aggr_group *ag)
Definition: ag.c:488
M0_INTERNAL struct m0_cm_aggr_group * m0_cm_ag_out_hi(const struct m0_cm *cm)
Definition: ag.c:428
M0_INTERNAL void m0_cm_ag_cp_del(struct m0_cm_aggr_group *ag, struct m0_cm_cp *cp)
Definition: ag.c:520
M0_INTERNAL bool m0_cm_ag_has_pending_cps(struct m0_cm_aggr_group *ag)
uint64_t cag_magic
Definition: ag.h:128
bool(* cago_is_frozen_on)(struct m0_cm_aggr_group *ag, struct m0_cm_proxy *proxy)
Definition: ag.h:157
Definition: sw.h:45
M0_INTERNAL bool m0_cm_ag_can_fini(struct m0_cm_aggr_group *ag)
Definition: ag.c:538
static struct m0_bufvec dst
Definition: xform.c:61
M0_INTERNAL void m0_cm_aggr_group_add(struct m0_cm *cm, struct m0_cm_aggr_group *ag, bool has_incoming)
Definition: ag.c:301
Definition: cp.h:160
void(* cago_fini)(struct m0_cm_aggr_group *ag)
Definition: ag.h:140
M0_INTERNAL struct m0_cm_aggr_group * m0_cm_ag_in_hi(const struct m0_cm *cm)
Definition: ag.c:403
struct m0_cm_ag_id cag_id
Definition: ag.h:72
M0_INTERNAL void m0_cm_ag_in_interval(const struct m0_cm *cm, struct m0_cm_sw *in_interval)
Definition: ag.c:436
Definition: sm.h:504
M0_INTERNAL bool m0_cm_ag_id_is_set(const struct m0_cm_ag_id *id)
Definition: ag.c:95
uint64_t(* cago_local_cp_nr)(const struct m0_cm_aggr_group *ag)
Definition: ag.h:146
M0_INTERNAL void m0_cm_aggr_group_init(struct m0_cm_aggr_group *ag, struct m0_cm *cm, const struct m0_cm_ag_id *id, bool has_incoming, const struct m0_cm_aggr_group_ops *ag_ops)
Definition: ag.c:153
uint64_t cag_cp_global_nr
Definition: ag.h:86
static struct m0_uint128 id0[UPDATE_NR *DTM_NR]
Definition: dtx.c:57
static struct m0_cm * cm
Definition: cm.c:63
bool cag_is_frozen
Definition: ag.h:106
M0_INTERNAL void m0_cm_ag_cp_add(struct m0_cm_aggr_group *ag, struct m0_cm_cp *cp)
Definition: ag.c:510
M0_INTERNAL bool m0_cm_ag_is_locked(struct m0_cm_aggr_group *ag)
Definition: ag.c:68
M0_INTERNAL void m0_cm_ag_lock(struct m0_cm_aggr_group *ag)
Definition: ag.c:58
int cag_rc
Definition: ag.h:126
M0_INTERNAL int m0_cm_ag_id_cmp(const struct m0_cm_ag_id *id0, const struct m0_cm_ag_id *id1)
Definition: ag.c:73
struct m0_cm_aggr_group M0_XCA_DOMAIN
struct m0_bob_type aggr_grps_bob
M0_INTERNAL void m0_cm_ag_put(struct m0_cm_aggr_group *ag)
Definition: ag.c:495
struct m0_cm * cag_cm
Definition: ag.h:70
uint64_t cag_ref
Definition: ag.h:80
M0_INTERNAL struct m0_cm_aggr_group * m0_cm_aggr_group_locate(struct m0_cm *cm, const struct m0_cm_ag_id *id, bool has_incoming)
Definition: ag.c:262
M0_INTERNAL struct m0_cm_aggr_group * m0_cm_ag_in_lo(const struct m0_cm *cm)
Definition: ag.c:412
M0_TL_DESCR_DECLARE(aggr_grps_in, M0_EXTERN)
bool cag_is_finalising
Definition: ag.h:103
struct m0_sm_ast cag_fini_ast
Definition: ag.h:78
uint64_t cag_transformed_cp_nr
Definition: ag.h:95
bool(* cago_has_incoming_from)(struct m0_cm_aggr_group *ag, struct m0_cm_proxy *proxy)
Definition: ag.h:148
uint64_t cag_freed_cp_nr
Definition: ag.h:98
M0_INTERNAL void m0_cm_aggr_group_fini(struct m0_cm_aggr_group *ag)
Definition: ag.c:180
const struct m0_cm_aggr_group_ops * cag_ops
Definition: ag.h:74
M0_INTERNAL void m0_cm_ag_out_interval(const struct m0_cm *cm, struct m0_cm_sw *out_interval)
Definition: ag.c:454
M0_INTERNAL int m0_cm_ag_advance(struct m0_cm *cm)
Definition: ag.c:377
Definition: cm.h:166
M0_INTERNAL bool m0_cm_aggr_group_tlists_are_empty(struct m0_cm *cm)
Definition: ag.c:355
uint64_t cag_cp_local_nr
Definition: ag.h:92
struct m0_uint128 ai_hi
Definition: ag.h:50
struct m0_uint128 ai_lo
Definition: ag.h:51
M0_INTERNAL void m0_cm_ag_fini_post(struct m0_cm_aggr_group *ag)
Definition: ag.c:533
struct m0_mutex cag_mutex
Definition: ag.h:76
M0_INTERNAL int m0_cm_aggr_group_alloc(struct m0_cm *cm, const struct m0_cm_ag_id *id, bool has_incoming, struct m0_cm_aggr_group **out)
Definition: ag.c:330
bool cag_has_incoming
Definition: ag.h:101
#define out(...)
Definition: gen.c:41
M0_TL_DECLARE(aggr_grps_in, M0_INTERNAL, struct m0_cm_aggr_group)
bool(* cago_ag_can_fini)(const struct m0_cm_aggr_group *ag)
Definition: ag.h:137
Definition: mutex.h:47
M0_INTERNAL void m0_cm_ag_cp_add_locked(struct m0_cm_aggr_group *ag, struct m0_cm_cp *cp)
Definition: ag.c:502
struct m0_pdclust_src_addr src
Definition: fd.c:108
Definition: ag.h:49
M0_INTERNAL void m0_cm_aggr_group_fini_and_progress(struct m0_cm_aggr_group *ag)
Definition: ag.c:207
struct m0_tlink cag_cm_out_linkage
Definition: ag.h:124
struct m0_tlink cag_cm_in_linkage
Definition: ag.h:116