Motr  M0
seg_dict.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_SEG_DICT_H__
26 #define __MOTR_BE_SEG_DICT_H__
27 
34 /*
35  * Design highlights:
36  * - bh_dict (BE list) contains entries sorted by keys. This fact is used in
37  * the iterator.
38  * - XXX Seg_dict is not thread-safe. For users that access seg_dict during
39  * mkfs/init process, it is not a problem, because they're serialised by
40  * serial motr/setup. But we should be aware of the next use-cases:
41  * 1. Multiple instances of cm/ag_store may modify/lookup seg_dict
42  * concurrently.
43  * 2. Ad stob domains may be created/destroyed concurrently with
44  * cm/ag_store. See m0_storage_dev.
45  * - XXX Seg dict iterator returns pointers to potentially unpinned memory. It
46  * may cause problems with `this_key` strings.
47  */
48 
49 struct m0_be_tx;
50 struct m0_be_seg;
51 struct m0_be_tx_credit;
52 
53 M0_INTERNAL void m0_be_seg_dict_init(struct m0_be_seg *seg);
54 M0_INTERNAL void m0_be_seg_dict_fini(struct m0_be_seg *seg);
55 M0_INTERNAL int m0_be_seg_dict_lookup(struct m0_be_seg *seg,
56  const char *name,
57  void **out);
58 M0_INTERNAL int m0_be_seg_dict_begin(struct m0_be_seg *seg,
59  const char *start_key,
60  const char **this_key,
61  void **this_rec);
62 M0_INTERNAL int m0_be_seg_dict_next(struct m0_be_seg *seg,
63  const char *prefix,
64  const char *start_key,
65  const char **this_key,
66  void **this_rec);
67 
68 /* tx based dictionary interface */
69 M0_INTERNAL int m0_be_seg_dict_insert(struct m0_be_seg *seg,
70  struct m0_be_tx *tx,
71  const char *name,
72  void *value);
73 M0_INTERNAL int m0_be_seg_dict_delete(struct m0_be_seg *seg,
74  struct m0_be_tx *tx,
75  const char *name);
76 M0_INTERNAL void m0_be_seg_dict_create(struct m0_be_seg *seg,
77  struct m0_be_tx *tx);
78 M0_INTERNAL void m0_be_seg_dict_destroy(struct m0_be_seg *seg,
79  struct m0_be_tx *tx);
80 
81 M0_INTERNAL void m0_be_seg_dict_create_credit(struct m0_be_seg *seg,
82  struct m0_be_tx_credit *accum);
83 M0_INTERNAL void m0_be_seg_dict_destroy_credit(struct m0_be_seg *seg,
84  struct m0_be_tx_credit *accum);
85 M0_INTERNAL void m0_be_seg_dict_insert_credit(struct m0_be_seg *seg,
86  const char *name,
87  struct m0_be_tx_credit *accum);
88 M0_INTERNAL void m0_be_seg_dict_delete_credit(struct m0_be_seg *seg,
89  const char *name,
90  struct m0_be_tx_credit *accum);
91 
93 #endif /* __MOTR_BE_SEG_DICT_H__ */
94 
95 /*
96  * Local variables:
97  * c-indentation-style: "K&R"
98  * c-basic-offset: 8
99  * tab-width: 8
100  * fill-column: 80
101  * scroll-step: 1
102  * End:
103  */
104 /*
105  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
106  */
M0_INTERNAL int m0_be_seg_dict_begin(struct m0_be_seg *seg, const char *start_key, const char **this_key, void **this_rec)
Definition: seg_dict.c:236
M0_INTERNAL int m0_be_seg_dict_insert(struct m0_be_seg *seg, struct m0_be_tx *tx, const char *name, void *value)
Definition: seg_dict.c:255
M0_INTERNAL void m0_be_seg_dict_init(struct m0_be_seg *seg)
Definition: seg_dict.c:160
M0_INTERNAL int m0_be_seg_dict_next(struct m0_be_seg *seg, const char *prefix, const char *start_key, const char **this_key, void **this_rec)
Definition: seg_dict.c:245
static struct m0_uint128 prefix
Definition: extmap.c:45
int const char const void * value
Definition: dir.c:325
const char * name
Definition: trace.c:110
M0_INTERNAL int m0_be_seg_dict_delete(struct m0_be_seg *seg, struct m0_be_tx *tx, const char *name)
Definition: seg_dict.c:316
M0_INTERNAL void m0_be_seg_dict_fini(struct m0_be_seg *seg)
Definition: seg_dict.c:170
M0_INTERNAL void m0_be_seg_dict_destroy_credit(struct m0_be_seg *seg, struct m0_be_tx_credit *accum)
Definition: seg_dict.c:150
Definition: seg.h:66
M0_INTERNAL void m0_be_seg_dict_delete_credit(struct m0_be_seg *seg, const char *name, struct m0_be_tx_credit *accum)
Definition: seg_dict.c:131
M0_INTERNAL void m0_be_seg_dict_create_credit(struct m0_be_seg *seg, struct m0_be_tx_credit *accum)
Definition: seg_dict.c:144
M0_INTERNAL void m0_be_seg_dict_destroy(struct m0_be_seg *seg, struct m0_be_tx *tx)
Definition: seg_dict.c:354
static struct m0_be_seg * seg
Definition: btree.c:40
M0_INTERNAL void m0_be_seg_dict_create(struct m0_be_seg *seg, struct m0_be_tx *tx)
Definition: seg_dict.c:342
#define out(...)
Definition: gen.c:41
M0_INTERNAL void m0_be_seg_dict_insert_credit(struct m0_be_seg *seg, const char *name, struct m0_be_tx_credit *accum)
Definition: seg_dict.c:114
M0_INTERNAL int m0_be_seg_dict_lookup(struct m0_be_seg *seg, const char *name, void **out)
Definition: seg_dict.c:180
Definition: tx.h:280