Skip to content

Commit 08eb006

Browse files
Merge pull request #854 from robertbaldyga/request-cleanup
A little cleanup between ocf_request and ocf_io
2 parents 0e294fc + c029f78 commit 08eb006

File tree

5 files changed

+17
-51
lines changed

5 files changed

+17
-51
lines changed

inc/ocf_io.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,6 @@ typedef void (*ocf_handle_io_t)(ocf_io_t io, void *opaque);
4545
*/
4646
typedef void (*ocf_end_io_t)(ocf_io_t io, void *priv1, void *priv2, int error);
4747

48-
/**
49-
* @brief Increase reference counter in OCF IO
50-
*
51-
* @note Wrapper for get IO operation
52-
*
53-
* @param[in] io OCF IO
54-
*/
55-
void ocf_io_get(ocf_io_t io);
56-
5748
/**
5849
* @brief Decrease reference counter in OCF IO
5950
*

src/ocf_core.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ static void ocf_req_complete(struct ocf_request *req, int error)
213213

214214
dec_counter_if_req_was_dirty(req);
215215

216-
/* Invalidate OCF IO, it is not valid after completion */
217-
ocf_io_put(req);
216+
ocf_req_put(req);
218217
}
219218

220219
static inline ocf_req_cache_mode_t _ocf_core_req_resolve_fast_mode(
@@ -261,7 +260,7 @@ static void ocf_core_volume_submit_io(ocf_io_t io)
261260
struct ocf_request *req = ocf_io_to_req(io);
262261
ocf_core_t core;
263262
ocf_cache_t cache;
264-
int ret;
263+
int ret, fastpath;
265264

266265
OCF_CHECK_NULL(io);
267266

@@ -281,7 +280,7 @@ static void ocf_core_volume_submit_io(ocf_io_t io)
281280

282281
req->complete = ocf_req_complete;
283282

284-
ocf_io_get(io);
283+
ocf_req_get(req);
285284

286285
if (unlikely(req->d2c)) {
287286
ocf_core_update_stats(core, io);
@@ -303,15 +302,15 @@ static void ocf_core_volume_submit_io(ocf_io_t io)
303302
* sequential cutoff info */
304303
ocf_req_get(req);
305304

306-
if (ocf_core_submit_io_fast(req, cache) == OCF_FAST_PATH_YES) {
307-
ocf_core_seq_cutoff_update(core, req);
308-
ocf_req_put(req);
309-
return;
310-
}
305+
fastpath = ocf_core_submit_io_fast(req, cache);
311306

307+
ocf_core_seq_cutoff_update(core, req);
312308
ocf_req_put(req);
309+
310+
if (fastpath == OCF_FAST_PATH_YES)
311+
return;
312+
313313
ocf_req_clear_map(req);
314-
ocf_core_seq_cutoff_update(core, req);
315314

316315
ret = ocf_engine_hndl_req(req);
317316
if (ret) {
@@ -323,7 +322,7 @@ static void ocf_core_volume_submit_io(ocf_io_t io)
323322

324323
err:
325324
ocf_io_end_func(io, ret);
326-
ocf_io_put(req);
325+
ocf_req_put(req);
327326
}
328327

329328
static void ocf_core_volume_submit_flush(ocf_io_t io)
@@ -349,7 +348,7 @@ static void ocf_core_volume_submit_flush(ocf_io_t io)
349348

350349
req->complete = ocf_req_complete;
351350

352-
ocf_io_get(io);
351+
ocf_req_get(req);
353352

354353
if (unlikely(req->d2c)) {
355354
ocf_d2c_flush_fast(req);
@@ -387,7 +386,7 @@ static void ocf_core_volume_submit_discard(ocf_io_t io)
387386

388387
req->complete = ocf_req_complete;
389388

390-
ocf_io_get(io);
389+
ocf_req_get(req);
391390

392391
if (unlikely(req->d2c)) {
393392
ocf_d2c_discard_fast(req);

src/ocf_io.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ ocf_io_t ocf_io_new(ocf_volume_t volume, ocf_queue_t queue,
8989
return NULL;
9090
}
9191

92-
env_atomic_set(&req->io.ref_count, 1);
9392
req->io.volume = volume;
9493
req->io.io_class = io_class;
9594
req->flags = flags;
@@ -125,22 +124,10 @@ uint32_t ocf_io_get_offset(ocf_io_t io)
125124
return req->offset;
126125
}
127126

128-
void ocf_io_get(ocf_io_t io)
129-
{
130-
struct ocf_request *req = ocf_io_to_req(io);
131-
132-
env_atomic_inc_return(&req->io.ref_count);
133-
}
134-
135127
void ocf_io_put(ocf_io_t io)
136128
{
137129
struct ocf_request *req = ocf_io_to_req(io);
138-
struct ocf_volume *volume;
139-
140-
if (env_atomic_dec_return(&req->io.ref_count))
141-
return;
142-
143-
volume = req->io.volume;
130+
struct ocf_volume *volume = req->io.volume;
144131

145132
ocf_io_allocator_del(&volume->type->allocator, (void *)req);
146133

src/ocf_request.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright(c) 2012-2022 Intel Corporation
3-
* Copyright(c) 2024 Huawei Technologies
3+
* Copyright(c) 2024-2025 Huawei Technologies
44
* SPDX-License-Identifier: BSD-3-Clause
55
*/
66

@@ -129,11 +129,6 @@ struct ocf_request_io {
129129
*/
130130
uint8_t io_class;
131131

132-
/**
133-
* @brief OCF IO reference count
134-
*/
135-
env_atomic ref_count;
136-
137132
/**
138133
* @brief Front volume handle
139134
*/
@@ -259,6 +254,9 @@ struct ocf_request {
259254
uint8_t rw : 1;
260255
/*!< Indicator of IO direction - Read/Write */
261256

257+
uint8_t alock_rw: 1;
258+
/*!< Read/Write mode for alock*/
259+
262260
uint8_t d2c : 1;
263261
/**!< request affects metadata cachelines (is not direct-to-core) */
264262

@@ -300,9 +298,6 @@ struct ocf_request {
300298

301299
ocf_req_cache_mode_t cache_mode;
302300

303-
uint64_t timestamp;
304-
/*!< Tracing timestamp */
305-
306301
ocf_queue_t io_queue;
307302
/*!< I/O queue handle for which request should be submitted */
308303

@@ -317,9 +312,6 @@ struct ocf_request {
317312

318313
struct ocf_req_discard_info discard;
319314

320-
uint32_t alock_rw;
321-
/*!< Read/Write mode for alock*/
322-
323315
uint8_t *alock_status;
324316
/*!< Mapping for locked/unlocked alock entries */
325317

tests/functional/pyocf/types/io.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ def del_object(self):
8181
def put(self):
8282
OcfLib.getInstance().ocf_io_put(byref(self))
8383

84-
def get(self):
85-
OcfLib.getInstance().ocf_io_get(byref(self))
86-
8784
@staticmethod
8885
@END
8986
def c_end(io, priv1, priv2, err):

0 commit comments

Comments
 (0)