Motr  M0
cache.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2015-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 #pragma once
23 #ifndef __MOTR_CONF_CACHE_H__
24 #define __MOTR_CONF_CACHE_H__
25 
26 #include "conf/obj.h"
27 #include "lib/tlist.h" /* M0_TL_DESCR_DECLARE */
28 
29 struct m0_mutex;
30 
32 M0_TL_DECLARE(m0_conf_cache, M0_INTERNAL, struct m0_conf_obj);
33 
65 
91 };
92 
94 struct m0_conf_cache {
100 
102  struct m0_mutex *ca_lock;
103 
105  uint64_t ca_ver;
106 
111  uint64_t ca_fid_counter;
112 };
113 
115 M0_INTERNAL void m0_conf_cache_init(struct m0_conf_cache *cache,
116  struct m0_mutex *lock);
117 
123 M0_INTERNAL void m0_conf_cache_fini(struct m0_conf_cache *cache);
124 
125 M0_INTERNAL void m0_conf_cache_lock(struct m0_conf_cache *cache);
126 M0_INTERNAL void m0_conf_cache_unlock(struct m0_conf_cache *cache);
127 M0_INTERNAL bool m0_conf_cache_is_locked(const struct m0_conf_cache *cache);
128 
140 M0_INTERNAL void m0_conf_cache_clean(struct m0_conf_cache *cache,
141  const struct m0_conf_obj_type *type);
142 
148 M0_INTERNAL void m0_conf_cache_gc(struct m0_conf_cache *cache);
149 
156 M0_INTERNAL int m0_conf_cache_add(struct m0_conf_cache *cache,
157  struct m0_conf_obj *obj);
158 
165 M0_INTERNAL void m0_conf_cache_del(const struct m0_conf_cache *cache,
166  struct m0_conf_obj *obj);
167 
171 M0_INTERNAL bool m0_conf_cache_contains(struct m0_conf_cache *cache,
172  const struct m0_fid *fid);
178 M0_INTERNAL struct m0_conf_obj *
180  const struct m0_fid *id);
181 
194 M0_INTERNAL int m0_conf_cache_to_string(struct m0_conf_cache *cache, char **str,
195  bool debug);
196 
205 M0_INTERNAL int m0_conf_cache_from_string(struct m0_conf_cache *cache,
206  const char *str);
207 
209 M0_INTERNAL int m0_conf_version(struct m0_conf_cache *cache);
210 
217 M0_INTERNAL struct m0_conf_obj *
219 
225 enum { M0_CONF_PATH_MAX = 15 };
226 
228 #endif /* __MOTR_CONF_CACHE_H__ */
Definition: beck.c:235
static struct m0_mutex lock
Definition: transmit.c:326
M0_TL_DESCR_DECLARE(m0_conf_cache, extern)
m0_conf_version
Definition: cache.h:75
M0_INTERNAL bool m0_conf_cache_contains(struct m0_conf_cache *cache, const struct m0_fid *fid)
Definition: cache.c:94
M0_TL_DECLARE(m0_conf_cache, M0_INTERNAL, struct m0_conf_obj)
M0_INTERNAL struct m0_conf_obj * m0_conf_cache_lookup(const struct m0_conf_cache *cache, const struct m0_fid *id)
Definition: cache.c:106
struct m0_mutex * ca_lock
Definition: cache.h:102
M0_INTERNAL int m0_conf_cache_add(struct m0_conf_cache *cache, struct m0_conf_obj *obj)
Definition: cache.c:79
M0_INTERNAL int m0_conf_cache_from_string(struct m0_conf_cache *cache, const char *str)
Definition: cache.c:278
uint64_t ca_fid_counter
Definition: cache.h:111
static struct foo * obj
Definition: tlist.c:302
struct m0_fid fid
Definition: di.c:46
M0_INTERNAL void m0_conf_cache_clean(struct m0_conf_cache *cache, const struct m0_conf_obj_type *type)
Definition: cache.c:168
struct m0_tl ca_registry
Definition: cache.h:99
M0_INTERNAL struct m0_conf_obj * m0_conf_cache_pinned(const struct m0_conf_cache *cache)
Definition: cache.c:320
M0_INTERNAL void m0_conf_cache_lock(struct m0_conf_cache *cache)
Definition: cache.c:50
Definition: tlist.h:251
M0_INTERNAL bool m0_conf_cache_is_locked(const struct m0_conf_cache *cache)
Definition: cache.c:60
M0_INTERNAL void m0_conf_cache_fini(struct m0_conf_cache *cache)
Definition: cache.c:183
M0_INTERNAL void m0_conf_cache_del(const struct m0_conf_cache *cache, struct m0_conf_obj *obj)
Definition: cache.c:124
M0_INTERNAL int m0_conf_cache_to_string(struct m0_conf_cache *cache, char **str, bool debug)
Definition: cache.c:257
Definition: fid.h:38
M0_INTERNAL void m0_conf_cache_init(struct m0_conf_cache *cache, struct m0_mutex *lock)
Definition: cache.c:66
M0_INTERNAL void m0_conf_cache_gc(struct m0_conf_cache *cache)
Definition: cache.c:176
M0_INTERNAL void m0_conf_cache_unlock(struct m0_conf_cache *cache)
Definition: cache.c:55
int type
Definition: dir.c:1031
uint64_t ca_ver
Definition: cache.h:105
Definition: mutex.h:47