Skip to content

Commit

Permalink
Merge pull request #811 from mmichal10/req-rewrq
Browse files Browse the repository at this point in the history
Request improvements
  • Loading branch information
robertbaldyga authored Sep 9, 2024
2 parents 6cd5a27 + dc58eea commit 1fbb00d
Show file tree
Hide file tree
Showing 14 changed files with 256 additions and 48 deletions.
8 changes: 4 additions & 4 deletions inc/ocf_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ void *ocf_queue_get_priv(ocf_queue_t q);
uint32_t ocf_queue_pending_io(ocf_queue_t q);

/**
* @brief Get cache instance to which I/O queue belongs
* @brief Return if queue is management queue
*
* @param[in] q I/O queue
* @param[in] queue - queue object
*
* @retval Cache instance
* @retval true - if management queue, otherwise false
*/
ocf_cache_t ocf_queue_get_cache(ocf_queue_t q);
bool ocf_queue_is_mngt(ocf_queue_t queue);

#endif
2 changes: 1 addition & 1 deletion src/metadata/metadata_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ int metadata_io_read_i_atomic(ocf_cache_t cache, ocf_queue_t queue, void *priv,
if (!context)
return -OCF_ERR_NO_MEM;

context->req = ocf_req_new(queue, NULL, 0, 0, 0);
context->req = ocf_req_new_mngt(cache, queue);
if (!context->req) {
env_vfree(context);
return -OCF_ERR_NO_MEM;
Expand Down
2 changes: 1 addition & 1 deletion src/metadata/metadata_raw_dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ void raw_dynamic_load_all(ocf_cache_t cache, struct ocf_metadata_raw *raw,
goto err_zpage;
}

context->req = ocf_req_new(cache->mngt_queue, NULL, 0, 0, 0);
context->req = ocf_req_new_mngt(cache, cache->mngt_queue);
if (!context->req) {
result = -OCF_ERR_NO_MEM;
goto err_req;
Expand Down
2 changes: 2 additions & 0 deletions src/mngt/ocf_mngt_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,8 @@ static int _ocf_mngt_init_new_cache(struct ocf_cache_mngt_init_params *params)
/* start with freezed metadata ref counter to indicate detached device*/
ocf_refcnt_freeze(&cache->refcnt.metadata);

ocf_refcnt_init(&cache->refcnt.d2c);

env_atomic_set(&(cache->last_access_ms),
env_ticks_to_msecs(env_get_tick_count()));

Expand Down
2 changes: 1 addition & 1 deletion src/mngt/ocf_mngt_flush.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ static void _ocf_mngt_flush_container(
fc->end = end;
fc->context = context;

req = ocf_req_new(cache->mngt_queue, NULL, 0, 0, 0);
req = ocf_req_new_mngt(cache, cache->mngt_queue);
if (!req) {
error = OCF_ERR_NO_MEM;
goto finish;
Expand Down
2 changes: 2 additions & 0 deletions src/ocf_cache_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ struct ocf_cache {
/* # of requests accessing attached metadata, excluding
* management reqs */
struct ocf_refcnt metadata __attribute__((aligned(64)));
/* # of requests in d2c mode */
struct ocf_refcnt d2c;
} refcnt;

struct {
Expand Down
5 changes: 3 additions & 2 deletions src/ocf_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static uint64_t _calc_dirty_for(uint64_t dirty_since)
return dirty_since ? (current_time - dirty_since) : 0;
}

static inline struct ocf_request *ocf_io_to_req(struct ocf_io *io)
struct ocf_request *ocf_io_to_req(struct ocf_io *io)
{
struct ocf_io_internal *ioi;

Expand Down Expand Up @@ -489,9 +489,10 @@ static void *ocf_core_io_allocator_new(ocf_io_allocator_t allocator,
ocf_volume_t volume, ocf_queue_t queue,
uint64_t addr, uint32_t bytes, uint32_t dir)
{
ocf_core_t core = ocf_volume_to_core(volume);
struct ocf_request *req;

req = ocf_req_new(queue, NULL, addr, bytes, dir);
req = ocf_req_new(queue, core, addr, bytes, dir);
if (!req)
return NULL;

Expand Down
3 changes: 3 additions & 0 deletions src/ocf_core_priv.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause
*/

Expand Down Expand Up @@ -105,4 +106,6 @@ ocf_core_id_t ocf_core_get_id(ocf_core_t core);

int ocf_core_volume_type_init(ocf_ctx_t ctx);

struct ocf_request *ocf_io_to_req(struct ocf_io *io);

#endif /* __OCF_CORE_PRIV_H__ */
13 changes: 6 additions & 7 deletions src/ocf_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ int ocf_queue_create_mngt(ocf_cache_t cache, ocf_queue_t *queue,
return 0;
}

bool ocf_queue_is_mngt(ocf_queue_t queue)
{
return queue == queue->cache->mngt_queue;
}

void ocf_queue_get(ocf_queue_t queue)
{
OCF_CHECK_NULL(queue);
Expand All @@ -144,7 +149,7 @@ void ocf_queue_put(ocf_queue_t queue)
return;

queue->ops->stop(queue);
if (queue != queue->cache->mngt_queue) {
if (!ocf_queue_is_mngt(queue)) {
env_spinlock_lock_irqsave(&cache->io_queues_lock, flags);
list_del(&queue->list);
env_spinlock_unlock_irqrestore(&cache->io_queues_lock, flags);
Expand Down Expand Up @@ -247,12 +252,6 @@ uint32_t ocf_queue_pending_io(ocf_queue_t q)
return env_atomic_read(&q->io_no);
}

ocf_cache_t ocf_queue_get_cache(ocf_queue_t q)
{
OCF_CHECK_NULL(q);
return q->cache;
}

void ocf_queue_push_req(struct ocf_request *req, uint flags)
{
ocf_cache_t cache = req->cache;
Expand Down
Loading

0 comments on commit 1fbb00d

Please sign in to comment.