Motr  M0
fop_item_type.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 #include "lib/errno.h"
24 #include "lib/memory.h"
25 #include "fop/fop.h"
26 #include "fop/fop_item_type.h"
27 #include "rpc/rpc_helpers.h" /* m0_rpc_item_header2_encdec */
28 
29 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_FOP
30 #include "lib/trace.h"
31 
32 M0_INTERNAL m0_bcount_t m0_fop_payload_size(const struct m0_rpc_item *item)
33 {
34  struct m0_fop *fop;
35  struct m0_xcode_ctx ctx;
36 
37  M0_PRE(item != NULL);
38 
40  M0_ASSERT(fop != NULL);
41  M0_ASSERT(fop->f_type != NULL);
42 
44 }
45 
46 M0_INTERNAL int
48  struct m0_rpc_item *item,
49  struct m0_bufvec_cursor *cur)
50 {
51  M0_PRE(item != NULL);
52  M0_PRE(cur != NULL);
53 
55 }
56 
57 M0_INTERNAL int
59  struct m0_rpc_item **item_out,
60  struct m0_bufvec_cursor *cur)
61 {
62  int rc;
63  struct m0_fop *fop;
64  struct m0_fop_type *ftype;
65  struct m0_rpc_item *item;
66 
67  M0_PRE(item_out != NULL);
68  M0_PRE(cur != NULL);
69 
70  *item_out = NULL;
71  ftype = m0_item_type_to_fop_type(item_type);
72  M0_ASSERT(ftype != NULL);
73 
74  /*
75  * Decoding in xcode is different from sunrpc xdr where top object is
76  * allocated by caller; in xcode, even the top object is allocated,
77  * so we don't need to allocate the fop->f_data->fd_data.
78  */
80  if (fop == NULL)
81  return M0_ERR(-ENOMEM);
82 
86  *item_out = item;
87 
88  return M0_RC(rc);
89 }
90 
95 M0_INTERNAL int m0_fop_item_encdec(struct m0_rpc_item *item,
96  struct m0_bufvec_cursor *cur,
97  enum m0_xcode_what what)
98 {
99  M0_PRE(item != NULL);
100  M0_PRE(cur != NULL);
101 
102  /* Currently MAX slot references in sessions is 1. */
103  return m0_rpc_item_header2_encdec(&item->ri_header, cur, what) ?:
105 }
106 
108 {
110 }
111 
113 {
115 }
116 
120 };
121 M0_EXPORTED(m0_fop_default_item_type_ops);
122 
123 #undef M0_TRACE_SUBSYSTEM
124 
125 /*
126  * Local variables:
127  * c-indentation-style: "K&R"
128  * c-basic-offset: 8
129  * tab-width: 8
130  * fill-column: 79
131  * scroll-step: 1
132  * End:
133  */
const struct m0_rpc_item_type_ops m0_fop_default_item_type_ops
#define M0_PRE(cond)
#define NULL
Definition: misc.h:38
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
Definition: addb2.c:791
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
uint64_t m0_bcount_t
Definition: types.h:77
m0_xcode_what
Definition: xcode.h:647
static struct m0_rpc_item * item
Definition: item.c:56
return M0_RC(rc)
struct m0_fop_type * f_type
Definition: fop.h:81
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL m0_bcount_t m0_fop_payload_size(const struct m0_rpc_item *item)
Definition: fop_item_type.c:32
M0_INTERNAL int m0_fop_item_type_default_encode(const struct m0_rpc_item_type *item_type, struct m0_rpc_item *item, struct m0_bufvec_cursor *cur)
Definition: fop_item_type.c:47
#define M0_ASSERT(cond)
struct m0_rpc_item_header2 ri_header
Definition: item.h:193
struct m0_fop * m0_fop_get(struct m0_fop *fop)
Definition: fop.c:162
M0_INTERNAL struct m0_fop_type * m0_item_type_to_fop_type(const struct m0_rpc_item_type *item_type)
Definition: fop.c:369
M0_INTERNAL int m0_fop_item_type_default_decode(const struct m0_rpc_item_type *item_type, struct m0_rpc_item **item_out, struct m0_bufvec_cursor *cur)
Definition: fop_item_type.c:58
void m0_fop_item_put(struct m0_rpc_item *item)
M0_INTERNAL int m0_xcode_data_size(struct m0_xcode_ctx *ctx, const struct m0_xcode_obj *obj)
Definition: xcode.c:437
M0_INTERNAL int m0_fop_item_encdec(struct m0_rpc_item *item, struct m0_bufvec_cursor *cur, enum m0_xcode_what what)
Definition: fop_item_type.c:95
M0_INTERNAL void m0_fop_release(struct m0_ref *ref)
Definition: fop.c:148
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
struct m0_rpc_item * m0_fop_to_rpc_item(const struct m0_fop *fop)
Definition: fop.c:338
M0_INTERNAL int m0_rpc_item_header2_encdec(struct m0_rpc_item_header2 *ioh, struct m0_bufvec_cursor *cur, enum m0_xcode_what what)
Definition: onwire.c:50
static struct m0_fop * fop
Definition: item.c:57
M0_INTERNAL int m0_fop_encdec(struct m0_fop *fop, struct m0_bufvec_cursor *cur, enum m0_xcode_what what)
Definition: fop.c:375
struct m0_fop * m0_rpc_item_to_fop(const struct m0_rpc_item *item)
Definition: fop.c:346
void m0_fop_item_get(struct m0_rpc_item *item)
Definition: nucleus.c:42
#define M0_FOP_XCODE_OBJ(f)
Definition: fop.h:334
void m0_fop_put(struct m0_fop *fop)
Definition: fop.c:177
int32_t rc
Definition: trigger_fop.h:47
#define M0_FOP_DEFAULT_ITEM_TYPE_OPS
Definition: fop.h:184
Definition: fop.h:79