Motr  M0
composite.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 
28 #include "lib/memory.h" /* M0_ALLOC_PTR() */
29 
30 #include "layout/layout_internal.h"
31 #include "layout/composite.h"
32 
36 };
37 
39 struct layout_prefix {
44  uint64_t lp_l_id;
45 
50  uint64_t lp_filler;
51 };
52 
53 /*
54  * @post A composite type of layout object is created. User is expected to
55  * add a reference on the layout object as required and is expected to release
56  * the reference when done with the usage. The layout is finalised when it is
57  * the last reference being released.
58  */
59 M0_INTERNAL void m0_composite_build(struct m0_layout_domain *dom,
60  uint64_t lid,
61  struct m0_tl *sub_layouts,
62  struct m0_composite_layout **out)
63 {
64 }
65 
66 #if 0 /* unused code */
67 
68 static void composite_fini(struct m0_ref *ref)
69 {
70 }
71 #endif
72 
73 /* Implementation of lto_allocate for COMPOSITE layout type. */
75  uint64_t lid,
76  struct m0_layout **out)
77 {
78  return 0;
79 }
80 
81 #if 0 /* unused code */
82 
83 static void composite_delete(struct m0_layout *l)
84 {
85 }
86 
88 static m0_bcount_t composite_recsize(const struct m0_layout *l)
89 {
90  return 0;
91 }
92 #endif
93 
100  const struct m0_layout_type *lt)
101 {
102  /*
103  @code
104  struct composite_schema_data *csd;
105 
106  M0_ALLOC_PTR(csd);
107 
108  Initialise csd->csd_comp_layout_ext_map table.
109 
110  dom->ld_type_data[lt->lt_id] = csd;
111  @endcode
112  */
113  return 0;
114 }
115 
122  const struct m0_layout_type *lt)
123 {
124  /*
125  @code
126  Finalise
127  dom->ld_type_data[lt->lt_id]->csd_comp_layout_ext_map
128  table.
129 
130  dom->ld_type_data[lt->lt_id] = NULL;
131  @endcode
132  */
133 }
134 
137 {
138  return 0;
139 }
140 
141 #if 0 /* unused code */
142 static const struct m0_layout_ops composite_ops;
143 
155 static int composite_decode(struct m0_layout *l,
156  struct m0_bufvec_cursor *cur,
157  enum m0_layout_xcode_op op,
158  struct m0_be_tx *tx,
159  uint32_t user_count)
160 {
161  /*
162  @code
163  struct m0_composite_layout *cl;
164 
165  M0_PRE(M0_IN(op, (M0_LXO_DB_LOOKUP, M0_LXO_BUFFER_OP));
166 
167  M0_ALLOC_PTR(cl);
168 
169  m0_layout__init(dom, &cl->cl_base, lid,
170  &m0_composite_layout_type, &composite_ops);
171 
172  if (op == M0_LXO_DB_LOOKUP) {
173  Read all the segments from the comp_layout_ext_map table,
174  belonging to composite layout with layout id 'lid' and store
175  them in the cl->cl_sub_layouts.
176 
177  } else {
178  Parse the sub-layout information from the buffer pointed by
179  cur and store it in cl->cl_sub_layouts.
180  }
181 
182  *out = &cl->cl_base;
183  @endcode
184  */
185 
186  return 0;
187 }
188 
200 static int composite_encode(struct m0_layout *l,
201  enum m0_layout_xcode_op op,
202  struct m0_be_tx *tx,
203  struct m0_bufvec_cursor *out)
204 {
205  /*
206  @code
207 
208  M0_PRE(M0_IN(op, (M0_LXO_DB_ADD, M0_LXO_DB_UPDATE,
209  M0_LXO_DB_DELETE, M0_LXO_BUFFER_OP)));
210 
211  if ((op == M0_LXO_DB_ADD) || (op == M0_LXO_DB_UPDATE) ||
212  (op == M0_LXO_DB_DELETE)) {
213  Form records for the cob_lists table by using data from the
214  m0_layout object l and depending on the value of op,
215  insert/update/delete those records to/from the cob_lists table.
216  } else {
217  Store composite layout type specific fields like information
218  about the sub-layouts, into the buffer by referring it from
219  m0_layout object l.
220  }
221 
222  @endcode
223  */
224 
225  return 0;
226 }
227 
228 static const struct m0_layout_ops composite_ops = {
229  .lo_fini = composite_fini,
230  .lo_delete = composite_delete,
231  .lo_recsize = composite_recsize,
232  .lo_decode = composite_decode,
233  .lo_encode = composite_encode
234 };
235 #endif
236 
237 static const struct m0_layout_type_ops composite_type_ops = {
239  .lto_unregister = composite_unregister,
240  .lto_max_recsize = composite_max_recsize,
241  .lto_allocate = composite_allocate
242 };
243 
244 
246  .lt_name = "composite",
247  .lt_id = 1,
248  .lt_ops = &composite_type_ops
249 };
250 
253 /*
254  * Local variables:
255  * c-indentation-style: "K&R"
256  * c-basic-offset: 8
257  * tab-width: 8
258  * fill-column: 80
259  * scroll-step: 1
260  * End:
261  */
static void composite_unregister(struct m0_layout_domain *dom, const struct m0_layout_type *lt)
Definition: composite.c:121
M0_INTERNAL void m0_composite_build(struct m0_layout_domain *dom, uint64_t lid, struct m0_tl *sub_layouts, struct m0_composite_layout **out)
Definition: composite.c:59
struct m0_be_emap csd_comp_layout_ext_map
Definition: composite.c:35
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
Definition: addb2.c:791
uint64_t m0_bcount_t
Definition: types.h:77
op
Definition: libdemo.c:64
uint64_t lp_filler
Definition: composite.c:50
Definition: refs.h:34
Definition: tlist.h:251
uint64_t lp_l_id
Definition: composite.c:44
static struct m0_stob_domain * dom
Definition: storage.c:38
const char * lt_name
Definition: layout.h:357
static const struct m0_layout_type_ops composite_type_ops
Definition: composite.c:237
static struct m0_clink l[NR]
Definition: chan.c:37
const struct m0_layout_type m0_composite_layout_type
Definition: composite.c:245
int(* lto_register)(struct m0_layout_domain *dom, const struct m0_layout_type *lt)
Definition: layout.h:378
static int composite_allocate(struct m0_layout_domain *dom, uint64_t lid, struct m0_layout **out)
Definition: composite.c:74
static m0_bcount_t composite_max_recsize(struct m0_layout_domain *dom)
Definition: composite.c:136
#define out(...)
Definition: gen.c:41
static int composite_register(struct m0_layout_domain *dom, const struct m0_layout_type *lt)
Definition: composite.c:99
m0_layout_xcode_op
Definition: layout.h:161
Definition: tx.h:280
void(* lo_fini)(struct m0_ref *ref)
Definition: layout.h:275