Motr  M0
rm_fops.c
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 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_RM
24 #include "lib/trace.h"
25 
26 #include "lib/errno.h"
27 #include "lib/memory.h"
28 #include "lib/misc.h"
29 #include "lib/finject.h"
30 #include "rpc/item.h"
31 #include "rpc/rpc_opcodes.h"
32 #include "rpc/rpc.h"
33 #include "rm/rm.h"
34 #include "rm/rm_fops.h"
35 #include "rm/rm_foms.h"
36 #include "rm/rm_fops_xc.h"
37 #include "rm/rm_service.h"
38 #include "rm/rm_internal.h"
39 
40 /*
41  * Data structures.
42  */
43 /*
44  * Tracking structure for outgoing request.
45  */
46 struct rm_out {
48  struct m0_sm_ast ou_ast;
49  struct m0_fop ou_fop;
50 };
51 
55 static void rm_reply_process(struct m0_rpc_item *item);
56 static void rm_borrow_ast(struct m0_sm_group *grp, struct m0_sm_ast *ast);
57 static void rm_revoke_ast(struct m0_sm_group *grp, struct m0_sm_ast *ast);
58 static void rm_cancel_ast(struct m0_sm_group *grp, struct m0_sm_ast *ast);
59 
60 static const struct m0_rpc_item_ops rm_request_rpc_ops = {
62 };
63 
69 extern struct m0_sm_state_descr rm_req_phases[];
71 
77 
82 
83 /*
84  * Extern FOM params
85  */
86 extern const struct m0_fom_type_ops rm_borrow_fom_type_ops;
87 extern const struct m0_sm_conf borrow_sm_conf;
88 
89 extern const struct m0_fom_type_ops rm_revoke_fom_type_ops;
90 extern const struct m0_fom_type_ops rm_cancel_fom_type_ops;
91 extern const struct m0_sm_conf canoke_sm_conf;
92 
93 /*
94  * Allocate and initialise remote request tracking structure.
95  */
96 static int rm_out_create(struct rm_out **out,
97  enum m0_rm_outgoing_type otype,
98  struct m0_rm_remote *other,
99  struct m0_rm_credit *credit)
100 {
101  struct rm_out *outreq;
102  int rc;
103 
104  M0_ENTRY();
105  M0_PRE(out != NULL);
106  M0_PRE(other != NULL);
107 
108  M0_ALLOC_PTR(outreq);
109  if (outreq == NULL) {
110  rc = M0_ERR(-ENOMEM);
111  goto out;
112  }
113  rc = m0_rm_outgoing_init(&outreq->ou_req, otype, other, credit);
114  if (rc != 0)
115  m0_free(outreq);
116  *out = outreq;
117 out:
118  return M0_RC(rc);
119 }
120 
121 /*
122  * De-allocates the remote request tracking structure.
123  */
124 static void rm_out_release(struct rm_out *out)
125 {
126  m0_free(out);
127 }
128 
129 static void rm_fop_release(struct m0_ref *ref)
130 {
131  struct m0_fop *fop;
132  struct rm_out *out;
133 
134  M0_ENTRY();
135  M0_PRE(ref != NULL);
136  fop = container_of(ref, struct m0_fop, f_ref);
137  out = container_of(fop, struct rm_out, ou_fop);
138 
139  m0_fop_fini(fop);
141  M0_LEAVE();
142 }
143 
144 static void rm_out_destroy(struct rm_out *out)
145 {
146  M0_ENTRY();
147  m0_rm_outgoing_fini(&out->ou_req);
149  M0_LEAVE();
150 }
151 
152 static int fop_common_fill(struct rm_out *outreq,
153  struct m0_rm_incoming *in,
154  struct m0_rm_credit *credit,
155  struct m0_cookie *cookie,
156  struct m0_fop_type *fopt,
157  size_t offset,
158  void **data)
159 {
160  struct m0_rm_fop_req *req;
161  struct m0_fop *fop;
162  int rc;
163 
164  fop = &outreq->ou_fop;
167  if (rc == 0) {
168  *data = m0_fop_data(fop);
169  req = (struct m0_rm_fop_req *) (char *)*data + offset;
170  req->rrq_policy = in->rin_policy;
171  req->rrq_flags = in->rin_flags;
172  req->rrq_orig_time = in->rin_reserve.rrp_time;
173  req->rrq_orig_owner = in->rin_reserve.rrp_owner;
174  req->rrq_orig_seq = in->rin_reserve.rrp_seq;
175  /*
176  * Set RIF_LOCAL_WAIT for remote requests if none of the
177  * RIF_LOCAL_WAIT, RIF_LOCAL_TRY is set, because only local
178  * users may resolve conflicts by some other means.
179  */
180  if (!(in->rin_flags & WAIT_TRY_FLAGS))
181  req->rrq_flags |= RIF_LOCAL_WAIT;
182  req->rrq_owner.ow_cookie = *cookie;
184  &req->rrq_owner.ow_resource) ?:
185  m0_rm_credit_encode(credit,
186  &req->rrq_credit.cr_opaque);
187  } else {
188  m0_fop_fini(fop);
189  }
190 
191  return M0_RC(rc);
192 }
193 
194 static int borrow_fop_fill(struct rm_out *outreq,
195  struct m0_rm_incoming *in,
196  struct m0_rm_credit *credit)
197 {
198  struct m0_rm_fop_borrow *bfop;
199  struct m0_cookie cookie;
200  int rc;
201 
202  M0_ENTRY("creating borrow fop for incoming: %p credit value: %llu",
203  in, (long long unsigned) credit->cr_datum);
204  m0_cookie_init(&cookie, &in->rin_want.cr_owner->ro_id);
205  rc = fop_common_fill(outreq, in, credit, &cookie,
208  (void **)&bfop);
209 
210  if (rc == 0) {
211  struct m0_rm_remote *rem = in->rin_want.cr_owner->ro_creditor;
212 
213  /* Copy creditor cookie */
214  bfop->bo_creditor.ow_cookie = rem ? rem->rem_cookie :
216  bfop->bo_group_id = credit->cr_group_id;
217  }
218  return M0_RC(rc);
219 }
220 
221 static int revoke_fop_fill(struct rm_out *outreq,
222  struct m0_rm_incoming *in,
223  struct m0_rm_loan *loan,
224  struct m0_rm_remote *other,
225  struct m0_rm_credit *credit)
226 {
227  struct m0_rm_fop_revoke *rfop;
228  int rc = 0;
229 
230  M0_ENTRY("creating revoke fop for incoming: %p credit value: %llu",
231  in, (long long unsigned) credit->cr_datum);
232 
233  rc = fop_common_fill(outreq, in, credit, &other->rem_cookie,
236  (void **)&rfop);
237  if (rc == 0)
238  rfop->fr_loan.lo_cookie = loan->rl_cookie;
239 
240  return M0_RC(rc);
241 }
242 
243 static int cancel_fop_fill(struct rm_out *outreq,
244  struct m0_rm_loan *loan)
245 {
246  struct m0_rm_fop_cancel *cfop;
247  struct m0_fop *fop;
248  int rc;
249 
250  M0_ENTRY("creating cancel fop for credit value: %llu",
251  (long long unsigned) loan->rl_credit.cr_datum);
252 
253  fop = &outreq->ou_fop;
256  if (rc == 0) {
257  cfop = m0_fop_data(fop);
258  cfop->fc_loan.lo_cookie = loan->rl_cookie;
259  cfop->fc_creditor_cookie = loan->rl_other->rem_cookie;
260  } else {
261  m0_fop_fini(fop);
262  }
263  return M0_RC(rc);
264 }
265 
266 static void outreq_fini(struct rm_out *outreq, int rc)
267 {
268  outreq->ou_req.rog_rc = rc;
270  m0_fop_put_lock(&outreq->ou_fop);
271 }
272 
273 M0_INTERNAL void m0_rm_outgoing_send(struct m0_rm_outgoing *outgoing)
274 {
275  struct rm_out *outreq;
276  struct m0_rpc_item *item;
277  int rc;
278 
279  M0_ENTRY("outgoing: %p", outgoing);
280  M0_PRE(outgoing->rog_sent == false);
281 
282  outreq = M0_AMB(outreq, outgoing, ou_req);
283  M0_ASSERT(outreq->ou_ast.sa_cb == NULL);
284  M0_ASSERT(outreq->ou_fop.f_item.ri_session == NULL);
285 
286  switch (outgoing->rog_type) {
287  case M0_ROT_BORROW:
288  outreq->ou_ast.sa_cb = &rm_borrow_ast;
289  break;
290  case M0_ROT_REVOKE:
291  outreq->ou_ast.sa_cb = &rm_revoke_ast;
292  break;
293  case M0_ROT_CANCEL:
294  outreq->ou_ast.sa_cb = &rm_cancel_ast;
295  break;
296  default:
297  break;
298  }
299 
300  item = &outreq->ou_fop.f_item;
303 
304  M0_LOG(M0_DEBUG, "%p[%u] sending request:%p over session: %p",
305  item, item->ri_type->rit_opcode, outreq, item->ri_session);
306 
307  if (M0_FI_ENABLED("no-rpc"))
308  return;
309 
310  rc = m0_rpc_post(item);
311  if (rc != 0) {
312  M0_LOG(M0_DEBUG, "%p[%u], request %p could not be posted, "
313  "rc %d", item, item->ri_type->rit_opcode, outgoing, rc);
316  &outreq->ou_ast);
317  outreq_fini(outreq, rc);
318  return;
319  }
320  outgoing->rog_sent = true;
321  M0_LEAVE();
322 }
323 
324 static void outgoing_queue(enum m0_rm_outgoing_type otype,
325  struct m0_rm_owner *owner,
326  struct rm_out *outreq,
327  struct m0_rm_incoming *in,
328  struct m0_rm_remote *other)
329 {
330  M0_PRE(owner != NULL);
331 
332  if (in != NULL)
333  m0_rm_pin_add(in, &outreq->ou_req.rog_want.rl_credit,
334  M0_RPF_TRACK);
335 
336  m0_rm_ur_tlist_add(&owner->ro_outgoing[OQS_GROUND],
337  &outreq->ou_req.rog_want.rl_credit);
338  /*
339  * It is possible that remote session is not yet established
340  * when revoke request should be sent.
341  * In this case let's wait till session is established and
342  * send revoke request from rev_session_clink_cb callback.
343  *
344  * The race is possible if m0_clink_is_armed() return false, but
345  * rev_session_clink_cb() call is not finished yet. In that case
346  * outgoing request could be sent twice.
347  * Flag m0_rm_outgoing::rog_sent is used to prevent that.
348  */
349  if (otype != M0_ROT_REVOKE ||
351  m0_rm_outgoing_send(&outreq->ou_req);
352 }
353 
354 M0_INTERNAL int m0_rm_request_out(enum m0_rm_outgoing_type otype,
355  struct m0_rm_incoming *in,
356  struct m0_rm_loan *loan,
357  struct m0_rm_credit *credit,
358  struct m0_rm_remote *other)
359 {
360  struct rm_out *outreq;
361  int rc;
362 
363  M0_ENTRY("sending request type: %d for incoming: %p credit value: %llu",
364  otype, in, (long long unsigned) credit->cr_datum);
365  M0_PRE(M0_IN(otype, (M0_ROT_BORROW, M0_ROT_REVOKE, M0_ROT_CANCEL)));
366  M0_PRE(ergo(M0_IN(otype, (M0_ROT_REVOKE, M0_ROT_CANCEL)),
367  loan != NULL));
368 
369  rc = rm_out_create(&outreq, otype, other, credit);
370  if (rc != 0)
371  return M0_ERR(rc);
372 
373  if (loan != NULL)
374  outreq->ou_req.rog_want.rl_cookie = loan->rl_cookie;
375 
376  switch (otype) {
377  case M0_ROT_BORROW:
378  rc = borrow_fop_fill(outreq, in, credit);
379  break;
380  case M0_ROT_REVOKE:
381  rc = revoke_fop_fill(outreq, in, loan, other, credit);
382  break;
383  case M0_ROT_CANCEL:
384  rc = cancel_fop_fill(outreq, loan);
385  break;
386  default:
387  rc = -EINVAL;
388  M0_IMPOSSIBLE("Unrecognized RM request");
389  }
390 
391  if (rc == 0) {
392  outgoing_queue(otype, credit->cr_owner, outreq, in, other);
393  } else {
394  M0_LOG(M0_ERROR, "filling fop failed: rc=%d", rc);
395  rm_out_destroy(outreq);
396  }
397  return M0_RC(rc);
398 }
399 
400 static void rm_borrow_ast(struct m0_sm_group *grp, struct m0_sm_ast *ast)
401 {
402  struct rm_out *outreq = M0_AMB(outreq, ast, ou_ast);
403  const struct m0_rpc_item *item = &outreq->ou_fop.f_item;
404  struct m0_rm_fop_borrow_rep *borrow_reply = NULL;
405  struct m0_rm_owner *owner;
406  struct m0_rm_loan *loan = NULL;
407  struct m0_rm_credit *credit;
408  struct m0_rm_credit *bcredit;
409  struct m0_buf buf;
410  int rc;
411 
412  M0_ENTRY();
414 
416  if (rc == 0) {
417  borrow_reply = m0_fop_data(m0_rpc_item_to_fop(item->ri_reply));
418  rc = borrow_reply->br_rc;
419  }
420  if (rc != 0) {
421  M0_LOG(M0_ERROR, "Borrow request %p failed: rc=%d", outreq, rc);
422  goto out;
423  }
424  M0_ASSERT(borrow_reply != NULL);
425  bcredit = &outreq->ou_req.rog_want.rl_credit;
426  owner = bcredit->cr_owner;
428  owner->ro_creditor->rem_cookie =
429  borrow_reply->br_creditor_cookie;
430  /* Get the data for a credit from the FOP */
431  m0_buf_init(&buf, borrow_reply->br_credit.cr_opaque.b_addr,
432  borrow_reply->br_credit.cr_opaque.b_nob);
433  rc = m0_rm_credit_decode(bcredit, &buf);
434  if (rc != 0) {
435  M0_LOG(M0_ERROR, "credit decode for request %p failed: rc=%d",
436  outreq, rc);
437  goto out;
438  }
439  rc = m0_rm_credit_dup(bcredit, &credit) ?:
440  m0_rm_loan_alloc(&loan, bcredit, owner->ro_creditor) ?:
441  granted_maybe_reserve(bcredit, credit);
442  if (rc != 0) {
443  M0_LOG(M0_ERROR, "borrowed loan/credit allocation request %p"
444  " failed: rc=%d", outreq, rc);
445  m0_free(loan);
446  m0_free(credit);
447  goto out;
448  }
449  M0_LOG(M0_INFO, "borrow request %p successful; credit value: %llu",
450  outreq, (long long unsigned)credit->cr_datum);
451  loan->rl_cookie = borrow_reply->br_loan.lo_cookie;
452  /* Add loan to the borrowed list. */
453  m0_rm_ur_tlist_add(&owner->ro_borrowed, &loan->rl_credit);
454  /* Add credit to the CACHED list. */
455  m0_rm_ur_tlist_add(&owner->ro_owned[OWOS_CACHED], credit);
456 out:
457  outreq_fini(outreq, rc);
458  M0_LEAVE();
459 }
460 
461 static void rm_revoke_ast(struct m0_sm_group *grp, struct m0_sm_ast *ast)
462 {
463  struct rm_out *outreq = M0_AMB(outreq, ast, ou_ast);
464  const struct m0_rpc_item *item = &outreq->ou_fop.f_item;
465  struct m0_rm_loan *loan;
466  struct m0_rm_fop_revoke_rep *revoke_reply;
467  int rc;
468 
469  M0_ENTRY();
471 
472  loan = &outreq->ou_req.rog_want;
473  if (loan->rl_other->rem_dead) {
474  /*
475  * Remote owner is considered failed by HA. All loans are
476  * already revoked in rm_remote_death_ast(). Set result code to
477  * SUCCESS, since loan is already settled and goto out to
478  * not try settle it once more.
479  */
480  rc = 0;
481  goto out;
482  }
484  if (rc == 0) {
485  revoke_reply = m0_fop_data(m0_rpc_item_to_fop(item->ri_reply));
486  rc = revoke_reply->rr_rc;
487  }
488  if (rc != 0) {
489  M0_LOG(M0_ERROR, "revoke request %p failed: rc=%d", outreq, rc);
490  goto out;
491  }
492  rc = m0_rm_loan_settle(loan->rl_credit.cr_owner, loan);
493 out:
494  outreq_fini(outreq, rc);
495  M0_LEAVE();
496 }
497 
498 static void rm_cancel_ast(struct m0_sm_group *grp, struct m0_sm_ast *ast)
499 {
500  struct rm_out *outreq = M0_AMB(outreq, ast, ou_ast);
501  struct m0_rm_owner *owner;
502  struct m0_rm_loan *loan;
503  struct m0_rm_credit *credit;
504  int rc;
505 
506  M0_ENTRY();
508 
509  rc = m0_rpc_item_error(&outreq->ou_fop.f_item);
510  if (rc != 0) {
511  M0_LOG(M0_ERROR, "cancel request %p failed: rc=%d", outreq, rc);
512  goto out;
513  }
514  owner = outreq->ou_req.rog_want.rl_credit.cr_owner;
515  loan = &outreq->ou_req.rog_want;
516  m0_tl_for (m0_rm_ur, &owner->ro_owned[OWOS_CACHED], credit) {
517  if (credit->cr_ops->cro_intersects(credit, &loan->rl_credit))
518  m0_rm_ur_tlist_del(credit);
519  } m0_tl_endfor;
520  rc = m0_rm_owner_loan_debit(owner, loan, &owner->ro_borrowed);
521 out:
522  outreq_fini(outreq, rc);
523  M0_LEAVE();
524 }
525 
526 static void rm_reply_process(struct m0_rpc_item *item)
527 {
528  struct m0_rm_owner *owner;
529  struct rm_out *outreq;
530 
531  M0_ENTRY();
532  M0_PRE(item != NULL);
533 
534  /*
535  * Note that RPC errors are handled in the corresponding AST callback:
536  * rm_borrow_ast(), rm_revoke_ast(), rm_cancel_ast().
537  */
539  outreq = M0_AMB(outreq, m0_rpc_item_to_fop(item), ou_fop);
540  owner = outreq->ou_req.rog_want.rl_credit.cr_owner;
541 
542  M0_ASSERT(outreq->ou_ast.sa_cb != NULL);
543  m0_sm_ast_post(owner_grp(owner), &outreq->ou_ast);
544  M0_LEAVE();
545 }
546 
547 M0_INTERNAL void m0_rm_fop_fini(void)
548 {
554 }
555 M0_EXPORTED(m0_rm_fop_fini);
556 
561 M0_INTERNAL int m0_rm_fop_init(void)
562 {
564  .name = "Credit Borrow",
566  .xt = m0_rm_fop_borrow_xc,
567  .sm = &borrow_sm_conf,
568  .fom_ops = &rm_borrow_fom_type_ops,
569  .svc_type = &m0_rms_type,
570  .rpc_flags = M0_RPC_ITEM_TYPE_REQUEST);
572  .name = "Credit Borrow Reply",
574  .xt = m0_rm_fop_borrow_rep_xc,
575  .svc_type = &m0_rpc_service_type,
576  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
578  .name = "Credit Revoke",
580  .xt = m0_rm_fop_revoke_xc,
581  .sm = &canoke_sm_conf,
582  .fom_ops = &rm_revoke_fom_type_ops,
583  .svc_type = &m0_rms_type,
584  .rpc_flags = M0_RPC_ITEM_TYPE_REQUEST);
586  .name = "Credit Revoke Reply",
588  .xt = m0_rm_fop_revoke_rep_xc,
589  .svc_type = &m0_rpc_service_type,
590  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
592  .name = "Credit Return (Cancel)",
594  .xt = m0_rm_fop_cancel_xc,
595  .sm = &canoke_sm_conf,
596  .fom_ops = &rm_cancel_fom_type_ops,
597  .svc_type = &m0_rms_type,
598  .rpc_flags = M0_RPC_ITEM_TYPE_REQUEST);
599  return 0;
600 }
601 M0_EXPORTED(m0_rm_fop_init);
602 
603 #undef M0_TRACE_SUBSYSTEM
604 
605 /*
606  * Local variables:
607  * c-indentation-style: "K&R"
608  * c-basic-offset: 8
609  * tab-width: 8
610  * fill-column: 80
611  * scroll-step: 1
612  * End:
613  */
const struct m0_rm_credit_ops * cr_ops
Definition: rm.h:502
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
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 *other)
Definition: rm_fops.c:354
M0_INTERNAL int m0_rpc_post(struct m0_rpc_item *item)
Definition: rpc.c:63
struct m0_rm_fop_credit br_credit
Definition: rm_fops.h:112
uint32_t rit_opcode
Definition: item.h:474
static void rm_fop_release(struct m0_ref *ref)
Definition: rm_fops.c:129
struct m0_rm_fop_loan fc_loan
Definition: rm_fops.h:140
int32_t rog_rc
Definition: rm.h:1548
#define M0_PRE(cond)
static void outreq_fini(struct rm_out *outreq, int rc)
Definition: rm_fops.c:266
uint64_t cr_datum
Definition: rm.h:514
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
#define NULL
Definition: misc.h:38
bool(* cro_intersects)(const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
Definition: rm.h:579
struct m0_clink rem_rev_sess_clink
Definition: rm.h:754
struct m0_rm_remote * ro_creditor
Definition: rm.h:1026
#define ergo(a, b)
Definition: misc.h:293
void(* sa_cb)(struct m0_sm_group *grp, struct m0_sm_ast *)
Definition: sm.h:506
#define M0_FOP_TYPE_INIT(ft,...)
Definition: fop.h:307
Definition: sm.h:350
void * b_addr
Definition: buf.h:39
M0_INTERNAL int m0_rm_credit_decode(struct m0_rm_credit *credit, struct m0_buf *buf)
Definition: rm.c:3376
static struct io_request req
Definition: file.c:100
struct m0_fid rrp_owner
Definition: rm.h:1255
static struct m0_sm_group * grp
Definition: bytecount.c:38
M0_INTERNAL void m0_fop_init(struct m0_fop *fop, struct m0_fop_type *fopt, void *data, void(*fop_release)(struct m0_ref *))
Definition: fop.c:79
#define M0_LOG(level,...)
Definition: trace.h:167
M0_LEAVE()
struct m0_cookie rl_cookie
Definition: rm.h:1110
M0_INTERNAL void m0_sm_ast_post(struct m0_sm_group *grp, struct m0_sm_ast *ast)
Definition: sm.c:135
enum m0_rm_incoming_policy rin_policy
Definition: rm.h:1447
M0_INTERNAL int m0_rm_credit_dup(const struct m0_rm_credit *src_credit, struct m0_rm_credit **dest_credit)
Definition: rm.c:3308
static void rm_out_release(struct rm_out *out)
Definition: rm_fops.c:124
m0_rm_outgoing_type
Definition: rm.h:1504
M0_INTERNAL void m0_buf_init(struct m0_buf *buf, void *data, uint32_t nob)
Definition: buf.c:37
static void rm_revoke_ast(struct m0_sm_group *grp, struct m0_sm_ast *ast)
Definition: rm_fops.c:461
struct m0_bufvec data
Definition: di.c:40
int32_t ri_error
Definition: item.h:161
void * m0_fop_data(const struct m0_fop *fop)
Definition: fop.c:220
void m0_fop_type_fini(struct m0_fop_type *fopt)
Definition: fop.c:232
struct m0_fop_type m0_rm_fop_borrow_rep_fopt
Definition: rm_fops.c:68
const struct m0_fom_type_ops rm_cancel_fom_type_ops
Definition: rm_foms.c:120
m0_time_t rrp_time
Definition: rm.h:1251
M0_INTERNAL bool m0_clink_is_armed(const struct m0_clink *link)
Definition: chan.c:303
uint64_t ro_id
Definition: rm.h:1066
Definition: sm.h:504
static int borrow_fop_fill(struct rm_out *outreq, struct m0_rm_incoming *in, struct m0_rm_credit *credit)
Definition: rm_fops.c:194
const struct m0_fom_type_ops rm_borrow_fom_type_ops
Definition: rm_foms.c:94
#define container_of(ptr, type, member)
Definition: misc.h:33
struct m0_rm_credit rin_want
Definition: rm.h:1450
struct m0_rpc_session * rem_session
Definition: rm.h:755
static struct m0_xcode_type ** xt[]
Definition: protocol.c:64
static struct m0_rpc_item * item
Definition: item.c:56
M0_INTERNAL int m0_rm_credit_encode(struct m0_rm_credit *credit, struct m0_buf *buf)
Definition: rm.c:3350
struct m0_rm_owner * cr_owner
Definition: rm.h:501
Definition: sock.c:887
struct m0_cookie br_creditor_cookie
Definition: rm_fops.h:120
#define m0_tl_endfor
Definition: tlist.h:700
return M0_RC(rc)
struct m0_cookie lo_cookie
Definition: rm_fops.h:82
uint64_t rrp_seq
Definition: rm.h:1265
#define M0_ENTRY(...)
Definition: trace.h:170
Definition: buf.h:37
static struct m0_sm_ast ast[NR]
Definition: locality.c:44
M0_INTERNAL int m0_rm_resource_encode(struct m0_rm_resource *res, struct m0_buf *buf)
Definition: rm.c:393
int opcode
Definition: crate.c:301
struct m0_rm_credit rl_credit
Definition: rm.h:1099
M0_INTERNAL void m0_rm_outgoing_send(struct m0_rm_outgoing *outgoing)
Definition: rm_fops.c:273
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL int m0_rm_loan_settle(struct m0_rm_owner *owner, struct m0_rm_loan *loan)
Definition: rm.c:2818
struct m0_tl ro_borrowed
Definition: rm.h:1033
Definition: trace.h:482
const char * name
Definition: trace.c:110
#define M0_AMB(obj, ptr, field)
Definition: misc.h:320
Definition: refs.h:34
static const struct m0_rpc_item_ops rm_request_rpc_ops
Definition: rm_fops.c:60
static int fop_common_fill(struct rm_out *outreq, struct m0_rm_incoming *in, struct m0_rm_credit *credit, struct m0_cookie *cookie, struct m0_fop_type *fopt, size_t offset, void **data)
Definition: rm_fops.c:152
m0_bcount_t b_nob
Definition: buf.h:38
#define M0_ASSERT(cond)
Definition: rm_fops.c:46
M0_INTERNAL bool m0_mutex_is_locked(const struct m0_mutex *mutex)
Definition: mutex.c:95
static void rm_borrow_ast(struct m0_sm_group *grp, struct m0_sm_ast *ast)
Definition: rm_fops.c:400
struct m0_tl ro_outgoing[OQS_NR]
Definition: rm.h:1058
struct m0_buf cr_opaque
Definition: rm_fops.h:86
struct m0_sm_state_descr rm_req_phases[]
Definition: rm_foms.c:124
static void rm_out_destroy(struct rm_out *out)
Definition: rm_fops.c:144
static int cancel_fop_fill(struct rm_out *outreq, struct m0_rm_loan *loan)
Definition: rm_fops.c:243
const struct m0_rpc_item_type * ri_type
Definition: item.h:200
struct m0_rpc_item * ri_reply
Definition: item.h:163
M0_INTERNAL int m0_rm_pin_add(struct m0_rm_incoming *in, struct m0_rm_credit *credit, uint32_t flags)
Definition: rm.c:3198
static struct m0_sm_group * owner_grp(const struct m0_rm_owner *owner)
Definition: rm_internal.h:309
const struct m0_fom_type_ops rm_revoke_fom_type_ops
Definition: rm_foms.c:107
static m0_bindex_t offset
Definition: dump.c:173
struct m0_rm_remote * rl_other
Definition: rm.h:1105
M0_INTERNAL int m0_fop_data_alloc(struct m0_fop *fop)
Definition: fop.c:71
M0_INTERNAL void m0_fop_fini(struct m0_fop *fop)
Definition: fop.c:136
static struct m0_rm_resource * incoming_to_resource(struct m0_rm_incoming *in)
Definition: rm_internal.h:291
struct m0_mutex s_lock
Definition: sm.h:514
M0_INTERNAL int granted_maybe_reserve(struct m0_rm_credit *granted, struct m0_rm_credit *to_cache)
Definition: rm.c:2750
const struct m0_sm_conf borrow_sm_conf
Definition: rm_foms.c:151
void(* rio_replied)(struct m0_rpc_item *item)
Definition: item.h:300
struct m0_reqh_service_type m0_rms_type
Definition: rm_service.c:69
int32_t m0_rpc_item_error(const struct m0_rpc_item *item)
Definition: item.c:973
struct m0_rm_fop_req bo_base
Definition: rm_fops.h:602
static int revoke_fop_fill(struct rm_out *outreq, struct m0_rm_incoming *in, struct m0_rm_loan *loan, struct m0_rm_remote *other, struct m0_rm_credit *credit)
Definition: rm_fops.c:221
static int rm_out_create(struct rm_out **out, enum m0_rm_outgoing_type otype, struct m0_rm_remote *other, struct m0_rm_credit *credit)
Definition: rm_fops.c:96
struct m0_reqh_service_type m0_rpc_service_type
Definition: service.c:120
M0_INTERNAL int m0_rm_fop_init(void)
Definition: rm_fops.c:561
#define M0_FI_ENABLED(tag)
Definition: finject.h:231
struct m0_cookie fc_creditor_cookie
Definition: rm_fops.h:141
static void rm_reply_process(struct m0_rpc_item *item)
Definition: rm_fops.c:526
struct m0_rm_fop_loan br_loan
Definition: rm_fops.h:111
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
const struct m0_rpc_item_ops * ri_ops
Definition: item.h:149
M0_INTERNAL void m0_rm_outgoing_complete(struct m0_rm_outgoing *og)
Definition: rm.c:2465
uint64_t rin_flags
Definition: rm.h:1448
struct m0_fop_type m0_rm_fop_cancel_fopt
Definition: rm_fops.c:81
struct m0_rpc_session * ri_session
Definition: item.h:147
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
struct m0_tl ro_owned[OWOS_NR]
Definition: rm.h:1047
void m0_fop_put_lock(struct m0_fop *fop)
Definition: fop.c:199
static struct m0_fop * fop
Definition: item.c:57
struct m0_fop_type m0_rm_fop_revoke_fopt
Definition: rm_fops.c:75
struct m0_fop * m0_rpc_item_to_fop(const struct m0_rpc_item *item)
Definition: fop.c:346
static void rm_cancel_ast(struct m0_sm_group *grp, struct m0_sm_ast *ast)
Definition: rm_fops.c:498
const struct m0_sm_conf canoke_sm_conf
Definition: rm_foms.c:157
M0_INTERNAL void m0_sm_ast_cancel(struct m0_sm_group *grp, struct m0_sm_ast *ast)
Definition: sm.c:183
struct m0_cookie rem_cookie
Definition: rm.h:768
#define out(...)
Definition: gen.c:41
struct m0_uint128 cr_group_id
Definition: rm.h:506
struct m0_fop_type m0_rm_fop_borrow_fopt
Definition: rm_fops.c:67
struct m0_fop_type m0_rm_fop_revoke_rep_fopt
Definition: rm_fops.c:76
#define m0_tl_for(name, head, obj)
Definition: tlist.h:695
struct m0_rm_fop_req fr_base
Definition: rm_fops.h:602
void m0_free(void *data)
Definition: memory.c:146
struct m0_rpc_item f_item
Definition: fop.h:83
static void outgoing_queue(enum m0_rm_outgoing_type otype, struct m0_rm_owner *owner, struct rm_out *outreq, struct m0_rm_incoming *in, struct m0_rm_remote *other)
Definition: rm_fops.c:324
struct m0_rm_reserve_prio rin_reserve
Definition: rm.h:1475
enum m0_rm_outgoing_type rog_type
Definition: rm.h:1544
int32_t rc
Definition: trigger_fop.h:47
bool rog_sent
Definition: rm.h:1552
#define offsetof(typ, memb)
Definition: misc.h:29
struct m0_sm_ast ou_ast
Definition: rm_fops.c:48
struct m0_rm_loan rog_want
Definition: rm.h:1550
Definition: rm.h:903
Definition: fop.h:79
struct m0_fop ou_fop
Definition: rm_fops.c:49
struct m0_rm_outgoing ou_req
Definition: rm_fops.c:47
M0_INTERNAL void m0_rm_fop_fini(void)
Definition: rm_fops.c:547
M0_INTERNAL void m0_rm_outgoing_fini(struct m0_rm_outgoing *out)
Definition: rm.c:1166
#define M0_IMPOSSIBLE(fmt,...)
bool rem_dead
Definition: rm.h:788