Skip to content

Commit 68fccaf

Browse files
author
Robert Baldyga
authored
Merge pull request #506 from jfckm/cache-priv-init
Add priv field initialization on cache start
2 parents 57dbe0e + 9f1df6e commit 68fccaf

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

example/simple/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ int initialize_cache(ocf_ctx_t ctx, ocf_cache_t *cache)
126126
return -ENOMEM;
127127

128128
/* Start cache */
129-
ret = ocf_mngt_cache_start(ctx, cache, &cache_cfg);
129+
ret = ocf_mngt_cache_start(ctx, cache, &cache_cfg, NULL);
130130
if (ret)
131131
goto err_priv;
132132

inc/ocf_mngt.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,13 @@ static inline void ocf_mngt_cache_config_set_default(
325325
* @param[in] ctx OCF context
326326
* @param[out] cache Cache handle
327327
* @param[in] cfg Starting cache configuration
328+
* @param[in] priv initial value of priv field in cache
328329
*
329330
* @retval 0 Cache started successfully
330331
* @retval Non-zero Error occurred and starting cache failed
331332
*/
332333
int ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
333-
struct ocf_mngt_cache_config *cfg);
334+
struct ocf_mngt_cache_config *cfg, void *priv);
334335

335336
/**
336337
* @brief Set queue to be used during management operations

src/mngt/ocf_mngt_cache.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ static void _ocf_mngt_cache_init(ocf_cache_t cache,
11791179
}
11801180

11811181
static int _ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
1182-
struct ocf_mngt_cache_config *cfg)
1182+
struct ocf_mngt_cache_config *cfg, void *priv)
11831183
{
11841184
struct ocf_cache_mngt_init_params params;
11851185
ocf_cache_t tmp_cache;
@@ -1208,6 +1208,7 @@ static int _ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
12081208

12091209
tmp_cache = params.cache;
12101210
tmp_cache->owner = ctx;
1211+
tmp_cache->priv = priv;
12111212

12121213
/*
12131214
* Initialize metadata selected segments of metadata in memory
@@ -1946,7 +1947,7 @@ static const char *_ocf_cache_mode_get_name(ocf_cache_mode_t cache_mode)
19461947
}
19471948

19481949
int ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
1949-
struct ocf_mngt_cache_config *cfg)
1950+
struct ocf_mngt_cache_config *cfg, void *priv)
19501951
{
19511952
int result;
19521953

@@ -1957,7 +1958,7 @@ int ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
19571958
if (result)
19581959
return result;
19591960

1960-
result = _ocf_mngt_cache_start(ctx, cache, cfg);
1961+
result = _ocf_mngt_cache_start(ctx, cache, cfg, priv);
19611962
if (!result) {
19621963
_ocf_mngt_cache_set_valid(*cache);
19631964

tests/functional/pyocf/types/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def __init__(
205205

206206
def start_cache(self, default_io_queue: Queue = None, mngt_queue: Queue = None):
207207
status = self.owner.lib.ocf_mngt_cache_start(
208-
self.owner.ctx_handle, byref(self.cache_handle), byref(self.cfg)
208+
self.owner.ctx_handle, byref(self.cache_handle), byref(self.cfg), None
209209
)
210210
if status:
211211
raise OcfError("Creating cache instance failed", status)

tests/functional/tests/management/test_start_stop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def test_start_stop_noqueue(pyocf_ctx):
394394

395395
cache_handle = c_void_p()
396396
status = pyocf_ctx.lib.ocf_mngt_cache_start(
397-
pyocf_ctx.ctx_handle, byref(cache_handle), byref(_cache.cfg)
397+
pyocf_ctx.ctx_handle, byref(cache_handle), byref(_cache.cfg), None
398398
)
399399
assert not status, "Failed to start cache: {}".format(status)
400400

0 commit comments

Comments
 (0)