Commit Graph

1056 Commits

Author SHA1 Message Date
Rafal Stefanowski
194e5a9172 Use cache_error and core_error flags only in WT
Signed-off-by: Rafal Stefanowski <rafal.stefanowski@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-09-18 14:04:08 +02:00
Rafal Stefanowski
2761540326 Report cache and core errors separately
Signed-off-by: Rafal Stefanowski <rafal.stefanowski@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-18 08:01:08 +02:00
Roel Apfelbaum
73387c8f26 Support set_data() with offset > 0 for core
Signed-off-by: Roel Apfelbaum <roel.apfelbaum@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-17 16:26:27 +02:00
Avi Halaf
bd06b1c9b8 Refactor resolving fast path
Signed-off-by: Avi Halaf <avi.halaf@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-10 16:47:40 +02:00
Michal Mielewczyk
ca7f3651e9 discard engine: lookup without updating hotness
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-10 15:20:51 +02:00
Michal Mielewczyk
0df0eec7f0 Uncouple lookup() and set_hot()
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-10 15:20:51 +02:00
Rafal Stefanowski
7dfe70f69b Fix discard step callback refcount
Signed-off-by: Rafal Stefanowski <rafal.stefanowski@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-10 15:20:51 +02:00
Robert Baldyga
1bcd949a89 Rename engine_ops to engine_flush
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-10 15:16:33 +02:00
Amir Haroush
7930ef9c21 cleaner: skip metadata flush in volatile mode
Signed-off-by: Amir Haroush <amir.haroush@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-10 12:32:25 +02:00
Robert Baldyga
3ebdf38aa9 Introduce ocf_dbg_cache_is_settled()
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-09-09 15:28:11 +02:00
Michal Mielewczyk
f4d9f0dcf6 Introduce ocf_refcnt_zeroed()
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-09 15:28:09 +02:00
Robert Baldyga
dc58eeae9b Introduce d2c request
This avoids unnecessary map allocation and initialization of unused fields of
request structure. It also allows to track thier number separately from
the regular requests

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-09 12:45:51 +02:00
Robert Baldyga
8b93b699c3 Eliminate queue -> cache mapping
Eliminate need to resolve cache based on the queue. This allows to share
the queue between cache instances. The queue still holds pointer to
a cache that owns the queue, but no management or io path relies on the
queue -> cache mapping.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-09 12:45:51 +02:00
Robert Baldyga
460cd461d3 Allocate requests for management path separately
Management path does not benefit much from mpools, as number of requests
allocated is very small. It's less restrictive (mngt_queue does not have
single-CPU affinity) thus avoiding mpool usage in management path allows
to introduce additional restrictions on mpool, leading to I/O performance
improvement.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-09 12:45:51 +02:00
Sara Merzel
835eb708b5 Introduce pass-through block stats
Signed-off-by: Sara Merzel <sara.merzel@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-06 14:47:02 +02:00
Robert Baldyga
3ebf6e64c1
Merge pull request #808 from mmichal10/vol_and_req_fixes
Volume improvements
2024-09-06 14:24:48 +02:00
Amir Haroush
ed62866324 Modify ocf_mngt_get_ram_needed to never fail
Signed-off-by: Amir Haroush <amir.haroush@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-09-05 15:41:54 +02:00
Gershon Geva
2096e34489 Pass user's params when opening a core volume
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-04 20:29:41 +02:00
Robert Baldyga
87b16aef6a Do not deinit user volume
The user is supposed to deinit/destroy it.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-03 16:10:56 +02:00
Robert Baldyga
3d99a2c938 Add missing ocf_volume_init() calls
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-03 16:10:56 +02:00
Robert Baldyga
8aa2d0fb63 Remove unused attach context property
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-03 16:10:56 +02:00
Robert Baldyga
5e6a90a293 parallelize: Fix race condition
In situation when all the shards finish their work before parallelize
loop does it's final loop condition check, which involves access to
parallelize object, it's possible that parallelize object will be
deinitialized before this final access.

Increasing refcount by 1 before running parallelize and decreasing it
only after the loop is finished addresses this problem.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-02 12:22:11 +02:00
Robert Baldyga
55b99518ed parallelize: Create number of shards requested by user
In some scenarios running the exact number of shards, regardless of
number of available queues is crucial for correctness of operation.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-02 12:22:11 +02:00
Robert Baldyga
5c714cb3de parallelize: Use mngt_queue only as a fallback
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-02 12:22:11 +02:00
Michael Lyulko
470204ac70 Count deferred requests as full miss
Otherwise, it may increase the number of hits, while the overall performance
has not been improved. This way, the hit rate is more correlated with
the performance changes.

Signed-off-by: Michael Lyulko <michael.lyulko@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-02 09:21:28 +02:00
Michal Mielewczyk
53756e81be Queue visitor API
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-08-29 10:45:57 +02:00
Robert Baldyga
b00ab08473 Introduce io_queues_lock
The queues can be created and destroyed dynamically at any point in
the cache lifetime, and this can happen from different execution contexts,
thus there is a need to protect the queue_list with a lock.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-08-29 10:45:36 +02:00
Robert Baldyga
8db93260ae Avoid adding mngt_queue to io_queues list
Previously every created queue was added to io_queues list, which
made mngt_queue being used in ocf_parallelize. Change mngt_queue creation
API so that mngt_queue is not added to the list and doesn't have
unnecessary functionalities initialized.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-08-29 10:45:26 +02:00
Michael Lyulko
1d903f4038 Fix debug stats compilation
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-08-29 10:16:26 +02:00
Michal Mielewczyk
0a9a173f33 Add missing flush_mutext destroy
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-08-29 10:15:08 +02:00
Michal Mielewczyk
2221a7bdf8 Add missing cache lock deinit
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-08-29 09:52:05 +02:00
Michal Mielewczyk
28f679cc91 Add missing cache unlock
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-08-29 09:52:05 +02:00
Michal Mielewczyk
a542cfa690 Refactor cache_trylock()
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-08-29 09:52:05 +02:00
Michal Mielewczyk
1c7de189e2 Get rid of non-OCF error codes
Let's put an end to random crashes and vague error messages in pyocf!

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-08-29 08:27:51 +02:00
Michal Mielewczyk
d883a40dbc cleaner: refactor completion function
The completion function should be the same either when it is called from
the queue context or from currnet context

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-08-27 15:20:02 +02:00
Michal Mielewczyk
736665af47 cleaner: Fix master request refcnt
Commit db6b009ef introduced changes in managing the master request life cycle,
but apparently not all paths have been updated. This change removes a redundant
ocf_req_get() before sending the requets into a queue

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-08-27 07:44:09 +02:00
Michal Mielewczyk
312b32ad61 cleaner: Fix tracking in-flight cache requests
When flushing a request, the number of cache reads is unknown until all cache
lines are locked and the IOs are actually submitted.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-08-19 22:10:45 +02:00
Robert Baldyga
5b2f26decf
Merge pull request #800 from robertbaldyga/redesign-queue-api
Redesign queue API
2024-08-02 14:43:52 +02:00
Ian Levine
ac1b6b774a Added a priority queue for the request instead of push front
Now the request can be pushed to a high priority queue (instead of ocf_queue_push_req_front)
and to a low priority queue (instead of ocf_queue_push_req_back).
Both functions were merged into one function (ocf_queue_push_req) and instead of the
allow_sync parameter there is now a flags parameter that can be an OR combination of
OCF_QUEUE_ALLOW_SYNC and OCF_QUEUE_PRIO_HIGH

Signed-off-by: Ian Levine <ian.levine@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-08-02 12:53:16 +02:00
Ian Levine
4f2d5c22d6 Move and rename ocf_engine_pop_req from cache_engine to ocf_queue_pop_req in ocf_queue
Signed-off-by: Ian Levine <ian.levine@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-08-02 12:53:16 +02:00
Ian Levine
038126e9ab Move and rename ocf_engine_push_req_* from engine_common to ocf_queue_push_req_* in ocf_queue
Signed-off-by: Ian Levine <ian.levine@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-08-02 12:53:16 +02:00
Ian Levine
de32a9649a Rename ocf_engine_cb to ocf_req_cb and move it from engine_common.h to ocf_request.h
Signed-off-by: Ian Levine <ian.levine@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-08-02 12:53:10 +02:00
Robert Baldyga
40ff7d2dcf
Merge pull request #799 from Open-CAS/cache_detach
Implement cache detach/attach
2024-07-31 06:54:08 +02:00
Robert Baldyga
218e9c5723 Revert "cleaner: Remove complete_queue"
This functionality is used by cleaning policies via cmpl_queue
to reschedule the completion, so that we avoid unlocking mutex in
the cleaner completion from interrupt context of IO completion.

This reverts commit 1e5eda68a7.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-07-26 10:35:23 +02:00
Robert Baldyga
1e5eda68a7 cleaner: Remove complete_queue
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-07-12 17:38:17 +02:00
Robert Baldyga
db6b009ef5 cleaner: Simplify master request life cycle management
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-07-12 17:38:17 +02:00
Robert Baldyga
3300dbd4e7 cleaner: Rework request allocation
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-07-12 17:38:17 +02:00
Robert Baldyga
3248c85828 cleaner: Skip cleaner iteration if the map is empty
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-07-12 17:38:17 +02:00
Robert Baldyga
dfb2e1a8d5 cleaner: Check mapping after taking cache line lock
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-07-12 17:38:13 +02:00
Robert Baldyga
0a13bea889 cleaner: Skip filling the tail of the request map
Simply update req->core_line_count instead.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-07-12 13:23:35 +02:00
Robert Baldyga
2b94a3ab31 cleaner: Move sort functionality to flush_data abstraction
The flush_data is used by ocf_cleaner_do_flush_data_async(), which means
that callers of ocf_cleaner_fire() are now expected to guarantee that
entries are returned by getter in a sorted order. Currently the only case
when ocf_cleaner_fire() is called directly is for request cleaning, and
the request map is sorted by definition.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-07-12 13:23:35 +02:00
Robert Baldyga
dd4add45e1 lru: Use common flush_data abstraction for cleaning
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-07-12 13:23:35 +02:00
Robert Baldyga
43cc487c40 lru: Move partition runtime structures outside of metadata
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-07-12 13:23:29 +02:00
Michal Mielewczyk
83ec255458 Disable changing cache params for detached cache
Majority of management operations should be blocked for detached cache,
although adding and removing cores should be possible.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-07-10 16:19:37 +02:00
Michal Mielewczyk
f1bfd94c98 Enable IO to detached cache instance
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-07-10 16:18:44 +02:00
Michal Mielewczyk
de07458ff2 Common context for cache stop and cache detach
Stop and cache detach were already sharing contexts implicitly, which allowed
to reuse some functions in both pipelines. However, changing the context structs
could lead to not obvious bugs.

To prevent such errors both methods now share context structure explicitly

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-07-10 16:18:33 +02:00
Michal Mielewczyk
09335cd6f2 Update cache's state after detach
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-07-10 16:18:28 +02:00
Michal Mielewczyk
695d77e3b5 Apply cache state API
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-07-10 16:18:23 +02:00
Michal Mielewczyk
2f0b86f5ca Extend cache state API
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-07-10 16:18:17 +02:00
Michal Mielewczyk
047e07c062 Rename cache "initializing" state to "detached"
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-07-10 16:18:04 +02:00
Michal Mielewczyk
d3c11a983b Update cache state when stopping uninited instance
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-07-10 16:16:31 +02:00
Michal Mielewczyk
3f41a35f30 Patch detached cache API
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-07-10 16:14:33 +02:00
Michal Mielewczyk
41224c61c0 Track max number of cores for atomic volume
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-07-10 16:13:15 +02:00
Michal Mielewczyk
2a97de8792 Detach finish: destroy stop pipeline before cmpl
'stop_pipeline' filed may be reused during cache lifetime (e.g. when cache is
detached and attached again - the pipeline would be freed and then
re-allocated). Calling completion after detach before freeing the pipeline may
lead to race condition.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-07-10 11:35:42 +02:00
Robert Baldyga
d7fe7c05f1 Add missing ocf_cache_mode_t to ocf_req_cache_mode_t conversions
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-07-05 16:59:05 +02:00
Robert Baldyga
168ecd0075 Add missing "static" to the local function
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-05-11 00:59:39 +02:00
Robert Baldyga
578f4b6591 Add missing headers
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-05-11 00:51:29 +02:00
Robert Baldyga
43608fc812 Remove unused function
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-05-11 00:50:34 +02:00
Robert Baldyga
253734b160 Move misplaced function declaration to the appropriate header
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-05-11 00:49:52 +02:00
Robert Baldyga
dc3b581e38 Move declaration to the right header
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-05-11 00:49:21 +02:00
Robert Baldyga
527e3deb74 Remove accidentally added .swp file
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-05-11 00:35:59 +02:00
Robert Baldyga
5710ca8b4a Fix compilation
Signed-off-by: Robert Baldyga <robert.baldyga@open-cas.com>
2024-04-01 18:27:25 +00:00
Amir Haroush
c85a01473f Fix wrong order call to ocf_alock_waitlist_remove_entry()
Signed-off-by: Amir Haroush <amir.haroush@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-03-21 21:20:11 +01:00
Robert Baldyga
2398412622 cleaner: Unlock cache mngt lock from queue context
Cache mngt lock cannot be unlocked from io completion context (which is
potentially atomic context) as it may involve sleeping operations.
Modify cleaner utility to support rescheduling to queue context before
calling the completion. Update cleaning policies to use that option.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-03-21 15:25:18 +01:00
Robert Baldyga
fd489e3a30 Fix potential deadlock in discard
HB lock takes inclusive metadata lock, which is taken also by metadata
flush, thus trying to call metadata flush under HB lock attempts to take
this lock recursively. In that case, if in the meantime some other thread
would try to take exclusive metadata lock, the inner inclusive lock would
block (because the lock keeps the order), with outer inclusive lock still
held, leading to a deadlock.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-03-20 23:35:46 +01:00
Robert Baldyga
d57c9bb51d Unlock request in PT using ocf_req_unlock()
There are situations when we can end up in engine_pt with cache lines
locked for write. One example is engine_rd falling back to engine_pt after
failure during cache line preparation, where write lock has been already
taken. To handle this situation properly, unlock request using more general
unlock function.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2023-09-13 17:04:06 +02:00
Robert Baldyga
e09463054d
Merge pull request #771 from robertbaldyga/cache-is-initializing
Add OCF API ocf_cache_is_initializing
2023-04-17 20:38:14 +02:00
Amir Haroush
041df202b8 Fix alignment of private data in parallelize & pipeline
there is an issue when someone call to parallelize/pipeline
with some struct that is aligned (say to 64B)
but these APIs add their own data, right before
the user's private data.
so, the user's data is no longer aligned
which might cause segfault in some cases.

Signed-off-by: Amir Haroush <amir.haroush@huawei.com>
Signed-off-by: Shai Fultheim <shai.fultheim@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2023-04-17 20:35:38 +02:00
Amir Haroush
6cb1ff71c2 Add OCF API ocf_cache_is_initializing
Signed-off-by: Amir Haroush <amir.haroush@huawei.com>
Signed-off-by: Shai Fultheim <shai.fultheim@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2023-03-30 10:34:05 +02:00
Amir Haroush
22a697d09e Fix segfault when copy unaligned struct as aligned
Because context has one field which is aligned to 64B
(struct ocf_volume cache_volume) the compiler use vmovdqa (aligned)
instead of vmovdqu (unaligned) in reality the address is not 64 aligned,
it ends with 0x8, so we get this segfault.

Signed-off-by: Amir Haroush <amir.haroush@huawei.com>
Signed-off-by: Shai Fultheim <shai.fultheim@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2023-03-28 09:32:33 +02:00
Damian Raczkowski
d2ea41cdbc remove ocf_io_start function
Signed-off-by: Damian Raczkowski <damian.raczkowski@intel.com>
2022-10-28 15:03:36 +02:00
David Lee
004e930a9f update copyright line as per requested
Signed-off-by: David Lee <live4thee@gmail.com>
2022-10-09 22:30:36 +08:00
David Lee
6184ad7759 alru: add parameter `max_dirty_ratio'
With a high dirty ratio and occupancy, OCF might unable to map cache lines
for new requests, thus pass-through the I/O to core devices.  IOPS will
drop afterwards.  We need to control the dirty ratio.

Existing `alru' policy gives user the chance to control the stale buffer
time, activity threshold etc.  They can affect the dirty ratio of the cache
device, but in an empirical manner, more or less.  Introducing
`max_dirty_ratio' can make it explicit.

At first glance, it might be better to implement a dedicated cleaner policy
directly targeting dirty ratio goal, so that the `alru' parameters remains
orthogonal.  But one the other hand, we still need to flush dirty cache
lines periodically, instead of just keeping a watermark of dirty ratio.
It indicates that existing `alru' parameters are still required if we
develop a new policy, and it seems reasonable to make it a parameter.

To sum up, this patch does the following:
- added a 'max_dirty_ratio' parameter with default value 100;
- with default value 100, `alru' cleaner is identical to what is was;
- with value N less than 100, the cleaner (when waken up) will active
  brought dirty ratio to N, regardless of staleness time.

Signed-off-by: David Lee <live4thee@gmail.com>
2022-10-01 17:48:14 +08:00
Michal Mielewczyk
7b8093aa34 Refactor cleaning policies initialization
Don't populate cleaning policies during initialization procedure so the user
has to call the latter explicitly.

Until now cleaning policies could be populated in two ways:
- implicitly during cleaning policy initialization,
- explicitly be calling populate.
The difference was that the former was single threaded.

This patch removes the functionally redundant and less efficient code.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-09-26 14:14:40 +02:00
Michal Mielewczyk
c0e99e1f79 cleaning: rename recovery to populate
The function not only recovers cleaning policy metadata but is also utilized
to initialize data structures so more generic name is actually more accurate

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-09-26 14:14:40 +02:00
Michal Mielewczyk
8faf74169a Parallelize initializing hash table
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-09-26 14:14:40 +02:00
Michal Mielewczyk
4dbf740f5b Parallelize initializing collision section
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-09-26 14:14:40 +02:00
Michal Mielewczyk
b50bd1b506 Initialize metadata structures in pipelines
Initializing metadata in an asynchronous manner will allow to use
parallelization utilities in the future commits

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-09-26 14:06:40 +02:00
Michal Mielewczyk
da67112b17 load: init_structures as a separate step
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-09-26 14:06:40 +02:00
Michal Mielewczyk
f8e8d74539 attach: setup promotion policy before cleaning
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-09-26 14:06:40 +02:00
Michal Mielewczyk
ca70ea3fff Deinit cleaning policy if attaching cache failed
Normally cleaning policy would be deinitialized during stopping cache which is
one of steps of error handling e.g in case of failed cache activation. But since
`cache_stop()` may be called only for an attached cache instance, cleaning
policy needs to deinitialized explicitly.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-09-26 14:06:40 +02:00
Michal Mielewczyk
21d5da83d9 A utility for counting queues
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-09-26 14:06:40 +02:00
Michal Mielewczyk
ef997b47fa Fix whitespaces
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-09-23 07:09:41 +02:00
Robert Baldyga
e9a3ebe460
Merge pull request #746 from pdebski21/fix_debug_kernel_stack_overflow
Stack memory reduction for OCF stats
2022-09-09 09:00:03 +02:00
Robert Baldyga
9ad308d84f
Merge pull request #714 from rafalste/copyright_header_check_improvements
Copyright header check improvements
2022-09-09 08:53:13 +02:00
Robert Baldyga
1c701e4101
Merge pull request #750 from robertbaldyga/remove-req-io-if
Get rid of req->io_if
2022-09-08 22:59:57 +02:00
Rafal Stefanowski
9d7f4becb8 copyright/license: Add missing copyright header
Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
2022-09-08 13:13:18 +02:00
Robert Baldyga
228c5fc891 Get rid of req->io_if
Remove one callback indirection level. I/O never changes it's direction
so there is no point in storing both read and write callbacks for each
request.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-09-07 23:07:04 +02:00
Robert Baldyga
d0d1db0b8d
Merge pull request #748 from arutk/fas
fix potential out of bound access in req->alock_status manipulation
2022-09-07 17:05:14 +02:00
Robert Baldyga
4d32e4272a
Merge pull request #751 from arutk/cesf
unify cache write error accounting
2022-09-07 11:04:21 +02:00
Piotr Debski
0aed807ac4 Stack memory reduction for OCF stats
Signed-off-by: Piotr Debski <piotr.debski@intel.com>
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-09-06 14:34:35 +02:00
Adam Rutkowski
0a09d05a8b Add missing ocf_metadata_read_sb error handling
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-09-06 13:24:05 +02:00
Adam Rutkowski
83b4455a0e unify cache write error stats accounting
In most (6/9) instances across engines ocf_core_stats_cache_error_update
is called upon each cache volume I/O error, possibly multiple times
per a user request in case of multi-cacheline requests. Backfill,
fast and read engine are exceptions, incrementing error stats only
once per user request.

This commit unifies ocf_core_stats_cache_error_update usage so that
in all the engines error statistic is incremented for once for every
error.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-09-05 21:13:06 +02:00
Adam Rutkowski
0cfb8077c5 allocate fixed map status alongside request struct
It is wastefull to allocate a full 1B to store 1 bit of
alock status per cacheline. Fixed allocation of 128 bits
seems more reasonable.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-08-29 20:02:18 +02:00
Adam Rutkowski
2f3e0b0fd0 more precise req->alock_status size calculations
1. On 1 bit per cacheline is required for the status
2. ... however the size must be 8B aligned

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-08-29 20:01:52 +02:00
Krzysztof Majzerowicz-Jaszcz
e12803f547 Fix for bad metadata capacity reported by dmesg
Metadata capacity reported by dmesg was actually a memory footprint.

A proper size of metadata is now reported.

Signed-off-by: Krzysztof Majzerowicz-Jaszcz <krzysztof.majzerowicz-jaszcz@intel.com>
2022-07-06 14:30:39 +02:00
Adam Rutkowski
5a71f7c068 validate uuid->size in ocf_volume_init
Optional uuid parameter to ocf_volume_init() points to UUID object
initialized by the user. We should verify it is not excesively large
as we attempt to allocate a buffer to store a copy of the UUID.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-06-28 08:02:58 +02:00
Adam Rutkowski
364e36ec7e Revert "fix deinitialization of moved composite volume"
The proper way to avoid calling on_deinit() callback on an already
deinitialized volume is to deinitialize type callbacks, as it is done
in the previous commit.

This reverts commit a7f70687a9.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-06-28 08:02:58 +02:00
Adam Rutkowski
b6587ad622 zero volume->type in ocf_volume_deinit()
After deinitialization of volume there is no need to call back to
type ops. Currently we would erroneously call on_deinit() callback
multiple times if ocf_volume_deinit() is performed more than once,
which we expect to happen and treat as a correct use of API.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-06-28 08:02:58 +02:00
Robert Baldyga
f0f6ff219b Set core volume type in metadata on core insert
ocf_metadata_flush_superblock() is being called on the cache stop, after
deinitialization of the cores (and their volumes), thus accessing core
volume in superblock flushing procedure leads to use-after-free bug.

Fix this by moving volume type setting to the core insertion code.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-06-28 07:59:43 +02:00
Robert Baldyga
8822094f14 Fix metadata on disk size calculation when cleaner is disabled
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-06-21 09:33:42 +02:00
Piotr Debski
c448043b42 Conditional pipeline step for filtering invalid segments
Signed-off-by: Piotr Debski <piotr.debski@intel.com>
2022-06-16 09:33:09 +02:00
Adam Rutkowski
1a27b07f72 Pipeline conditional step
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
Signed-off-by: Piotr Debski <piotr.debski@intel.com>
2022-06-16 09:33:09 +02:00
Adam Rutkowski
a7f70687a9 fix deinitialization of moved composite volume
After moving from a volume, it's priv is assigned to the new owner.
Destroying the volume after moving from it must not attempt to use the
priv, especially not to attempt to deinit member volumes in case of
composite volume.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-06-13 11:40:08 +02:00
Adam Rutkowski
5a80237e74 expose composite volume type id in API
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-06-13 11:40:08 +02:00
Adam Rutkowski
02db4de75b Composite volume io calculations fix
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-06-13 11:40:08 +02:00
Adam Rutkowski
0030ebdecc Handle already opened volume in volume open
Volumes are now exposed in OCF API and we should gracefully handle
attempt to open already opened volume (instead of ENV_BUG).

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-06-13 11:40:08 +02:00
Adam Rutkowski
b053f7925a
Merge pull request #702 from robertbaldyga/v22.6-composite-volume
Introduce composite volume
2022-06-02 13:36:21 +02:00
Adam Rutkowski
5f767dd618
Merge pull request #726 from arutk/fipm
flush handling fixes and enhanced tests
2022-06-02 10:46:36 +02:00
Robert Baldyga
b847fa9a61 Introduce composite volume
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-06-02 09:49:39 +02:00
Robert Baldyga
8858e7344d Replace uuid/type pair with volume object in the device config
It makes it possible to attach/load cache using volume types that have
non-standard constructors.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-06-02 09:49:39 +02:00
Robert Baldyga
54b951fcdf Make default io allocators part of internal API
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-06-02 09:49:39 +02:00
Robert Baldyga
c9ea68f3bf Introduce on_init/on_deinit ops in ocf_volume interface
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-06-02 09:49:39 +02:00
Robert Baldyga
af62d14f02 Set priv to NULL on volume deinit
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-06-02 09:49:39 +02:00
Robert Baldyga
70a410b2fe Improve error handling in ocf_volume_init()
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-06-02 09:49:39 +02:00
Adam Rutkowski
df7ed6920c Fix ops(flush) engine
Flush I/O should be forwarded to core and cache device. In case of core
this is simple - just mirror the I/O from the top volume. Since
cache data is owned by OCF it makes sense to send a simple flush I/O
with 0 address and size.

Current implementation attempts to use cache data I/O interface
(ocf_submit_cache_reqs function) instead of submitting empty flush to
the underlying cache device. This function is designed to read/write
from mapped cachelines while there is no traversation/mapping
performed on flush I/O.

If request map allocation succeeds, this results in sending I/O to
addres 0 with size and flags inherited from the top adapter I/O.
This doesn't make any sense, and can even result in invalid I/O if the
size is greater than cache device size.

Even worse, if flush request map allocation fails (which happens
always in case of large flush requests) then the erroneous call to
ocf_submit_cache_reqs results in NULL pointer dereference.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-06-01 22:33:35 +02:00
Adam Rutkowski
1992bfc410
Merge pull request #710 from pdebski21/cache_line_size_mismatch
Explicit check for cacheline size mismatch during cache activation
2022-06-01 18:07:36 +02:00
Piotr Debski
0b9104e8d5 Cache metadata and superblock cache line size mismatch check
Signed-off-by: Piotr Debski <piotr.debski@intel.com>
2022-05-23 15:20:35 +02:00
Jan Musial
6016a6f4c7 Mark unlikely branches in pio_concurrency
Signed-off-by: Jan Musial <jan.musial@intel.com>
2022-05-18 11:56:06 +02:00
Jan Musial
60a6da7ee6 Extend alock API with entries_count method
Right now alock assumes that number of locks taken will equal number of
core lines. This is not the case in pio, where only parts of metadata
are under locks. If pio request overlaps locked and not-locked metadata
section it will have different core lines number and awaited locks
number. To remedy this discrepancy additional method which gets count of
locks that will be taken/waited on is added to alock API.

Signed-off-by: Jan Musial <jan.musial@intel.com>
2022-05-16 16:21:08 +02:00
Robert Baldyga
3aa12793a1
Merge pull request #713 from robertbaldyga/use-ocf-div-round-up
Use internal implementation of DIV_ROUND_UP
2022-05-13 21:21:26 +02:00
Robert Baldyga
ad7a40feaf Use internal implementation of DIV_ROUND_UP
It's required, because environments other than Linux kernel may not define
their own DIV_ROUND_UP. Moving it to env would just generate boilerplate,
because its implementation is trivial and portable.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-05-10 09:52:17 +02:00
Robert Baldyga
d4df912f46 Add option to disable cleaner
This allows to avoid allocating cleaner metadata section and effectively
save up to 20% of metadata memory footprint.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-04-28 13:04:27 +02:00
Michal Mielewczyk
e8e4e00bb7 alru: explicit upcasting
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-04-11 15:21:37 +02:00
Michal Mielewczyk
cd4d894348 acp: skip the first bucket on recovering acp
Since the threshold for the first bucket is always zero and the condition to
exit from the loop is never met in the first iteration it is save to start
iterating from `1`

This change is meant to avoid confusing static code analyzers

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-04-11 13:14:25 +02:00
Michal Mielewczyk
edd42fed98 Avoid zero-size memcpy
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-04-08 16:10:28 +02:00
Michal Mielewczyk
92fa8f7e59 Remove redundant standby check
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-04-08 15:34:14 +02:00
Michal Mielewczyk
bc30d2665b Prevent sending io to volume if it not opened
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-04-08 15:34:14 +02:00
Michal Mielewczyk
9734980be2 Free memory when failed to open core volume
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2022-04-08 15:34:14 +02:00
Adam Rutkowski
8f24556cec Add missing pio deinitialization in standby stop pipeline
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-04-07 12:23:03 +02:00
Adam Rutkowski
550a479cde fix typo in cache mngmt
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-04-07 12:23:03 +02:00
Robert Baldyga
dc9c076ef3 Remove space from names of internal volumes
Those names are used for creating allocators. In Linux kernel environment
starting from version 5.12 there is a kernel warning if allocator name
contains spaces. This patch resolves this problem by replacing spaces with
underscores.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-04-06 13:23:02 +02:00
Robert Baldyga
c677f65212 Avoid double initialization of cleaning policy in standby mode
Cleaning policy is initialized on standby activate, after all the metadata
from primary cache is flushed and the actual recovery is being performed.
Thus initializing it earlier on standby attach is incorrect.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-04-04 12:08:27 +02:00
Robert Baldyga
65918344c0
Merge pull request #691 from arutk/fix_core_load_err
Fix core load cleanup loop
2022-04-01 14:57:58 +02:00
Adam Rutkowski
77380d6579 Fix core load cleanup loop
conf_meta->core_count is not modified during load/recovery in the latest
version. Thus in case of error in cores initialization, in order to
iterate over the initialized cores we must depend on core->added only,
regardles of conf_meta->core_count value. for_each_core() macro does
exactly this.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-04-01 13:53:25 +02:00
Krzysztof Majzerowicz-Jaszcz
1b3f0d44a8 Fix error code for superblock checksum mismatch
Fix error code for superblock checksum mismatch.
Superblock validation now returns a proper error on checksum check fail.

Signed-off-by: Krzysztof Majzerowicz-Jaszcz <krzysztof.majzerowicz-jaszcz@intel.com>
2022-04-01 07:23:49 +00:00
Adam Rutkowski
09b73461b4 Always modify valid_core_map together with core_count
.. to assure that superblock config state on drive is consistent

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2022-03-31 13:37:42 +02:00
Robert Baldyga
9ebb0de878 Do not modify core_count on cache load / activate
Increment core_count only on core addition, and decrement it only on core
removal.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-03-31 10:00:24 +02:00
Robert Baldyga
25434cb8d1 Explicitly validate valid_core_bitmap consistency
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-03-30 23:46:06 +02:00
Robert Baldyga
9c751dd2b8 Manage valid_core_bitmap properly
Set bit only on core addition and clean it on core removal.

This allows to avoid conf metadata modification in load / standby load
paths, which effectively prevents issues with metadata mismatch during
consequent standby activate attempts after initial activate failure.
Previously the first attempt changed the metadata, so on comparison with
metadata on drive failed on any following attempt, leading to inability
to activate the cache.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2022-03-30 23:46:06 +02:00