From 3fbb75756e76bedb2283adf4e1e03c7285ce3b1d Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Fri, 2 Aug 2024 16:06:32 +0200 Subject: [PATCH] Consolidate ocf_request_io and ocf_request - io properties Signed-off-by: Robert Baldyga Signed-off-by: Michal Mielewczyk --- src/engine/cache_engine.c | 3 +- src/engine/engine_common.c | 6 ++-- src/engine/engine_d2c.c | 6 ++-- src/engine/engine_debug.h | 5 ++-- src/engine/engine_discard.c | 14 ++++----- src/engine/engine_io.c | 34 +++++++++++----------- src/engine/engine_pt.c | 2 +- src/engine/engine_rd.c | 6 ++-- src/engine/engine_wi.c | 2 +- src/engine/engine_zero.c | 10 +++---- src/metadata/metadata_io.c | 2 +- src/metadata/metadata_passive_update.c | 16 +++++------ src/metadata/metadata_raw.c | 2 +- src/ocf_cache.c | 8 +++--- src/ocf_core.c | 12 ++++---- src/ocf_io.c | 19 +++++++++---- src/ocf_request.c | 12 ++++---- src/ocf_request.h | 39 ++++++-------------------- src/ocf_seq_cutoff.c | 10 +++---- src/ocf_stats.c | 8 +++--- src/ocf_volume.c | 6 ++-- src/utils/utils_cache_line.h | 21 +++++++------- src/utils/utils_cleaner.c | 6 ++-- src/utils/utils_io.c | 4 +-- src/utils/utils_parallelize.c | 4 +-- 25 files changed, 121 insertions(+), 136 deletions(-) diff --git a/src/engine/cache_engine.c b/src/engine/cache_engine.c index ee7d3ab..c291214 100644 --- a/src/engine/cache_engine.c +++ b/src/engine/cache_engine.c @@ -157,8 +157,7 @@ void ocf_resolve_effective_cache_mode(ocf_cache_t cache, return; } - if (cache->pt_unaligned_io && !ocf_req_is_4k(req->byte_position, - req->byte_length)) { + if (cache->pt_unaligned_io && !ocf_req_is_4k(req->addr, req->bytes)) { req->cache_mode = ocf_req_cache_mode_pt; return; } diff --git a/src/engine/engine_common.c b/src/engine/engine_common.c index 457182d..e25eb4f 100644 --- a/src/engine/engine_common.c +++ b/src/engine/engine_common.c @@ -31,8 +31,8 @@ void ocf_engine_error(struct ocf_request *req, if (ocf_cache_log_rl(cache)) { ocf_core_log(req->core, log_err, "%s sector: %" ENV_PRIu64 ", bytes: %u\n", msg, - BYTES_TO_SECTORS(req->byte_position), - req->byte_length); + BYTES_TO_SECTORS(req->addr), + req->bytes); } } @@ -571,7 +571,7 @@ void ocf_engine_clean(struct ocf_request *req) void ocf_engine_update_block_stats(struct ocf_request *req) { ocf_core_stats_vol_block_update(req->core, req->part_id, req->rw, - req->byte_length); + req->bytes); } void ocf_engine_update_request_stats(struct ocf_request *req) diff --git a/src/engine/engine_d2c.c b/src/engine/engine_d2c.c index b8c5e3a..e55320f 100644 --- a/src/engine/engine_d2c.c +++ b/src/engine/engine_d2c.c @@ -41,7 +41,7 @@ int ocf_d2c_io_fast(struct ocf_request *req) ocf_engine_update_block_stats(req); ocf_core_stats_pt_block_update(req->core, req->part_id, req->rw, - req->byte_length); + req->bytes); ocf_core_stats_request_pt_update(req->core, req->part_id, req->rw, req->info.hit_no, req->core_line_count); @@ -61,7 +61,7 @@ int ocf_d2c_flush_fast(struct ocf_request *req) ocf_engine_update_block_stats(req); ocf_core_stats_pt_block_update(req->core, req->part_id, req->rw, - req->byte_length); + req->bytes); ocf_core_stats_request_pt_update(req->core, req->part_id, req->rw, req->info.hit_no, req->core_line_count); @@ -81,7 +81,7 @@ int ocf_d2c_discard_fast(struct ocf_request *req) ocf_engine_update_block_stats(req); ocf_core_stats_pt_block_update(req->core, req->part_id, req->rw, - req->byte_length); + req->bytes); ocf_core_stats_request_pt_update(req->core, req->part_id, req->rw, req->info.hit_no, req->core_line_count); diff --git a/src/engine/engine_debug.h b/src/engine/engine_debug.h index fb72e7b..8f54e48 100644 --- a/src/engine/engine_debug.h +++ b/src/engine/engine_debug.h @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2021 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -33,8 +34,8 @@ #define OCF_DEBUG_RQ(req, format, ...) \ ocf_cache_log(req->cache, log_info, "[Engine][%s][%s, %llu, %u] %s - " \ format"\n", OCF_ENGINE_DEBUG_IO_NAME, \ - OCF_READ == (req)->rw ? "RD" : "WR", req->byte_position, \ - req->byte_length, __func__, ##__VA_ARGS__) + OCF_READ == (req)->rw ? "RD" : "WR", req->addr, \ + req->bytes, __func__, ##__VA_ARGS__) #else #define OCF_DEBUG_PREFIX diff --git a/src/engine/engine_discard.c b/src/engine/engine_discard.c index 02372e8..250da03 100644 --- a/src/engine/engine_discard.c +++ b/src/engine/engine_discard.c @@ -28,8 +28,8 @@ static void _ocf_discard_complete_req(struct ocf_request *req, int error) static int _ocf_discard_core(struct ocf_request *req) { - req->byte_position = SECTORS_TO_BYTES(req->discard.sector); - req->byte_length = SECTORS_TO_BYTES(req->discard.nr_sects); + req->addr = SECTORS_TO_BYTES(req->discard.sector); + req->bytes = SECTORS_TO_BYTES(req->discard.nr_sects); ocf_engine_forward_core_discard_req(req, _ocf_discard_complete_req); @@ -60,7 +60,7 @@ static int _ocf_discard_step(struct ocf_request *req); static void _ocf_discard_finish_step(struct ocf_request *req) { - req->discard.handled += BYTES_TO_SECTORS(req->byte_length); + req->discard.handled += BYTES_TO_SECTORS(req->bytes); if (req->discard.handled < req->discard.nr_sects) req->engine_handler = _ocf_discard_step; @@ -149,13 +149,13 @@ static int _ocf_discard_step(struct ocf_request *req) OCF_DEBUG_TRACE(req->cache); - req->byte_position = SECTORS_TO_BYTES(req->discard.sector + + req->addr = SECTORS_TO_BYTES(req->discard.sector + req->discard.handled); - req->byte_length = OCF_MIN(SECTORS_TO_BYTES(req->discard.nr_sects - + req->bytes = OCF_MIN(SECTORS_TO_BYTES(req->discard.nr_sects - req->discard.handled), MAX_TRIM_RQ_SIZE); - req->core_line_first = ocf_bytes_2_lines(cache, req->byte_position); + req->core_line_first = ocf_bytes_2_lines(cache, req->addr); req->core_line_last = - ocf_bytes_2_lines(cache, req->byte_position + req->byte_length - 1); + ocf_bytes_2_lines(cache, req->addr + req->bytes - 1); req->core_line_count = req->core_line_last - req->core_line_first + 1; req->engine_handler = _ocf_discard_step_do; diff --git a/src/engine/engine_io.c b/src/engine/engine_io.c index c742cd3..cb7f79c 100644 --- a/src/engine/engine_io.c +++ b/src/engine/engine_io.c @@ -16,7 +16,7 @@ void ocf_engine_forward_cache_io(struct ocf_request *req, int dir, uint64_t offset, uint64_t size, ocf_req_end_t callback) { ocf_cache_t cache = req->cache; - uint32_t seek = req->byte_position % ocf_line_size(cache); + uint32_t seek = req->addr % ocf_line_size(cache); uint32_t first_cl = ocf_bytes_2_lines(cache, offset + seek); uint64_t addr; @@ -27,7 +27,7 @@ void ocf_engine_forward_cache_io(struct ocf_request *req, int dir, addr += (offset + seek) % ocf_line_size(cache); ocf_core_stats_cache_block_update(req->core, req->part_id, - dir, req->byte_length); + dir, req->bytes); ocf_req_forward_cache_io(req, dir, addr, size, req->offset + offset); @@ -45,12 +45,12 @@ void ocf_engine_forward_cache_io_req(struct ocf_request *req, int dir, if (ocf_engine_is_sequential(req)) { addr = cache->device->metadata_offset; addr += req->map[0].coll_idx * ocf_line_size(cache); - addr += req->byte_position % ocf_line_size(cache); + addr += req->addr % ocf_line_size(cache); ocf_core_stats_cache_block_update(req->core, req->part_id, - dir, req->byte_length); + dir, req->bytes); - ocf_req_forward_cache_io(req, dir, addr, req->byte_length, + ocf_req_forward_cache_io(req, dir, addr, req->bytes, req->offset); return; } @@ -67,7 +67,7 @@ void ocf_engine_forward_cache_io_req(struct ocf_request *req, int dir, bytes = ocf_line_size(cache); if (i == 0) { - uint64_t seek = (req->byte_position) % + uint64_t seek = (req->addr) % ocf_line_size(cache); addr += seek; @@ -87,13 +87,13 @@ void ocf_engine_forward_cache_io_req(struct ocf_request *req, int dir, if (i == (req->core_line_count - 1)) { uint64_t skip = (ocf_line_size(cache) - - ((req->byte_position + req->byte_length) % + ((req->addr + req->bytes) % ocf_line_size(cache))) % ocf_line_size(cache); bytes -= skip; } - bytes = OCF_MIN(bytes, req->byte_length - total_bytes); + bytes = OCF_MIN(bytes, req->bytes - total_bytes); ENV_BUG_ON(bytes == 0); ocf_core_stats_cache_block_update(req->core, req->part_id, @@ -105,7 +105,7 @@ void ocf_engine_forward_cache_io_req(struct ocf_request *req, int dir, total_bytes += bytes; } - ENV_BUG_ON(total_bytes != req->byte_length); + ENV_BUG_ON(total_bytes != req->bytes); ocf_req_forward_cache_put(req); } @@ -123,27 +123,27 @@ void ocf_engine_forward_cache_discard_req(struct ocf_request *req, { req->cache_forward_end = callback; - ocf_req_forward_cache_discard(req, req->byte_position, - req->byte_length); + ocf_req_forward_cache_discard(req, req->addr, + req->bytes); } void ocf_engine_forward_core_io_req(struct ocf_request *req, ocf_req_end_t callback) { ocf_core_stats_core_block_update(req->core, req->part_id, req->rw, - req->byte_length); + req->bytes); req->core_forward_end = callback; - ocf_req_forward_core_io(req, req->rw, req->byte_position, - req->byte_length, req->offset); + ocf_req_forward_core_io(req, req->rw, req->addr, + req->bytes, req->offset); } void ocf_engine_forward_core_flush_req(struct ocf_request *req, ocf_req_end_t callback) { ocf_core_stats_core_block_update(req->core, req->part_id, req->rw, - req->byte_length); + req->bytes); req->core_forward_end = callback; @@ -154,9 +154,9 @@ void ocf_engine_forward_core_discard_req(struct ocf_request *req, ocf_req_end_t callback) { ocf_core_stats_core_block_update(req->core, req->part_id, req->rw, - req->byte_length); + req->bytes); req->core_forward_end = callback; - ocf_req_forward_core_discard(req, req->byte_position, req->byte_length); + ocf_req_forward_core_discard(req, req->addr, req->bytes); } diff --git a/src/engine/engine_pt.c b/src/engine/engine_pt.c index f570e79..f15c055 100644 --- a/src/engine/engine_pt.c +++ b/src/engine/engine_pt.c @@ -79,7 +79,7 @@ int ocf_read_pt_do(struct ocf_request *req) ocf_engine_update_block_stats(req); ocf_core_stats_pt_block_update(req->core, req->part_id, req->rw, - req->byte_length); + req->bytes); ocf_core_stats_request_pt_update(req->core, req->part_id, req->rw, req->info.hit_no, req->core_line_count); diff --git a/src/engine/engine_rd.c b/src/engine/engine_rd.c index 6c6cd92..bbc90cb 100644 --- a/src/engine/engine_rd.c +++ b/src/engine/engine_rd.c @@ -65,7 +65,7 @@ static void _ocf_read_generic_miss_complete(struct ocf_request *req, int error) /* Copy data to the backfill buffer */ if (req->cp_data) { ctx_data_cpy(cache->owner, req->cp_data, req->data, 0, 0, - req->byte_length); + req->bytes); } req->complete(req, error); @@ -85,12 +85,12 @@ static inline void _ocf_read_generic_submit_miss(struct ocf_request *req) int ret; req->cp_data = ctx_data_alloc(cache->owner, - BYTES_TO_PAGES(req->byte_length)); + BYTES_TO_PAGES(req->bytes)); if (!req->cp_data) { /* If buffer allocation for backfill fails, ignore the error */ ocf_cache_log(cache, log_warn, "Backfill buffer allocation " "error (size %u)\n", - req->byte_length); + req->bytes); goto err_alloc; } diff --git a/src/engine/engine_wi.c b/src/engine/engine_wi.c index 5257af1..4804038 100644 --- a/src/engine/engine_wi.c +++ b/src/engine/engine_wi.c @@ -143,7 +143,7 @@ static int _ocf_write_wi_core_write(struct ocf_request *req) ocf_engine_update_block_stats(req); ocf_core_stats_pt_block_update(req->core, req->part_id, req->rw, - req->byte_length); + req->bytes); ocf_core_stats_request_pt_update(req->core, req->part_id, req->rw, req->info.hit_no, req->core_line_count); diff --git a/src/engine/engine_zero.c b/src/engine/engine_zero.c index ec98f45..6306a97 100644 --- a/src/engine/engine_zero.c +++ b/src/engine/engine_zero.c @@ -76,15 +76,15 @@ static inline void ocf_zero_map_info(struct ocf_request *req) if (map_idx == 0) { /* First */ - start_bit = BYTES_TO_SECTORS(req->byte_position) - % ocf_line_sectors(cache); + start_bit = (BYTES_TO_SECTORS(req->addr) + % ocf_line_sectors(cache)); } if (map_idx == (count - 1)) { /* Last */ - end_bit = BYTES_TO_SECTORS(req->byte_position + - req->byte_length - 1) % - ocf_line_sectors(cache); + end_bit = (BYTES_TO_SECTORS(req->addr + + req->bytes - 1) % + ocf_line_sectors(cache)); } ocf_metadata_flush_mark(cache, req, map_idx, INVALID, diff --git a/src/metadata/metadata_io.c b/src/metadata/metadata_io.c index 27524d8..e48d766 100644 --- a/src/metadata/metadata_io.c +++ b/src/metadata/metadata_io.c @@ -426,7 +426,7 @@ static int metadata_io_i_asynch(ocf_cache_t cache, ocf_queue_t queue, int dir, m_req->req.rw = dir; m_req->req.map = LIST_POISON1; m_req->req.alock_status = (uint8_t*)&m_req->alock_status; - m_req->req.io.flags = flags; + m_req->req.flags = flags; /* If req_count == io_count and count is not multiple of * max_count, for last we can allocate data smaller that diff --git a/src/metadata/metadata_passive_update.c b/src/metadata/metadata_passive_update.c index 30197e5..ac31d6b 100644 --- a/src/metadata/metadata_passive_update.c +++ b/src/metadata/metadata_passive_update.c @@ -30,8 +30,8 @@ static int passive_io_resume(struct ocf_request *req) struct ocf_request *master = req->master_io_req; ocf_cache_t cache = req->cache; struct ocf_metadata_ctrl *ctrl = cache->metadata.priv; - uint64_t io_start_page = BYTES_TO_PAGES(master->io.addr); - uint64_t io_pages_count = BYTES_TO_PAGES(master->io.bytes); + uint64_t io_start_page = BYTES_TO_PAGES(master->addr); + uint64_t io_pages_count = BYTES_TO_PAGES(master->bytes); uint64_t io_end_page = io_start_page + io_pages_count - 1; enum ocf_metadata_segment_id update_segments[] = { metadata_segment_sb_config, @@ -77,12 +77,12 @@ int ocf_metadata_passive_update(struct ocf_request *master) { ocf_cache_t cache = master->cache; struct ocf_metadata_ctrl *ctrl = cache->metadata.priv; - uint64_t io_start_page = BYTES_TO_PAGES(master->io.addr); - uint64_t io_end_page = io_start_page + BYTES_TO_PAGES(master->io.bytes); + uint64_t io_start_page = BYTES_TO_PAGES(master->addr); + uint64_t io_end_page = io_start_page + BYTES_TO_PAGES(master->bytes); struct ocf_request *req; int lock = 0; - if (master->io.dir == OCF_READ) { + if (master->rw == OCF_READ) { master->complete(master, 0); return 0; } @@ -92,14 +92,14 @@ int ocf_metadata_passive_update(struct ocf_request *master) return 0; } - if (master->io.addr % PAGE_SIZE || master->io.bytes % PAGE_SIZE) { + if (master->addr % PAGE_SIZE || master->bytes % PAGE_SIZE) { ocf_cache_log(cache, log_warn, "Metadata update not aligned to page size!\n"); master->complete(master, -OCF_ERR_INVAL); return -OCF_ERR_INVAL; } - if (master->io.bytes > MAX_PASSIVE_IO_SIZE) { + if (master->bytes > MAX_PASSIVE_IO_SIZE) { //FIXME handle greater IOs ocf_cache_log(cache, log_warn, "IO size exceedes max supported size!\n"); @@ -113,7 +113,7 @@ int ocf_metadata_passive_update(struct ocf_request *master) return -OCF_ERR_NO_MEM; } - req->io_queue = master->io.io_queue;; + req->io_queue = master->io_queue;; req->info.internal = true; req->engine_handler = passive_io_resume; req->rw = OCF_WRITE; diff --git a/src/metadata/metadata_raw.c b/src/metadata/metadata_raw.c index 2811409..24e8575 100644 --- a/src/metadata/metadata_raw.c +++ b/src/metadata/metadata_raw.c @@ -621,7 +621,7 @@ static int _raw_ram_flush_do_asynch(ocf_cache_t cache, result |= metadata_io_write_i_asynch(cache, req->io_queue, ctx, raw->ssd_pages_offset + start_page, count, - req->io.flags, + req->flags, _raw_ram_flush_do_asynch_fill, _raw_ram_flush_do_asynch_io_complete, raw->mio_conc); diff --git a/src/ocf_cache.c b/src/ocf_cache.c index 33aeda1..b3d0dee 100644 --- a/src/ocf_cache.c +++ b/src/ocf_cache.c @@ -333,8 +333,8 @@ static void ocf_cache_volume_submit_io(ocf_io_t io) env_atomic_set(&req->req_remaining, 3); req->cache_forward_end = ocf_cache_io_complete; - ocf_req_forward_cache_io(req, req->rw, req->byte_position, - req->byte_length, req->offset); + ocf_req_forward_cache_io(req, req->rw, req->addr, + req->bytes, req->offset); req->complete = ocf_cache_io_complete; result = ocf_metadata_passive_update(req); @@ -381,8 +381,8 @@ static void ocf_cache_volume_submit_discard(ocf_io_t io) } req->cache_forward_end = ocf_cache_volume_io_complete_generic; - ocf_req_forward_cache_discard(req, req->byte_position, - req->byte_length); + ocf_req_forward_cache_discard(req, req->addr, + req->bytes); } /* *** VOLUME OPS *** */ diff --git a/src/ocf_core.c b/src/ocf_core.c index c4e3415..d78f982 100644 --- a/src/ocf_core.c +++ b/src/ocf_core.c @@ -182,16 +182,16 @@ static inline int ocf_core_validate_io(ocf_io_t io) ocf_volume_t volume = ocf_io_get_volume(io); ocf_core_t core = ocf_volume_to_core(volume); - if (req->io.addr + req->io.bytes > ocf_volume_get_length(volume)) + if (req->addr + req->bytes > ocf_volume_get_length(volume)) return -OCF_ERR_INVAL; if (req->io.io_class >= OCF_USER_IO_CLASS_MAX) return -OCF_ERR_INVAL; - if (req->io.dir != OCF_READ && req->io.dir != OCF_WRITE) + if (req->rw != OCF_READ && req->rw != OCF_WRITE) return -OCF_ERR_INVAL; - if (!req->io.io_queue) + if (!req->io_queue) return -OCF_ERR_INVAL; if (!req->io.end) @@ -200,7 +200,7 @@ static inline int ocf_core_validate_io(ocf_io_t io) /* Core volume I/O must not be queued on management queue - this would * break I/O accounting code, resulting in use-after-free type of errors * after cache detach, core remove etc. */ - if (req->io.io_queue == ocf_core_get_cache(core)->mngt_queue) + if (req->io_queue == ocf_core_get_cache(core)->mngt_queue) return -OCF_ERR_INVAL; return 0; @@ -323,7 +323,7 @@ static void ocf_core_volume_submit_io(ocf_io_t io) err: ocf_io_end_func(io, ret); - ocf_io_put(io); + ocf_io_put(req); } static void ocf_core_volume_submit_flush(ocf_io_t io) @@ -367,7 +367,7 @@ static void ocf_core_volume_submit_discard(ocf_io_t io) OCF_CHECK_NULL(io); - if (req->io.bytes == 0) { + if (req->bytes == 0) { ocf_io_end_func(io, -OCF_ERR_INVAL); return; } diff --git a/src/ocf_io.c b/src/ocf_io.c index d7510e1..c8a801e 100644 --- a/src/ocf_io.c +++ b/src/ocf_io.c @@ -32,7 +32,18 @@ void *ocf_io_allocator_default_new(ocf_io_allocator_t allocator, ocf_volume_t volume, ocf_queue_t queue, uint64_t addr, uint32_t bytes, uint32_t dir) { - return env_allocator_new(allocator->priv); + struct ocf_request *req; + + req = env_allocator_new(allocator->priv); + if (!req) + return NULL; + + req->io_queue = queue; + req->addr = addr; + req->bytes = bytes; + req->rw = dir; + + return req; } void ocf_io_allocator_default_del(ocf_io_allocator_t allocator, void *obj) @@ -80,12 +91,8 @@ ocf_io_t ocf_io_new(ocf_volume_t volume, ocf_queue_t queue, env_atomic_set(&req->io.ref_count, 1); req->io.volume = volume; - req->io.io_queue = queue; - req->io.addr = addr; - req->io.bytes = bytes; - req->io.dir = dir; req->io.io_class = io_class; - req->io.flags = flags; + req->flags = flags; return req; } diff --git a/src/ocf_request.c b/src/ocf_request.c index 0ed6bac..d24fecc 100644 --- a/src/ocf_request.c +++ b/src/ocf_request.c @@ -92,8 +92,8 @@ static inline void ocf_req_init(struct ocf_request *req, ocf_cache_t cache, env_atomic_set(&req->ref_count, 1); - req->byte_position = addr; - req->byte_length = bytes; + req->addr = addr; + req->bytes = bytes; req->rw = rw; } @@ -326,7 +326,7 @@ int ocf_req_alloc_map_discard(struct ocf_request *req) ENV_BUILD_BUG_ON(MAX_TRIM_RQ_SIZE / ocf_cache_line_size_4 * sizeof(struct ocf_map_info) > 4 * KiB); - if (req->byte_length <= MAX_TRIM_RQ_SIZE) + if (req->bytes <= MAX_TRIM_RQ_SIZE) return ocf_req_alloc_map(req); /* @@ -334,9 +334,9 @@ int ocf_req_alloc_map_discard(struct ocf_request *req) * can handle more than MAX_TRIM_RQ_SIZE, so for these cache line sizes * discard request uses only part of the mapping array. */ - req->byte_length = MAX_TRIM_RQ_SIZE; + req->bytes = MAX_TRIM_RQ_SIZE; req->core_line_last = ocf_bytes_2_lines(req->cache, - req->byte_position + req->byte_length - 1); + req->addr + req->bytes - 1); req->core_line_count = req->core_line_last - req->core_line_first + 1; return ocf_req_alloc_map(req); @@ -596,7 +596,7 @@ uint64_t ocf_forward_get_flags(ocf_forward_token_t token) { struct ocf_request *req = (struct ocf_request *)(token & ~1); - return (token & 1) ? 0 : req->io.flags; + return (token & 1) ? 0 : req->flags; } static inline void _ocf_forward_get(ocf_forward_token_t token) diff --git a/src/ocf_request.h b/src/ocf_request.h index 70d9868..ce62ac7 100644 --- a/src/ocf_request.h +++ b/src/ocf_request.h @@ -123,31 +123,12 @@ struct ocf_request; typedef int (*ocf_req_cb)(struct ocf_request *req); struct ocf_request_io { - /** - * @brief OCF IO destination address - */ - uint64_t addr; - - /** - * @brief OCF IO flags - */ - uint64_t flags; - - /** - * @brief OCF IO size in bytes - */ - uint32_t bytes; /** * @brief OCF IO destination class */ uint8_t io_class; - /** - * @brief OCF IO direction - */ - uint8_t dir:1; - /** * @brief OCF IO reference count */ @@ -158,11 +139,6 @@ struct ocf_request_io { */ ocf_volume_t volume; - /** - * @brief Queue handle - */ - ocf_queue_t io_queue; - /** * @brief OCF IO start function */ @@ -247,27 +223,30 @@ struct ocf_request { ctx_data_t *cp_data; /*!< Copy of request data */ - uint64_t byte_position; - /*!< LBA byte position of request in core domain */ - uint64_t core_line_first; /*! First core line */ uint64_t core_line_last; /*! Last core line */ - uint32_t byte_length; - /*!< Byte length of OCF request */ - uint32_t core_line_count; /*! Core line count */ uint32_t alloc_core_line_count; /*! Number of core lines at time of request allocation */ + uint64_t addr; + /*!< LBA byte position of request in core domain */ + + uint32_t bytes; + /*!< Byte length of OCF request */ + uint32_t offset; /*!< Offset into request data*/ + uint64_t flags; + /*!< IO flags */ + int error; /*!< This filed indicates an error for OCF request */ diff --git a/src/ocf_seq_cutoff.c b/src/ocf_seq_cutoff.c index f92aac7..6b7da96 100644 --- a/src/ocf_seq_cutoff.c +++ b/src/ocf_seq_cutoff.c @@ -209,7 +209,7 @@ bool ocf_core_seq_cutoff_check(ocf_core_t core, struct ocf_request *req) env_rwlock_read_lock(&req->io_queue->seq_cutoff->lock); result = ocf_core_seq_cutoff_base_check(req->io_queue->seq_cutoff, - req->byte_position, req->byte_length, req->rw, + req->addr, req->bytes, req->rw, threshold, &queue_stream); env_rwlock_read_unlock(&req->io_queue->seq_cutoff->lock); if (queue_stream) @@ -217,7 +217,7 @@ bool ocf_core_seq_cutoff_check(ocf_core_t core, struct ocf_request *req) env_rwlock_read_lock(&core->seq_cutoff->lock); result = ocf_core_seq_cutoff_base_check(core->seq_cutoff, - req->byte_position, req->byte_length, req->rw, + req->addr, req->bytes, req->rw, threshold, &core_stream); env_rwlock_read_unlock(&core->seq_cutoff->lock); @@ -309,7 +309,7 @@ void ocf_core_seq_cutoff_update(ocf_core_t core, struct ocf_request *req) if (policy == ocf_seq_cutoff_policy_never) return; - if (req->byte_length >= threshold && promote_on_threshold) + if (req->bytes >= threshold && promote_on_threshold) promote = true; if (promotion_count == 1) @@ -318,7 +318,7 @@ void ocf_core_seq_cutoff_update(ocf_core_t core, struct ocf_request *req) if (req->seq_cutoff_core || promote) { env_rwlock_write_lock(&core->seq_cutoff->lock); stream = ocf_core_seq_cutoff_base_update(core->seq_cutoff, - req->byte_position, req->byte_length, req->rw, + req->addr, req->bytes, req->rw, promote); env_rwlock_write_unlock(&core->seq_cutoff->lock); @@ -328,7 +328,7 @@ void ocf_core_seq_cutoff_update(ocf_core_t core, struct ocf_request *req) env_rwlock_write_lock(&req->io_queue->seq_cutoff->lock); stream = ocf_core_seq_cutoff_base_update(req->io_queue->seq_cutoff, - req->byte_position, req->byte_length, req->rw, true); + req->addr, req->bytes, req->rw, true); env_rwlock_write_unlock(&req->io_queue->seq_cutoff->lock); if (stream->bytes >= threshold && promote_on_threshold) diff --git a/src/ocf_stats.c b/src/ocf_stats.c index 4d0ecea..f4c0d0f 100644 --- a/src/ocf_stats.c +++ b/src/ocf_stats.c @@ -431,14 +431,14 @@ void ocf_core_update_stats(ocf_core_t core, ocf_io_t io) stats = &core->counters->debug_stats; - idx = to_packet_idx(req->io.bytes); - if (req->io.dir == OCF_WRITE) + idx = to_packet_idx(req->bytes); + if (req->rw == OCF_WRITE) env_atomic64_inc(&stats->write_size[idx]); else env_atomic64_inc(&stats->read_size[idx]); - idx = to_align_idx(req->io.addr); - if (req->io.dir == OCF_WRITE) + idx = to_align_idx(req->addr); + if (req->rw == OCF_WRITE) env_atomic64_inc(&stats->write_align[idx]); else env_atomic64_inc(&stats->read_align[idx]); diff --git a/src/ocf_volume.c b/src/ocf_volume.c index 580c59f..0b9ace4 100644 --- a/src/ocf_volume.c +++ b/src/ocf_volume.c @@ -300,8 +300,8 @@ void ocf_volume_submit_io(ocf_io_t io) volume->type->properties->ops.submit_io(io); } else { req->volume_forward_end = ocf_volume_req_forward_complete; - ocf_req_forward_volume_io(req, volume, req->io.dir, req->io.addr, - req->io.bytes, req->offset); + ocf_req_forward_volume_io(req, volume, req->rw, req->addr, + req->bytes, req->offset); } } @@ -338,7 +338,7 @@ void ocf_volume_submit_discard(ocf_io_t io) } else { req->volume_forward_end = ocf_volume_req_forward_complete; ocf_req_forward_volume_discard(req, volume, - req->io.addr, req->io.bytes); + req->addr, req->bytes); } } diff --git a/src/utils/utils_cache_line.h b/src/utils/utils_cache_line.h index ccfafac..87f3501 100644 --- a/src/utils/utils_cache_line.h +++ b/src/utils/utils_cache_line.h @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2021 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -192,17 +193,16 @@ static inline void ocf_purge_map_info(struct ocf_request *req) if (map_idx == 0) { /* First */ - start_bit = BYTES_TO_SECTORS(req->byte_position) - % ocf_line_sectors(cache); - + start_bit = (BYTES_TO_SECTORS(req->addr) + % ocf_line_sectors(cache)); } if (map_idx == (count - 1)) { /* Last */ - end_bit = BYTES_TO_SECTORS(req->byte_position + - req->byte_length - 1) % - ocf_line_sectors(cache); + end_bit = (BYTES_TO_SECTORS(req->addr + + req->bytes - 1) % + ocf_line_sectors(cache)); } ocf_metadata_start_collision_shared_access(cache, map[map_idx]. @@ -218,8 +218,8 @@ static inline uint8_t ocf_map_line_start_sector(struct ocf_request *req, uint32_t line) { if (line == 0) { - return BYTES_TO_SECTORS(req->byte_position) - % ocf_line_sectors(req->cache); + return (BYTES_TO_SECTORS(req->addr) + % ocf_line_sectors(req->cache)); } return 0; @@ -229,9 +229,8 @@ static inline uint8_t ocf_map_line_end_sector(struct ocf_request *req, uint32_t line) { if (line == req->core_line_count - 1) { - return BYTES_TO_SECTORS(req->byte_position + - req->byte_length - 1) % - ocf_line_sectors(req->cache); + return (BYTES_TO_SECTORS(req->addr + req->bytes - 1) % + ocf_line_sectors(req->cache)); } return ocf_line_end_sector(req->cache); diff --git a/src/utils/utils_cleaner.c b/src/utils/utils_cleaner.c index 9a0c249..bcb2c8b 100644 --- a/src/utils/utils_cleaner.c +++ b/src/utils/utils_cleaner.c @@ -560,7 +560,7 @@ static int _ocf_cleaner_fire_cache(struct ocf_request *req) ocf_part_id_t part_id; req->cache_forward_end = _ocf_cleaner_cache_io_end; - req->byte_length = ocf_line_size(cache); + req->bytes = ocf_line_size(cache); ocf_req_forward_cache_get(req); for (i = 0; i < req->core_line_count; i++, iter++) { @@ -581,7 +581,7 @@ static int _ocf_cleaner_fire_cache(struct ocf_request *req) ocf_core_stats_cache_block_update(req->core, part_id, OCF_READ, ocf_line_size(cache)); - req->byte_position = iter->core_line * ocf_line_size(cache); + req->addr = iter->core_line * ocf_line_size(cache); ocf_req_forward_cache_io(req, OCF_READ, addr, ocf_line_size(cache), offset); @@ -624,7 +624,7 @@ static int _ocf_cleaner_do_fire(struct ocf_request *req) int result; req->engine_handler = _ocf_cleaner_check_map; - req->byte_position = req->core_line_count * ocf_line_size(req->cache); + req->addr = req->core_line_count * ocf_line_size(req->cache); master = (req->master_io_req_type == ocf_cleaner_req_type_master) ? req : req->master_io_req; diff --git a/src/utils/utils_io.c b/src/utils/utils_io.c index 35651a3..d180d12 100644 --- a/src/utils/utils_io.c +++ b/src/utils/utils_io.c @@ -184,8 +184,8 @@ void ocf_submit_cache_page(ocf_cache_t cache, uint64_t addr, int dir, req->cache_forward_end = ocf_submit_cache_page_end; req->priv = context; req->rw = dir; - req->byte_position = addr; - req->byte_length = PAGE_SIZE; + req->addr = addr; + req->bytes = PAGE_SIZE; ocf_req_forward_cache_io(req, dir, addr, PAGE_SIZE, 0); diff --git a/src/utils/utils_parallelize.c b/src/utils/utils_parallelize.c index 85eba9e..53160d3 100644 --- a/src/utils/utils_parallelize.c +++ b/src/utils/utils_parallelize.c @@ -47,7 +47,7 @@ static int _ocf_parallelize_hndl(struct ocf_request *req) int error; error = parallelize->handle(parallelize, parallelize->priv, - req->byte_position, parallelize->shards_cnt); + req->addr, parallelize->shards_cnt); env_atomic_cmpxchg(¶llelize->error, 0, error); @@ -113,7 +113,7 @@ int ocf_parallelize_create(ocf_parallelize_t *parallelize, tmp_parallelize->reqs[i]->info.internal = true; tmp_parallelize->reqs[i]->engine_handler = _ocf_parallelize_hndl; - tmp_parallelize->reqs[i]->byte_position = i; + tmp_parallelize->reqs[i]->addr = i; tmp_parallelize->reqs[i]->priv = tmp_parallelize; }