Motr  M0
nucleus.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_NUCLEUS_H__
27 #define __MOTR_DTM_NUCLEUS_H__
28 
29 
36 /* import */
37 #include "lib/mutex.h"
38 #include "lib/tlist.h"
39 #include "lib/types.h"
40 
41 /* export */
42 struct m0_dtm_nu;
43 struct m0_dtm_hi;
44 struct m0_dtm_op;
45 struct m0_dtm_up;
46 
47 struct m0_dtm_hi_ops;
49 
50 typedef uint64_t m0_dtm_ver_t;
51 
61 };
62 
63 struct m0_dtm_hi {
64  struct m0_dtm_nu *hi_nu;
65  uint64_t hi_flags;
67  const struct m0_dtm_hi_ops *hi_ops;
68  struct m0_tl hi_ups;
69 };
70 M0_INTERNAL bool m0_dtm_hi_invariant(const struct m0_dtm_hi *hi);
71 
73  M0_DHF_SHARED = 1ULL << 0,
74  M0_DHF_FULL = 1ULL << 1,
75  M0_DHF_OWNED = 1ULL << 2,
76  M0_DHF_BUSY = 1ULL << 3,
77  M0_DHF_LAST = 1ULL << 4
78 };
79 
80 struct m0_dtm_hi_ops {
81  void (*dho_release) (struct m0_dtm_hi *hi);
82 };
83 
90 };
91 
92 struct m0_dtm_up {
93  uint64_t up_magix;
98  struct m0_dtm_hi *up_hi;
100  struct m0_dtm_op *up_op;
102 };
103 M0_INTERNAL bool m0_dtm_up_invariant(const struct m0_dtm_up *up);
104 
105 struct m0_dtm_op {
106  struct m0_dtm_nu *op_nu;
107  struct m0_tl op_ups;
108  const struct m0_dtm_op_ops *op_ops;
109 };
110 M0_INTERNAL bool m0_dtm_op_invariant(const struct m0_dtm_op *op);
111 
113  void (*doo_ready)(struct m0_dtm_op *op);
114  void (*doo_late) (struct m0_dtm_op *op);
115  void (*doo_miser)(struct m0_dtm_op *op);
116 };
117 
118 struct m0_dtm_nu {
120 };
121 
122 M0_INTERNAL void m0_dtm_op_init (struct m0_dtm_op *op,
123  struct m0_dtm_nu *nu);
124 M0_INTERNAL void m0_dtm_op_prepared(const struct m0_dtm_op *op);
125 M0_INTERNAL void m0_dtm_op_done (const struct m0_dtm_op *op);
126 M0_INTERNAL void m0_dtm_op_close (const struct m0_dtm_op *op);
127 M0_INTERNAL void m0_dtm_op_del (struct m0_dtm_op *op);
128 M0_INTERNAL void m0_dtm_op_fini (struct m0_dtm_op *op);
129 
130 M0_INTERNAL void m0_dtm_hi_init (struct m0_dtm_hi *hi,
131  struct m0_dtm_nu *nu);
132 M0_INTERNAL void m0_dtm_hi_fini (struct m0_dtm_hi *hi);
133 
134 M0_INTERNAL void m0_dtm_up_init (struct m0_dtm_up *up,
135  struct m0_dtm_hi *hi,
136  struct m0_dtm_op *op,
137  enum m0_dtm_up_rule rule,
138  m0_dtm_ver_t ver, m0_dtm_ver_t orig_ver);
139 M0_INTERNAL void m0_dtm_up_ver_set (struct m0_dtm_up *up,
140  m0_dtm_ver_t ver, m0_dtm_ver_t orig_ver);
141 M0_INTERNAL void m0_dtm_nu_init (struct m0_dtm_nu *nu);
142 M0_INTERNAL void m0_dtm_nu_fini (struct m0_dtm_nu *nu);
143 
144 M0_INTERNAL struct m0_dtm_up *m0_dtm_up_prior(struct m0_dtm_up *up);
145 M0_INTERNAL struct m0_dtm_up *m0_dtm_up_later(struct m0_dtm_up *up);
146 
147 M0_INTERNAL void m0_dtm_nuclei_init(void);
148 M0_INTERNAL void m0_dtm_nuclei_fini(void);
149 
152 #endif /* __MOTR_DTM_NUCLEUS_H__ */
153 
154 
155 /*
156  * Local variables:
157  * c-indentation-style: "K&R"
158  * c-basic-offset: 8
159  * tab-width: 8
160  * fill-column: 80
161  * scroll-step: 1
162  * End:
163  */
164 /*
165  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
166  */
M0_INTERNAL void m0_dtm_op_init(struct m0_dtm_op *op, struct m0_dtm_nu *nu)
Definition: nucleus.c:77
M0_INTERNAL struct m0_dtm_up * m0_dtm_up_later(struct m0_dtm_up *up)
Definition: nucleus.c:380
enum m0_dtm_state up_state
Definition: nucleus.h:94
m0_dtm_ver_t up_orig_ver
Definition: nucleus.h:97
M0_INTERNAL void m0_dtm_op_done(const struct m0_dtm_op *op)
Definition: nucleus.c:108
m0_dtm_up_rule
Definition: nucleus.h:84
struct m0_dtm_nu * hi_nu
Definition: nucleus.h:64
struct m0_dtm_nu * op_nu
Definition: nucleus.h:106
m0_dtm_hi_flags
Definition: nucleus.h:72
M0_INTERNAL bool m0_dtm_hi_invariant(const struct m0_dtm_hi *hi)
Definition: nucleus.c:436
uint64_t hi_flags
Definition: nucleus.h:65
M0_INTERNAL bool m0_dtm_up_invariant(const struct m0_dtm_up *up)
Definition: nucleus.c:448
M0_INTERNAL void m0_dtm_nuclei_init(void)
Definition: nucleus.c:528
struct m0_dtm_hi * up_hi
Definition: nucleus.h:98
m0_dtm_ver_t up_ver
Definition: nucleus.h:96
void(* dho_release)(struct m0_dtm_hi *hi)
Definition: nucleus.h:81
struct m0_dtm_op * up_op
Definition: nucleus.h:100
M0_INTERNAL void m0_dtm_op_del(struct m0_dtm_op *op)
Definition: nucleus.c:128
op
Definition: libdemo.c:64
struct m0_tl hi_ups
Definition: nucleus.h:68
M0_INTERNAL void m0_dtm_nu_init(struct m0_dtm_nu *nu)
Definition: nucleus.c:365
const struct m0_dtm_op_ops * op_ops
Definition: nucleus.h:108
struct m0_mutex nu_lock
Definition: nucleus.h:119
uint64_t m0_dtm_ver_t
Definition: nucleus.h:48
Definition: tlist.h:251
static void nu(void)
Definition: nucleus.c:87
M0_INTERNAL bool m0_dtm_op_invariant(const struct m0_dtm_op *op)
Definition: nucleus.c:470
M0_INTERNAL void m0_dtm_up_ver_set(struct m0_dtm_up *up, m0_dtm_ver_t ver, m0_dtm_ver_t orig_ver)
void(* doo_miser)(struct m0_dtm_op *op)
Definition: nucleus.h:115
M0_INTERNAL void m0_dtm_hi_fini(struct m0_dtm_hi *hi)
Definition: nucleus.c:277
struct m0_tl op_ups
Definition: nucleus.h:107
enum m0_dtm_up_rule up_rule
Definition: nucleus.h:95
M0_INTERNAL void m0_dtm_op_close(const struct m0_dtm_op *op)
Definition: nucleus.c:84
void(* doo_ready)(struct m0_dtm_op *op)
Definition: nucleus.h:113
M0_INTERNAL void m0_dtm_nuclei_fini(void)
Definition: nucleus.c:534
M0_INTERNAL void m0_dtm_op_fini(struct m0_dtm_op *op)
Definition: nucleus.c:135
M0_INTERNAL struct m0_dtm_up * m0_dtm_up_prior(struct m0_dtm_up *up)
Definition: nucleus.c:375
struct m0_tlink up_op_linkage
Definition: nucleus.h:101
m0_dtm_ver_t hi_ver
Definition: nucleus.h:66
struct m0_tlink up_hi_linkage
Definition: nucleus.h:99
M0_INTERNAL void m0_dtm_up_init(struct m0_dtm_up *up, struct m0_dtm_hi *hi, struct m0_dtm_op *op, enum m0_dtm_up_rule rule, m0_dtm_ver_t ver, m0_dtm_ver_t orig_ver)
Definition: nucleus.c:286
M0_INTERNAL void m0_dtm_hi_init(struct m0_dtm_hi *hi, struct m0_dtm_nu *nu)
Definition: nucleus.c:268
uint64_t up_magix
Definition: nucleus.h:93
M0_INTERNAL void m0_dtm_nu_fini(struct m0_dtm_nu *nu)
Definition: nucleus.c:370
void(* doo_late)(struct m0_dtm_op *op)
Definition: nucleus.h:114
Definition: mutex.h:47
m0_dtm_state
Definition: nucleus.h:52
static void hi(void)
Definition: nucleus.c:93
M0_INTERNAL void m0_dtm_op_prepared(const struct m0_dtm_op *op)
Definition: nucleus.c:97
const struct m0_dtm_hi_ops * hi_ops
Definition: nucleus.h:67