Motr  M0
rm_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 #pragma once
23 
24 #ifndef __MOTR_RM_RM_INTERNAL_H__
25 #define __MOTR_RM_RM_INTERNAL_H__
26 
27 #include "lib/bob.h"
28 #include "lib/cookie.h"
29 #include "rm/rm.h"
30 
33 };
34 
39 };
40 
41 enum {
43 };
44 
62 };
63 
68 M0_INTERNAL int m0_rm_pin_add(struct m0_rm_incoming *in,
69  struct m0_rm_credit *credit,
70  uint32_t flags);
71 
78 M0_INTERNAL int granted_maybe_reserve(struct m0_rm_credit *granted,
79  struct m0_rm_credit *to_cache);
80 
106 M0_INTERNAL int m0_rm_borrow_commit(struct m0_rm_remote_incoming *bor);
107 
117 M0_INTERNAL int m0_rm_revoke_commit(struct m0_rm_remote_incoming *rvk);
118 
127 M0_INTERNAL int m0_rm_borrow_done(struct m0_rm_outgoing *out,
128  struct m0_rm_loan *loan);
129 
136 
143 int m0_rm_resource_owner_find(const struct m0_rm_resource *resource,
144  struct m0_rm_owner **owner);
145 
154 M0_INTERNAL int m0_rm_request_out(enum m0_rm_outgoing_type otype,
155  struct m0_rm_incoming *in,
156  struct m0_rm_loan *loan,
157  struct m0_rm_credit *credit,
158  struct m0_rm_remote *remote);
159 
160 M0_INTERNAL void m0_rm_outgoing_send(struct m0_rm_outgoing *outgoing);
161 
171 M0_INTERNAL int m0_rm_outgoing_init(struct m0_rm_outgoing *out,
172  enum m0_rm_outgoing_type req_type,
173  struct m0_rm_remote *other,
174  struct m0_rm_credit *credit);
175 
181 M0_INTERNAL void m0_rm_outgoing_fini(struct m0_rm_outgoing *out);
182 
186 M0_INTERNAL int m0_rm_loan_init(struct m0_rm_loan *loan,
187  const struct m0_rm_credit *credit,
188  struct m0_rm_remote *creditor);
189 
193 M0_INTERNAL void m0_rm_loan_fini(struct m0_rm_loan *loan);
194 
202 M0_INTERNAL int m0_rm_loan_alloc(struct m0_rm_loan **loan,
203  const struct m0_rm_credit *credit,
204  struct m0_rm_remote *creditor);
205 
209 M0_INTERNAL int m0_rm_owner_loan_debit(struct m0_rm_owner *owner,
210  struct m0_rm_loan *paid_loan,
211  struct m0_tl *list);
215 M0_INTERNAL int m0_rm_loan_settle(struct m0_rm_owner *owner,
216  struct m0_rm_loan *loan);
217 
222 M0_INTERNAL void m0_rm_outgoing_complete(struct m0_rm_outgoing *og);
223 
227 M0_INTERNAL int
229  struct m0_rm_remote *remote);
230 
239 M0_TL_DESCR_DECLARE(res, extern);
240 M0_TL_DECLARE(res, M0_INTERNAL, struct m0_rm_resource);
241 
242 M0_TL_DESCR_DECLARE(m0_rm_ur, extern);
243 M0_TL_DECLARE(m0_rm_ur, M0_INTERNAL, struct m0_rm_credit);
244 
245 M0_TL_DESCR_DECLARE(m0_remotes, extern);
246 M0_TL_DECLARE(m0_remotes, M0_INTERNAL, struct m0_rm_remote);
247 
248 M0_TL_DESCR_DECLARE(m0_owners, extern);
249 M0_TL_DECLARE(m0_owners, M0_INTERNAL, struct m0_rm_owner);
250 
251 M0_TL_DESCR_DECLARE(pr, extern);
252 M0_TL_DECLARE(pr, M0_INTERNAL, struct m0_rm_pin);
253 
254 M0_TL_DESCR_DECLARE(pi, extern);
255 M0_TL_DECLARE(pi, M0_INTERNAL, struct m0_rm_pin);
256 
257 M0_EXTERN const struct m0_bob_type loan_bob;
258 M0_BOB_DECLARE(M0_INTERNAL, m0_rm_loan);
259 
263 #define RM_OWNER_LISTS_FOR(owner, expr) \
264 ({ \
265  struct m0_rm_owner *__o = (owner); \
266  int __i; \
267  int __j; \
268  \
269  (expr)(&__o->ro_borrowed); \
270  (expr)(&__o->ro_sublet); \
271  \
272  for (__i = 0; __i < ARRAY_SIZE(__o->ro_owned); __i++) \
273  (expr)(&__o->ro_owned[__i]); \
274  \
275  for (__i = 0; __i < ARRAY_SIZE(__o->ro_incoming); __i++) { \
276  for (__j = 0; __j < ARRAY_SIZE(__o->ro_incoming[__i]); __j++) \
277  (expr)(&__o->ro_incoming[__i][__j]); \
278  } \
279  \
280  for (__i = 0; __i < ARRAY_SIZE(__o->ro_outgoing); __i++) \
281  (expr)(&__o->ro_outgoing[__i]); \
282 })
283 
284 static inline enum m0_rm_incoming_state
286 {
287  return (enum m0_rm_incoming_state)in->rin_sm.sm_state;
288 }
289 
290 static inline struct m0_rm_resource *
292 {
293  return in->rin_want.cr_owner->ro_resource;
294 }
295 
296 static inline enum m0_rm_owner_state
297 owner_state(const struct m0_rm_owner *owner)
298 {
299  return (enum m0_rm_owner_state)owner->ro_sm.sm_state;
300 }
301 
302 static inline struct m0_sm_group *
304 {
305  return &res->r_type->rt_sm_grp;
306 }
307 
308 static inline struct m0_sm_group *
309 owner_grp(const struct m0_rm_owner *owner)
310 {
311  return resource_grp(owner->ro_resource);
312 }
313 
320 M0_INTERNAL struct m0_rm_remote *
322 
323 /* __MOTR_RM_RM_INTERNAL_H__ */
324 #endif
325 
326 /*
327  * Local variables:
328  * c-indentation-style: "K&R"
329  * c-basic-offset: 8
330  * tab-width: 8
331  * fill-column: 80
332  * scroll-step: 1
333  * End:
334  */
M0_INTERNAL int m0_rm_outgoing_init(struct m0_rm_outgoing *out, enum m0_rm_outgoing_type req_type, struct m0_rm_remote *other, struct m0_rm_credit *credit)
Definition: rm.c:1150
int m0_rm_resource_owner_find(const struct m0_rm_resource *resource, struct m0_rm_owner **owner)
static struct m0_list list
Definition: list.c:144
int const char const void size_t int flags
Definition: dir.c:328
M0_INTERNAL void m0_rm_outgoing_send(struct m0_rm_outgoing *outgoing)
Definition: rm_fops.c:273
M0_INTERNAL int m0_rm_owner_loan_debit(struct m0_rm_owner *owner, struct m0_rm_loan *paid_loan, struct m0_tl *list)
Definition: rm.c:2690
struct m0_cookie ri_rem_owner_cookie
Definition: rm_internal.h:59
static struct m0_rm_remote creditor
Definition: file.c:95
struct m0_cookie ri_loan_cookie
Definition: rm_internal.h:60
m0_rm_outgoing_type
Definition: rm.h:1504
m0_rm_owner_state
Definition: rm.h:810
M0_INTERNAL int m0_rm_reverse_session_get(struct m0_rm_remote_incoming *rem_in, struct m0_rm_remote *remote)
Definition: rm_foms.c:355
int m0_rm_revoke_done(struct m0_rm_outgoing *out)
struct m0_rm_credit rin_want
Definition: rm.h:1450
M0_INTERNAL int m0_rm_loan_init(struct m0_rm_loan *loan, const struct m0_rm_credit *credit, struct m0_rm_remote *creditor)
Definition: rm.c:1235
struct m0_cookie ri_owner_cookie
Definition: rm_internal.h:55
struct m0_rm_owner * cr_owner
Definition: rm.h:501
struct m0_sm rin_sm
Definition: rm.h:1436
struct m0_sm ro_sm
Definition: rm.h:1005
M0_INTERNAL int m0_rm_loan_settle(struct m0_rm_owner *owner, struct m0_rm_loan *loan)
Definition: rm.c:2818
static enum m0_rm_owner_state owner_state(const struct m0_rm_owner *owner)
Definition: rm_internal.h:297
m0_rm_incoming_state
Definition: rm.h:1134
static enum m0_rm_incoming_state incoming_state(const struct m0_rm_incoming *in)
Definition: rm_internal.h:285
Definition: tlist.h:251
M0_BOB_DECLARE(M0_INTERNAL, m0_rm_loan)
M0_INTERNAL int m0_rm_pin_add(struct m0_rm_incoming *in, struct m0_rm_credit *credit, uint32_t flags)
Definition: rm.c:3198
struct m0_pdclust_instance pi
Definition: fd.c:107
M0_INTERNAL int m0_rm_borrow_done(struct m0_rm_outgoing *out, struct m0_rm_loan *loan)
static struct m0_sm_group * owner_grp(const struct m0_rm_owner *owner)
Definition: rm_internal.h:309
static struct m0_sm_group * resource_grp(const struct m0_rm_resource *res)
Definition: rm_internal.h:303
m0_rwlock_credit
Definition: rm_internal.h:36
static struct m0_rm_resource * incoming_to_resource(struct m0_rm_incoming *in)
Definition: rm_internal.h:291
M0_INTERNAL int granted_maybe_reserve(struct m0_rm_credit *granted, struct m0_rm_credit *to_cache)
Definition: rm.c:2750
M0_INTERNAL int m0_rm_revoke_commit(struct m0_rm_remote_incoming *rvk)
Definition: rm.c:1615
M0_INTERNAL void m0_rm_loan_fini(struct m0_rm_loan *loan)
Definition: rm.c:1257
struct m0_rm_incoming ri_incoming
Definition: rm_internal.h:50
m0_file_credit
Definition: rm_internal.h:31
M0_INTERNAL void m0_rm_outgoing_complete(struct m0_rm_outgoing *og)
Definition: rm.c:2465
static struct m0_rm_remote * remote
Definition: rm_fops.c:35
M0_TL_DECLARE(res, M0_INTERNAL, struct m0_rm_resource)
M0_INTERNAL int m0_rm_loan_alloc(struct m0_rm_loan **loan, const struct m0_rm_credit *credit, struct m0_rm_remote *creditor)
Definition: rm.c:1183
M0_INTERNAL int m0_rm_request_out(enum m0_rm_outgoing_type otype, struct m0_rm_incoming *in, struct m0_rm_loan *loan, struct m0_rm_credit *credit, struct m0_rm_remote *remote)
Definition: rm_fops.c:354
#define out(...)
Definition: gen.c:41
M0_TL_DESCR_DECLARE(res, extern)
M0_INTERNAL struct m0_rm_remote * m0_rm_remote_find(struct m0_rm_remote_incoming *rem_in)
Definition: rm.c:1366
M0_EXTERN const struct m0_bob_type loan_bob
Definition: rm_internal.h:257
struct m0_uint128 ri_group_id
Definition: rm_internal.h:61
uint32_t sm_state
Definition: sm.h:307
M0_INTERNAL int m0_rm_borrow_commit(struct m0_rm_remote_incoming *bor)
Definition: rm.c:1564
Definition: rm.h:1675
struct m0_rm_resource * ro_resource
Definition: rm.h:1015
M0_INTERNAL void m0_rm_outgoing_fini(struct m0_rm_outgoing *out)
Definition: rm.c:1166