Motr  M0
packet.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-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_FORMATION
24 #include "lib/trace.h"
25 
26 #include "lib/tlist.h"
27 #include "lib/misc.h"
28 #include "lib/vec.h"
29 #include "lib/errno.h"
30 #include "lib/finject.h"
31 #include "lib/memory.h"
32 #include "motr/magic.h"
33 #include "xcode/xcode.h"
34 #include "rpc/rpc_internal.h"
35 #include "reqh/reqh.h"
36 #include "format/format.h"
37 #include "addb2/addb2.h"
38 #include "rpc/addb2.h"
39 
40 
46 #define PACKHD_XCODE_OBJ(ptr) M0_XCODE_OBJ(m0_rpc_packet_onwire_header_xc, ptr)
47 #define PACKFT_XCODE_OBJ(ptr) M0_XCODE_OBJ(m0_rpc_packet_onwire_footer_xc, ptr)
48 
49 M0_TL_DESCR_DEFINE(packet_item, "packet_item", M0_INTERNAL, struct m0_rpc_item,
50  ri_plink, ri_magic, M0_RPC_ITEM_MAGIC,
52 M0_TL_DEFINE(packet_item, M0_INTERNAL, struct m0_rpc_item);
53 
55 {
57  struct m0_xcode_ctx ctx;
58  static m0_bcount_t packet_header_size;
59 
60  if (packet_header_size == 0) {
62  packet_header_size = m0_xcode_length(&ctx);
63  }
64 
65  return packet_header_size;
66 }
67 
69 {
71  struct m0_xcode_ctx ctx;
72  static m0_bcount_t packet_footer_size;
73 
74  if (packet_footer_size == 0) {
76  packet_footer_size = m0_xcode_length(&ctx);
77  }
78 
79  return packet_footer_size;
80 }
81 
82 M0_INTERNAL bool m0_rpc_packet_invariant(const struct m0_rpc_packet *p)
83 {
84  struct m0_rpc_item *item;
86 
87  size = 0;
91 
92  return
93  _0C(p != NULL) &&
94  _0C(p->rp_ow.poh_version != 0) &&
95  _0C(p->rp_ow.poh_magic == M0_RPC_PACKET_HEAD_MAGIC) &&
96  _0C(p->rp_rmachine != NULL) &&
97  _0C(p->rp_ow.poh_nr_items ==
98  packet_item_tlist_length(&p->rp_items)) &&
99  _0C(p->rp_size == size + m0_rpc_packet_onwire_header_size() +
101 }
102 
103 M0_INTERNAL void m0_rpc_packet_init(struct m0_rpc_packet *p,
104  struct m0_rpc_machine *rmach)
105 {
106  M0_ENTRY("packet: %p", p);
107  M0_PRE(p != NULL);
108 
109  M0_SET0(p);
110 
111  p->rp_ow.poh_version = M0_RPC_VERSION_1;
112  p->rp_ow.poh_magic = M0_RPC_PACKET_HEAD_MAGIC;
113  p->rp_size = m0_rpc_packet_onwire_header_size() +
115  packet_item_tlist_init(&p->rp_items);
116  p->rp_rmachine = rmach;
117 
119  M0_LEAVE();
120 }
121 
122 M0_INTERNAL void m0_rpc_packet_fini(struct m0_rpc_packet *p)
123 {
124  M0_ENTRY("packet: %p nr_items: %llu", p,
125  (unsigned long long)p->rp_ow.poh_nr_items);
126  M0_PRE(m0_rpc_packet_invariant(p) && p->rp_ow.poh_nr_items == 0);
127 
128  packet_item_tlist_fini(&p->rp_items);
129  M0_SET0(p);
130 
131  M0_LEAVE();
132 }
133 
134 M0_INTERNAL void m0_rpc_packet_discard(struct m0_rpc_packet *packet)
135 {
138  m0_free(packet);
139 }
140 
141 M0_INTERNAL void m0_rpc_packet_add_item(struct m0_rpc_packet *p,
142  struct m0_rpc_item *item)
143 {
144  M0_ENTRY("packet: %p, item: %p[%s/%u]", p, item,
147  M0_PRE(!packet_item_tlink_is_in(item));
148  M0_PRE(m0_rpc_machine_is_locked(p->rp_rmachine));
149 
151  item->ri_rmachine = p->rp_rmachine;
152  item->ri_packet = p;
153  packet_item_tlink_init_at_tail(item, &p->rp_items);
154  ++p->rp_ow.poh_nr_items;
155  p->rp_size += m0_rpc_item_size(item);
156 
157  M0_LOG(M0_DEBUG, "packet: %p nr_items: %llu packet size: %llu",
158  p, (unsigned long long)p->rp_ow.poh_nr_items,
159  (unsigned long long)p->rp_size);
162  M0_LEAVE();
163 }
164 
165 M0_INTERNAL void m0_rpc_packet_remove_item(struct m0_rpc_packet *p,
166  struct m0_rpc_item *item)
167 {
168  M0_ENTRY("packet: %p, item: %p[%s/%u]", p, item,
172  M0_PRE(m0_rpc_machine_is_locked(p->rp_rmachine));
173 
174  packet_item_tlink_del_fini(item);
175  item->ri_packet = NULL;
176  --p->rp_ow.poh_nr_items;
177  p->rp_size -= m0_rpc_item_size(item);
178 
179  M0_LOG(M0_DEBUG, "p %p, nr_items: %llu->%llu packet size: %llu->%llu",
180  p, (unsigned long long)p->rp_ow.poh_nr_items + 1,
181  (unsigned long long)p->rp_ow.poh_nr_items,
182  (unsigned long long)p->rp_size + m0_rpc_item_size(item),
183  (unsigned long long)p->rp_size);
184  M0_POST(!packet_item_tlink_is_in(item));
187  M0_LEAVE();
188 }
189 
191 {
192  struct m0_rpc_item *item;
193 
194  M0_ENTRY("packet: %p", p);
196  M0_PRE(m0_rpc_machine_is_locked(p->rp_rmachine));
197 
198  M0_LOG(M0_DEBUG, "p %p, nr_items: %d", p, (int)p->rp_ow.poh_nr_items);
199 
203 
205  M0_LEAVE();
206 }
207 
208 M0_INTERNAL bool m0_rpc_packet_is_carrying_item(const struct m0_rpc_packet *p,
209  const struct m0_rpc_item *item)
210 {
211  return packet_item_tlist_contains(&p->rp_items, item);
212 }
213 
214 M0_INTERNAL bool m0_rpc_packet_is_empty(const struct m0_rpc_packet *p)
215 {
217 
218  return p->rp_ow.poh_nr_items == 0;
219 }
220 
221 M0_INTERNAL int m0_rpc_packet_encode(struct m0_rpc_packet *p,
222  struct m0_bufvec *bufvec)
223 {
224  struct m0_bufvec_cursor cur;
225  m0_bcount_t bufvec_size;
226 
227  M0_ENTRY("packet: %p bufvec: %p", p, bufvec);
228  M0_PRE_EX(m0_rpc_packet_invariant(p) && bufvec != NULL);
230 
231  if (M0_FI_ENABLED("fake_error"))
232  return M0_ERR(-EFAULT);
233 
234  bufvec_size = m0_vec_count(&bufvec->ov_vec);
235 
236  M0_ASSERT(M0_IS_8ALIGNED(bufvec_size));
237  M0_ASSERT(m0_forall(i, bufvec->ov_vec.v_nr,
238  M0_IS_8ALIGNED(bufvec->ov_vec.v_count[i])));
239  M0_ASSERT(bufvec_size >= p->rp_size);
240 
241  m0_bufvec_cursor_init(&cur, bufvec);
243 
245 }
246 
248  struct m0_bufvec_cursor *cursor,
249  enum m0_xcode_what what)
250 
251 {
252  M0_ENTRY();
253  return M0_RC(m0_xcode_encdec(&PACKHD_XCODE_OBJ(ph), cursor, what));
254 }
255 
257  struct m0_bufvec_cursor *cursor,
258  enum m0_xcode_what what)
259 
260 {
261  M0_ENTRY();
262  return M0_RC(m0_xcode_encdec(&PACKFT_XCODE_OBJ(pf), cursor, what));
263 }
264 
265 static int item_encode(struct m0_rpc_item *item,
266  struct m0_bufvec_cursor *cursor)
267 {
268  struct m0_rpc_item_header1 ioh;
269  struct m0_format_tag item_format_tag = {
271  .ot_type = M0_FORMAT_TYPE_RPC_ITEM,
272  };
273  struct m0_rpc_item_footer iof;
274  int rc;
275  struct m0_ha_domain *ha_dom;
276  uint64_t epoch = M0_HA_EPOCH_NONE;
277 
278  M0_ENTRY("item: %p cursor: %p", item, cursor);
279  M0_PRE(item != NULL && cursor != NULL);
280  M0_PRE(item->ri_type != NULL &&
281  item->ri_type->rit_ops != NULL &&
283 
285  epoch = item->ri_ha_epoch;
286  else if (item->ri_rmachine != NULL &&
287  item->ri_rmachine->rm_reqh != NULL) {
288  ha_dom = &item->ri_rmachine->rm_reqh->rh_hadom;
289  epoch = ha_dom->hdo_epoch;
290  }
291 
292  M0_LOG(M0_DEBUG, "ha_epoch: %lu", (unsigned long)epoch);
293  ioh = (struct m0_rpc_item_header1){
295  .ioh_flags = item->ri_flags,
296  .ioh_ha_epoch = epoch,
297  .ioh_magic = M0_RPC_ITEM_MAGIC,
298  };
299 
300  /* measured in bytes: including header, payload, and footer */
301  item_format_tag.ot_size = item->ri_size;
302  m0_format_header_pack(&ioh.ioh_header, &item_format_tag);
303 
304  if (item->ri_nr_sent > 0)
305  ioh.ioh_flags |= M0_RIF_DUP;
307  if (rc == 0)
309  item, cursor);
310  if (rc == 0) {
313  }
314  return M0_RC(rc);
315 }
316 
318  struct m0_bufvec_cursor
319  *cursor)
320 {
321  struct m0_rpc_item *item;
322  bool end_of_bufvec;
324  int rc;
325  struct m0_format_tag packet_format_tag = {
327  .ot_type = M0_FORMAT_TYPE_RPC_PACKET,
328  };
329 
330  M0_ENTRY("packet: %p cursor: %p", packet, cursor);
333 
334  /* measured in bytes: including header, items, and footer */
335  packet_format_tag.ot_size = packet->rp_size;
336  m0_format_header_pack(&packet->rp_ow.poh_header, &packet_format_tag);
337 
338  rc = packet_header_encdec(&packet->rp_ow, cursor, M0_XCODE_ENCODE);
339  if (rc == 0) {
341  uint64_t item_sm_id = m0_sm_id_get(&item->ri_sm);
342 
346  item_sm_id,
347  (uint64_t)item->ri_type->rit_opcode,
350 
351  rc = item_encode(item, cursor);
352  if (rc != 0)
353  break;
355  }
356  if (rc == 0) {
357  m0_format_footer_generate(&pf.pof_footer, NULL, 0);
359  }
360 
361  end_of_bufvec = m0_bufvec_cursor_align(cursor, 8);
362  M0_ASSERT(end_of_bufvec ||
364  return M0_RC(rc);
365 }
366 
367 M0_INTERNAL int m0_rpc_packet_decode(struct m0_rpc_packet *p,
368  struct m0_bufvec *bufvec,
369  m0_bindex_t off, m0_bcount_t len)
370 {
371  struct m0_bufvec_cursor cursor;
372  int rc;
373 
374  M0_ENTRY();
375  M0_PRE_EX(m0_rpc_packet_invariant(p) && bufvec != NULL && len > 0);
376  M0_PRE(len <= m0_vec_count(&bufvec->ov_vec));
377  M0_PRE(M0_IS_8ALIGNED(off) && M0_IS_8ALIGNED(len));
378  M0_ASSERT(m0_forall(i, bufvec->ov_vec.v_nr,
379  M0_IS_8ALIGNED(bufvec->ov_vec.v_count[i])));
380 
381  m0_bufvec_cursor_init(&cursor, bufvec);
382  m0_bufvec_cursor_move(&cursor, off);
384  rc = m0_rpc_packet_decode_using_cursor(p, &cursor, len);
385  M0_ASSERT(ergo(rc == 0, m0_bufvec_cursor_move(&cursor, 0) ||
387  return M0_RC(rc);
388 }
389 
390 static int item_decode(struct m0_bufvec_cursor *cursor,
391  struct m0_rpc_item **item_out)
392 {
393  struct m0_rpc_item_type *item_type;
394  struct m0_rpc_item_header1 ioh;
395  struct m0_rpc_item_footer iof;
396  int rc;
397  struct m0_format_tag ioh_t;
398 
399  M0_ENTRY();
400  M0_PRE(cursor != NULL && item_out != NULL);
401 
402  *item_out = NULL;
403 
405  if (rc != 0)
406  return M0_ERR(rc);
407 
408  if (ioh.ioh_magic != M0_RPC_ITEM_MAGIC)
409  return M0_ERR(-EPROTO);
410 
411  /* check version compatibility. */
412  if (M0_FI_ENABLED("header_unpack"))
413  return M0_ERR(-EPROTO);
414 
415  m0_format_header_unpack(&ioh_t, &ioh.ioh_header);
416  if (ioh_t.ot_version != M0_RPC_ITEM_FORMAT_VERSION ||
418  return M0_ERR(-EPROTO);
419 
420  item_type = m0_rpc_item_type_lookup(ioh.ioh_opcode);
421  if (item_type == NULL)
422  return M0_ERR(-EPROTO);
423 
424  M0_ASSERT(item_type->rit_ops != NULL &&
425  item_type->rit_ops->rito_decode != NULL);
426 
427  if (M0_FI_ENABLED("rito_decode_nomem"))
428  return M0_ERR(-ENOMEM);
429 
430  rc = item_type->rit_ops->rito_decode(item_type, item_out, cursor);
431  if (rc != 0)
432  return M0_ERR(rc);
433 
435  if (rc == 0)
437  false);
438  if (rc != 0)
439  return M0_ERR(rc);
440 
441  (*item_out)->ri_ha_epoch = ioh.ioh_ha_epoch;
442  (*item_out)->ri_flags = ioh.ioh_flags;
443  M0_LOG(M0_DEBUG, "ha_epoch: %lu", (unsigned long)ioh.ioh_ha_epoch);
444 
445  return M0_RC(0);
446 }
447 
449  struct m0_bufvec_cursor
450  *cursor, m0_bcount_t len)
451 {
452  struct m0_rpc_packet_onwire_header poh;
453  struct m0_rpc_packet_onwire_footer pof;
454  struct m0_rpc_item *item;
455  int rc;
456  int i;
457  struct m0_format_tag rpc_t;
458 
459  M0_ENTRY();
460  M0_PRE_EX(m0_rpc_packet_invariant(p) && cursor != NULL);
461 
462  rc = packet_header_encdec(&poh, cursor, M0_XCODE_DECODE);
463  if (rc != 0)
464  return M0_RC(rc);
465  if (poh.poh_version != M0_RPC_VERSION_1 || poh.poh_nr_items == 0 ||
467  return M0_RC(-EPROTO);
468 
469  /* check version compatibility. */
470  m0_format_header_unpack(&rpc_t, &poh.poh_header);
473  return M0_RC(-EPROTO);
474 
475  /*
476  * p->rp_ow.poh_{version,magic} are initialized in m0_rpc_packet_init().
477  * p->rp_ow.poh_nr_items will be updated while decoding items in
478  * the following item_decode().
479  */
480  p->rp_ow.poh_header = poh.poh_header;
481 
482  for (i = 0; i < poh.poh_nr_items; ++i) {
483  rc = item_decode(cursor, &item);
484  if (item == NULL) {
485  /* Here fop is not allocated, no need to release it. */
486  return M0_ERR(rc);
487  } else if (rc != 0) {
488  struct m0_fop *fop = m0_rpc_item_to_fop(item);
489  uint64_t count = m0_ref_read(&fop->f_ref);
490 
491  /* After item_decode(), there's no conception of rpc or
492  * fop, and rpc_mach is set in m0_rpc_packet_add_item()
493  * later. So it's impossible to perform lock on rpc_mach
494  * inside m0_fop_put_lock() and it's replaced with
495  * explicit m0_ref_put(). */
496  M0_ASSERT(count == 1);
497  m0_ref_put(&fop->f_ref);
498 
499  return M0_ERR(rc);
500  }
501  m0_rpc_machine_lock(p->rp_rmachine);
504  m0_rpc_machine_unlock(p->rp_rmachine);
505  item = NULL;
506  }
507  rc = packet_footer_encdec(&pof, cursor, M0_XCODE_DECODE);
508  if (rc == 0)
510  false);
511  if (rc != 0)
512  return M0_ERR(rc);
513  m0_bufvec_cursor_align(cursor, 8);
514 
515  /* assert the decoded packet has the same number of items and size */
516  M0_ASSERT(p->rp_ow.poh_nr_items == poh.poh_nr_items);
517  M0_ASSERT(p->rp_size == rpc_t.ot_size);
518 
520 
521  return M0_RC(0);
522 }
523 
525  item_visit_fn *visit,
526  int opaque_data)
527 {
528  struct m0_rpc_item *item;
529 
530  M0_ENTRY("p: %p visit: %p", p, visit);
532  M0_LOG(M0_DEBUG, "%p nr_items: %u", p,
533  (unsigned int)p->rp_ow.poh_nr_items);
534 
536  visit(p, item, opaque_data);
538 
540  M0_LEAVE();
541 }
542 
544 #undef M0_TRACE_SUBSYSTEM
545 
546 /*
547  * Local variables:
548  * c-indentation-style: "K&R"
549  * c-basic-offset: 8
550  * tab-width: 8
551  * fill-column: 80
552  * scroll-step: 1
553  * End:
554  */
uint64_t ioh_ha_epoch
Definition: onwire.h:90
M0_INTERNAL void m0_format_footer_generate(struct m0_format_footer *footer, const void *buffer, uint32_t size)
Definition: format.c:59
M0_INTERNAL int m0_xcode_encdec(struct m0_xcode_obj *obj, struct m0_bufvec_cursor *cur, enum m0_xcode_what what)
Definition: xcode.c:416
uint32_t rit_opcode
Definition: item.h:474
static struct m0_addb2_philter p
Definition: consumer.c:40
#define M0_PRE(cond)
uint64_t hdo_epoch
Definition: epoch.h:113
M0_INTERNAL void m0_format_header_pack(struct m0_format_header *dest, const struct m0_format_tag *src)
Definition: format.c:40
M0_INTERNAL void m0_format_header_unpack(struct m0_format_tag *dest, const struct m0_format_header *src)
Definition: format.c:49
struct m0_ha_domain rh_hadom
Definition: reqh.h:156
#define NULL
Definition: misc.h:38
M0_TL_DESCR_DEFINE(packet_item, "packet_item", M0_INTERNAL, struct m0_rpc_item, ri_plink, ri_magic, M0_RPC_ITEM_MAGIC, M0_RPC_PACKET_HEAD_MAGIC)
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
Definition: addb2.c:791
#define ergo(a, b)
Definition: misc.h:293
static int packet_footer_encdec(struct m0_rpc_packet_onwire_footer *pf, struct m0_bufvec_cursor *cursor, enum m0_xcode_what what)
Definition: packet.c:256
size_t ri_size
Definition: item.h:198
const struct m0_rpc_item_type_ops * rit_ops
Definition: item.h:476
M0_INTERNAL int m0_rpc_packet_decode(struct m0_rpc_packet *p, struct m0_bufvec *bufvec, m0_bindex_t off, m0_bcount_t len)
Definition: packet.c:367
void m0_rpc_item_put(struct m0_rpc_item *item)
Definition: item.c:443
#define M0_LOG(level,...)
Definition: trace.h:167
M0_LEAVE()
static int item_encode(struct m0_rpc_item *item, struct m0_bufvec_cursor *cursor)
Definition: packet.c:265
M0_INTERNAL const uint64_t M0_HA_EPOCH_NONE
Definition: epoch.c:77
M0_INTERNAL void m0_rpc_packet_traverse_items(struct m0_rpc_packet *p, item_visit_fn *visit, int opaque_data)
Definition: packet.c:524
M0_INTERNAL int m0_rpc_item_header1_encdec(struct m0_rpc_item_header1 *ioh, struct m0_bufvec_cursor *cur, enum m0_xcode_what what)
Definition: onwire.c:42
uint64_t osr_session_id
Definition: onwire.h:97
struct m0_vec ov_vec
Definition: vec.h:147
void m0_rpc_item_get(struct m0_rpc_item *item)
Definition: item.c:434
struct m0_sm ri_sm
Definition: item.h:181
uint32_t ot_size
Definition: format.h:75
struct m0_format_header ioh_header
Definition: onwire.h:84
uint64_t m0_bindex_t
Definition: types.h:80
M0_INTERNAL struct m0_rpc_item_type * m0_rpc_item_type_lookup(uint32_t opcode)
Definition: item.c:189
M0_INTERNAL void * m0_bufvec_cursor_addr(struct m0_bufvec_cursor *cur)
Definition: vec.c:597
uint64_t m0_bcount_t
Definition: types.h:77
M0_INTERNAL const char * item_kind(const struct m0_rpc_item *item)
Definition: item.c:356
M0_INTERNAL void m0_rpc_packet_add_item(struct m0_rpc_packet *p, struct m0_rpc_item *item)
Definition: packet.c:141
m0_xcode_what
Definition: xcode.h:647
#define M0_SET0(obj)
Definition: misc.h:64
M0_ADDB2_ADD(M0_AVI_FS_CREATE, new_fid.f_container, new_fid.f_key, mode, rc)
static struct m0_rpc_item * item
Definition: item.c:56
static m0_bcount_t count
Definition: xcode.c:167
M0_INTERNAL bool m0_rpc_packet_invariant(const struct m0_rpc_packet *p)
Definition: packet.c:82
return M0_RC(rc)
M0_INTERNAL int m0_xcode_length(struct m0_xcode_ctx *ctx)
Definition: xcode.c:390
#define PACKHD_XCODE_OBJ(ptr)
Definition: packet.c:46
#define M0_ASSERT_EX(cond)
#define M0_ENTRY(...)
Definition: trace.h:170
m0_bcount_t m0_rpc_item_size(struct m0_rpc_item *item)
Definition: item.c:470
uint64_t osr_xid
Definition: onwire.h:105
M0_INTERNAL bool m0_bufvec_cursor_move(struct m0_bufvec_cursor *cur, m0_bcount_t count)
Definition: vec.c:574
M0_INTERNAL void m0_rpc_packet_init(struct m0_rpc_packet *p, struct m0_rpc_machine *rmach)
Definition: packet.c:103
M0_INTERNAL bool m0_rpc_machine_is_locked(const struct m0_rpc_machine *machine)
Definition: rpc_machine.c:565
int i
Definition: dir.c:1033
M0_INTERNAL void m0_rpc_packet_fini(struct m0_rpc_packet *p)
Definition: packet.c:122
uint16_t ot_version
Definition: format.h:63
M0_INTERNAL int m0_rpc_packet_decode_using_cursor(struct m0_rpc_packet *p, struct m0_bufvec_cursor *cursor, m0_bcount_t len)
Definition: packet.c:448
M0_INTERNAL void m0_ref_put(struct m0_ref *ref)
Definition: refs.c:38
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL void m0_rpc_machine_unlock(struct m0_rpc_machine *machine)
Definition: rpc_machine.c:558
static int item_decode(struct m0_bufvec_cursor *cursor, struct m0_rpc_item **item_out)
Definition: packet.c:390
#define M0_ASSERT(cond)
M0_INTERNAL int m0_rpc_packet_encode_using_cursor(struct m0_rpc_packet *packet, struct m0_bufvec_cursor *cursor)
Definition: packet.c:317
struct m0_format_header poh_header
Definition: onwire.h:71
struct m0_rpc_item_header2 ri_header
Definition: item.h:193
int(* rito_decode)(const struct m0_rpc_item_type *item_type, struct m0_rpc_item **item, struct m0_bufvec_cursor *cur)
Definition: item.h:411
Definition: xcode.h:95
static const struct pfamily pf[]
Definition: sock.c:1155
M0_INTERNAL void m0_bufvec_cursor_init(struct m0_bufvec_cursor *cur, const struct m0_bufvec *bvec)
Definition: vec.c:563
M0_INTERNAL int m0_format_footer_verify_generic(const struct m0_format_footer *footer, const void *buffer, uint32_t size, bool iem)
Definition: format.c:125
const struct m0_rpc_item_type * ri_type
Definition: item.h:200
M0_INTERNAL int m0_rpc_packet_encode(struct m0_rpc_packet *p, struct m0_bufvec *bufvec)
Definition: packet.c:221
uint32_t ioh_opcode
Definition: onwire.h:86
#define M0_POST(cond)
uint32_t ri_flags
Definition: item.h:156
uint32_t v_nr
Definition: vec.h:51
m0_bcount_t * v_count
Definition: vec.h:53
void item_visit_fn(struct m0_rpc_packet *packet, struct m0_rpc_item *item, int data)
M0_INTERNAL int m0_rpc_item_footer_encdec(struct m0_rpc_item_footer *iof, struct m0_bufvec_cursor *cur, enum m0_xcode_what what)
Definition: onwire.c:58
M0_INTERNAL m0_bcount_t m0_vec_count(const struct m0_vec *vec)
Definition: vec.c:53
static int packet_header_encdec(struct m0_rpc_packet_onwire_header *ph, struct m0_bufvec_cursor *cursor, enum m0_xcode_what what)
Definition: packet.c:247
#define m0_forall(var, nr,...)
Definition: misc.h:112
M0_INTERNAL bool m0_rpc_packet_is_carrying_item(const struct m0_rpc_packet *p, const struct m0_rpc_item *item)
Definition: packet.c:208
struct m0_rpc_packet * ri_packet
Definition: item.h:223
M0_INTERNAL int64_t m0_ref_read(const struct m0_ref *ref)
Definition: refs.c:44
uint16_t ot_type
Definition: format.h:64
M0_INTERNAL void m0_rpc_item_xid_min_update(struct m0_rpc_item *item)
Definition: item.c:543
#define M0_FI_ENABLED(tag)
Definition: finject.h:231
struct m0_ref f_ref
Definition: fop.h:80
M0_INTERNAL void m0_rpc_machine_lock(struct m0_rpc_machine *machine)
Definition: rpc_machine.c:551
M0_INTERNAL bool m0_bufvec_cursor_align(struct m0_bufvec_cursor *cur, uint64_t alignment)
Definition: vec.c:604
M0_TL_DEFINE(packet_item, M0_INTERNAL, struct m0_rpc_item)
m0_bcount_t size
Definition: di.c:39
#define _0C(exp)
Definition: assert.h:311
M0_INTERNAL m0_bcount_t m0_rpc_packet_onwire_footer_size(void)
Definition: packet.c:68
M0_INTERNAL void m0_rpc_packet_discard(struct m0_rpc_packet *packet)
Definition: packet.c:134
uint64_t ioh_magic
Definition: onwire.h:91
static struct m0_fop * fop
Definition: item.c:57
M0_INTERNAL void m0_rpc_packet_remove_item(struct m0_rpc_packet *p, struct m0_rpc_item *item)
Definition: packet.c:165
#define PACKFT_XCODE_OBJ(ptr)
Definition: packet.c:47
struct m0_fop * m0_rpc_item_to_fop(const struct m0_rpc_item *item)
Definition: fop.c:346
M0_INTERNAL void m0_rpc_item_xid_assign(struct m0_rpc_item *item)
Definition: item.c:565
#define for_each_item_in_packet(item, packet)
uint32_t ioh_flags
Definition: onwire.h:88
Definition: nucleus.c:42
M0_INTERNAL void m0_rpc_packet_remove_all_items(struct m0_rpc_packet *p)
Definition: packet.c:190
M0_INTERNAL void m0_xcode_ctx_init(struct m0_xcode_ctx *ctx, const struct m0_xcode_obj *obj)
Definition: xcode.c:373
#define M0_IS_8ALIGNED(val)
Definition: arith.h:190
uint32_t ri_nr_sent
Definition: item.h:183
struct m0_rpc_machine * ri_rmachine
Definition: item.h:160
#define M0_PRE_EX(cond)
M0_INTERNAL bool m0_rpc_packet_is_empty(const struct m0_rpc_packet *p)
Definition: packet.c:214
M0_INTERNAL uint64_t m0_sm_id_get(const struct m0_sm *sm)
Definition: sm.c:1021
void m0_free(void *data)
Definition: memory.c:146
M0_INTERNAL m0_bcount_t m0_rpc_packet_onwire_header_size(void)
Definition: packet.c:54
int32_t rc
Definition: trigger_fop.h:47
uint64_t ri_ha_epoch
Definition: item.h:136
#define M0_POST_EX(cond)
struct m0_reqh * rm_reqh
Definition: rpc_machine.h:105
int(* rito_encode)(const struct m0_rpc_item_type *item_type, struct m0_rpc_item *item, struct m0_bufvec_cursor *cur)
Definition: item.h:404
#define end_for_each_item_in_packet
Definition: fop.h:79
Definition: vec.h:145