Motr  M0
extmap.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 
23 #pragma once
24 
25 #ifndef __MOTR_BE_EXTMAP_H__
26 #define __MOTR_BE_EXTMAP_H__
27 
107 #include "lib/ext.h" /* m0_ext */
108 #include "lib/ext_xc.h" /* m0_ext_xc */
109 #include "lib/types.h" /* struct m0_uint128 */
110 #include "lib/types_xc.h" /* m0_uint128_xc */
111 #include "be/tx.h"
112 #include "be/btree.h"
113 #include "be/btree_xc.h"
114 
115 #include "be/extmap_internal.h"
116 #include "be/extmap_internal_xc.h"
117 
118 /* import */
119 struct m0_be_emap;
120 struct m0_be_seg;
121 struct m0_be_tx;
122 struct m0_indexvec;
123 
124 /* export */
125 struct m0_be_emap_seg;
126 struct m0_be_emap_cursor;
127 
136 M0_INTERNAL void m0_be_emap_init(struct m0_be_emap *map,
137  struct m0_be_seg *db);
138 
140 M0_INTERNAL void m0_be_emap_fini(struct m0_be_emap *map);
141 
150 M0_INTERNAL void m0_be_emap_create(struct m0_be_emap *map,
151  struct m0_be_tx *tx,
152  struct m0_be_op *op,
153  const struct m0_fid *fid);
154 
156 M0_INTERNAL void m0_be_emap_destroy(struct m0_be_emap *map,
157  struct m0_be_tx *tx,
158  struct m0_be_op *op);
159 
169 M0_INTERNAL void m0_be_emap_obj_insert(struct m0_be_emap *map,
170  struct m0_be_tx *tx,
171  struct m0_be_op *op,
172  const struct m0_uint128 *prefix,
173  uint64_t val);
174 
181 M0_INTERNAL void m0_be_emap_obj_delete(struct m0_be_emap *map,
182  struct m0_be_tx *tx,
183  struct m0_be_op *op,
184  const struct m0_uint128 *prefix);
191  struct m0_ext ee_ext;
193  uint64_t ee_val;
195 } M0_XCA_RECORD M0_XCA_DOMAIN(be);
196 
204  uint64_t ec_version;
217  struct m0_be_op ec_op;
218 };
219 
221 M0_INTERNAL bool m0_be_emap_ext_is_last(const struct m0_ext *ext);
222 
224 M0_INTERNAL bool m0_be_emap_ext_is_first(const struct m0_ext *ext);
225 
227 M0_INTERNAL struct m0_be_emap_seg *
229 
231 M0_INTERNAL struct m0_be_op *m0_be_emap_op(struct m0_be_emap_cursor *it);
232 M0_INTERNAL int m0_be_emap_op_rc(const struct m0_be_emap_cursor *it);
233 
252 M0_INTERNAL void m0_be_emap_lookup(struct m0_be_emap *map,
253  const struct m0_uint128 *prefix,
255  struct m0_be_emap_cursor *it);
256 
264 M0_INTERNAL void m0_be_emap_next(struct m0_be_emap_cursor *it);
265 
273 M0_INTERNAL void m0_be_emap_prev(struct m0_be_emap_cursor *it);
274 
287 M0_INTERNAL void m0_be_emap_merge(struct m0_be_emap_cursor *it,
288  struct m0_be_tx *tx,
289  m0_bindex_t delta);
290 
309 M0_INTERNAL void m0_be_emap_split(struct m0_be_emap_cursor *it,
310  struct m0_be_tx *tx,
311  struct m0_indexvec *vec,
312  struct m0_buf *cksum);
313 
345 M0_INTERNAL void m0_be_emap_paste(struct m0_be_emap_cursor *it,
346  struct m0_be_tx *tx,
347  struct m0_ext *ext,
348  uint64_t val,
349  void (*del)(struct m0_be_emap_seg*),
350  void (*cut_left)(struct m0_be_emap_seg*, struct m0_ext*, uint64_t),
351  void (*cut_right)(struct m0_be_emap_seg*, struct m0_ext*, uint64_t));
352 
354 M0_INTERNAL int m0_be_emap_count(struct m0_be_emap_cursor *it,
355  m0_bcount_t *segs);
356 
363 M0_INTERNAL void m0_be_emap_extent_update(struct m0_be_emap_cursor *it,
364  struct m0_be_tx *tx,
365  const struct m0_be_emap_seg *es);
366 
370 M0_INTERNAL void m0_be_emap_close(struct m0_be_emap_cursor *it);
371 
387 };
388 
389 M0_INTERNAL void m0_be_emap_caret_init(struct m0_be_emap_caret *car,
390  struct m0_be_emap_cursor *it,
392 
393 M0_INTERNAL void m0_be_emap_caret_fini(struct m0_be_emap_caret *car);
394 
401 M0_INTERNAL int m0_be_emap_caret_move(struct m0_be_emap_caret *car,
403 
405 M0_INTERNAL int m0_be_emap_caret_move_sync(struct m0_be_emap_caret *car,
407 
409 M0_INTERNAL m0_bcount_t m0_be_emap_caret_step(const struct m0_be_emap_caret*);
410 
424 };
425 
436 M0_INTERNAL void m0_be_emap_credit(struct m0_be_emap *emap,
437  enum m0_be_emap_optype optype,
438  m0_bcount_t nr,
439  struct m0_be_tx_credit *accum);
440 
441 M0_INTERNAL
442 struct m0_be_domain *m0_be_emap_seg_domain(const struct m0_be_emap *emap);
443 
444 /*
445  * Dumps the number of cobs and segments from the @emap
446  * into the trace logs. Note, on large amount of data
447  * when BE segment does not fit into available RAM this
448  * may generate a lot of I/O because of page-ins.
449  */
450 M0_INTERNAL int m0_be_emap_dump(struct m0_be_emap *emap);
451 
454 /* __MOTR_BE_EXTMAP_H__ */
455 #endif
456 
457 /*
458  * Local variables:
459  * c-indentation-style: "K&R"
460  * c-basic-offset: 8
461  * tab-width: 8
462  * fill-column: 80
463  * scroll-step: 1
464  * End:
465  */
M0_INTERNAL struct m0_be_domain * m0_be_emap_seg_domain(const struct m0_be_emap *map)
Definition: extmap.c:339
static size_t nr
Definition: dump.c:1505
M0_INTERNAL void m0_be_emap_next(struct m0_be_emap_cursor *it)
Definition: extmap.c:377
M0_INTERNAL m0_bcount_t m0_be_emap_caret_step(const struct m0_be_emap_caret *car)
Definition: extmap.c:834
map
Definition: processor.c:112
Definition: idx_mock.c:52
M0_INTERNAL int m0_be_emap_dump(struct m0_be_emap *map)
Definition: extmap.c:199
struct m0_be_emap_cursor M0_XCA_DOMAIN
uint64_t ee_val
Definition: extmap.h:193
M0_INTERNAL int m0_be_emap_caret_move(struct m0_be_emap_caret *car, m0_bcount_t count)
Definition: extmap.c:840
struct m0_be_emap_key ec_key
Definition: extmap.h:209
static struct m0_uint128 prefix
Definition: extmap.c:45
struct m0_buf ec_keybuf
Definition: extmap.h:211
static m0_bcount_t segs[NR *IT]
Definition: vec.c:45
M0_INTERNAL void m0_be_emap_destroy(struct m0_be_emap *map, struct m0_be_tx *tx, struct m0_be_op *op)
Definition: extmap.c:300
M0_INTERNAL void m0_be_emap_obj_insert(struct m0_be_emap *map, struct m0_be_tx *tx, struct m0_be_op *op, const struct m0_uint128 *prefix, uint64_t val)
Definition: extmap.c:744
M0_INTERNAL void m0_be_emap_prev(struct m0_be_emap_cursor *it)
Definition: extmap.c:391
M0_INTERNAL void m0_be_emap_close(struct m0_be_emap_cursor *it)
Definition: extmap.c:360
static struct m0_be_emap_cursor it
Definition: extmap.c:46
struct m0_buf ec_recbuf
Definition: extmap.h:212
uint64_t m0_bindex_t
Definition: types.h:80
uint64_t m0_bcount_t
Definition: types.h:77
m0_be_emap_optype
Definition: extmap.h:415
m0_bindex_t ec_unit_size
Definition: extmap.h:214
struct m0_be_emap_seg ec_seg
Definition: extmap.h:206
M0_INTERNAL void m0_be_emap_split(struct m0_be_emap_cursor *it, struct m0_be_tx *tx, struct m0_indexvec *vec, struct m0_buf *cksum)
Definition: extmap.c:464
M0_INTERNAL bool m0_be_emap_ext_is_first(const struct m0_ext *ext)
Definition: extmap.c:323
uint64_t ec_version
Definition: extmap.h:204
M0_INTERNAL void m0_be_emap_merge(struct m0_be_emap_cursor *it, struct m0_be_tx *tx, m0_bindex_t delta)
Definition: extmap.c:432
static m0_bcount_t count
Definition: xcode.c:167
struct m0_buf ee_cksum_buf
Definition: extmap.h:194
M0_INTERNAL struct m0_be_op * m0_be_emap_op(struct m0_be_emap_cursor *it)
Definition: extmap.c:328
struct m0_fid fid
Definition: di.c:46
op
Definition: libdemo.c:64
Definition: buf.h:37
M0_INTERNAL int m0_be_emap_op_rc(const struct m0_be_emap_cursor *it)
Definition: extmap.c:333
M0_INTERNAL void m0_be_emap_paste(struct m0_be_emap_cursor *it, struct m0_be_tx *tx, struct m0_ext *ext, uint64_t val, void(*del)(struct m0_be_emap_seg *), void(*cut_left)(struct m0_be_emap_seg *, struct m0_ext *, uint64_t), void(*cut_right)(struct m0_be_emap_seg *, struct m0_ext *, uint64_t))
Definition: extmap.c:517
struct m0_be_btree_cursor ec_cursor
Definition: extmap.h:208
m0_bindex_t ct_index
Definition: extmap.h:386
M0_INTERNAL void m0_be_emap_init(struct m0_be_emap *map, struct m0_be_seg *db)
Definition: extmap.c:258
static void del(void)
Definition: client_ut.c:3157
static void * vec
Definition: xcode.c:168
struct m0_be_emap * ec_map
Definition: extmap.h:202
M0_INTERNAL void m0_be_emap_caret_init(struct m0_be_emap_caret *car, struct m0_be_emap_cursor *it, m0_bindex_t index)
Definition: extmap.c:817
struct m0_be_emap_rec ec_rec
Definition: extmap.h:210
M0_INTERNAL bool m0_be_emap_ext_is_last(const struct m0_ext *ext)
Definition: extmap.c:318
M0_INTERNAL void m0_be_emap_extent_update(struct m0_be_emap_cursor *it, struct m0_be_tx *tx, const struct m0_be_emap_seg *es)
Definition: extmap.c:405
struct m0_be_op ec_op
Definition: extmap.h:217
struct m0_uint128 ee_pre
Definition: extmap.h:189
M0_INTERNAL void m0_be_emap_fini(struct m0_be_emap *map)
Definition: extmap.c:276
M0_INTERNAL void m0_be_emap_lookup(struct m0_be_emap *map, const struct m0_uint128 *prefix, m0_bindex_t offset, struct m0_be_emap_cursor *it)
Definition: extmap.c:344
static m0_bindex_t offset
Definition: dump.c:173
M0_INTERNAL void m0_be_emap_obj_delete(struct m0_be_emap *map, struct m0_be_tx *tx, struct m0_be_op *op, const struct m0_uint128 *prefix)
Definition: extmap.c:774
Definition: seg.h:66
struct m0_uint128 ec_prefix
Definition: extmap.h:213
static struct m0_be_emap * emap
Definition: extmap.c:44
struct m0_be_emap_cursor * ct_it
Definition: extmap.h:385
struct m0_ext ee_ext
Definition: extmap.h:191
Definition: ext.h:37
Definition: fid.h:38
M0_INTERNAL int m0_be_emap_caret_move_sync(struct m0_be_emap_caret *car, m0_bcount_t count)
Definition: extmap.c:872
M0_INTERNAL void m0_be_emap_credit(struct m0_be_emap *map, enum m0_be_emap_optype optype, m0_bcount_t nr, struct m0_be_tx_credit *accum)
Definition: extmap.c:886
struct m0_buf ec_app_cksum_buf
Definition: extmap.h:216
M0_INTERNAL int m0_be_emap_count(struct m0_be_emap_cursor *it, m0_bcount_t *segs)
Definition: extmap.c:713
Definition: op.h:74
M0_INTERNAL void m0_be_emap_create(struct m0_be_emap *map, struct m0_be_tx *tx, struct m0_be_op *op, const struct m0_fid *fid)
Definition: extmap.c:283
static struct m0_be_ut_backend be
Definition: service_ut.c:59
M0_INTERNAL struct m0_be_emap_seg * m0_be_emap_seg_get(struct m0_be_emap_cursor *it)
Definition: extmap.c:313
Definition: tx.h:280
M0_INTERNAL void m0_be_emap_caret_fini(struct m0_be_emap_caret *car)
Definition: extmap.c:828