Commit Graph

1049 Commits

Author SHA1 Message Date
Michal Mielewczyk
62307d82b8 Don't destroy stop pipeline if detach cache failed
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-26 11:39:05 +01:00
Michal Mielewczyk
4a2597dc25 stop: Don't deinitialize cleaning policy twice
The cleaning metadata has been deinitialized in the previous pipeline
step together with other services

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-26 08:53:30 +01:00
Michal Mielewczyk
6f7c0c6c51 Add missing d2c refcnt deinit
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-25 15:39:42 +01:00
Michal Mielewczyk
a38341389a Microoptimization for resolving cache mode
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-25 09:32:39 +01:00
Michal Mielewczyk
5d0608de2c Don't unfreeze refcnt in atomic context
Unfreezing a refcnt might be a sleeping operation so it can't be called
from completion context. Moving D2C refcnt unfreeze to a separate step
in pipeline ensures that it will always be called from process context

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-25 09:32:39 +01:00
Robert Baldyga
db134d12e7 Fix refcnt memleak in ocf_volume
Avoid double initialization of volume refcnt.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2025-03-24 21:47:35 +01:00
Michal Mielewczyk
295b3949bc backfill: Update occupancy only if BF succeeded
Increasing the occupancy before the backfill request has completed leads
to incorrect statistics

test_lazy_engine_errors() detected the bug in the following scenario:
1. Rio submitted a read request
2. The read turned out to be a full miss. After a successful read from
   the core device, engine_read set the metadata bits to valid and
   submitted a backfill request
3. In meantime, Rio submitted a write request to the same cache lines
4. Since the test uses an error device as cache (all sectors are
   erroneous) the backfill request failed and was redirected to
   engine_invalidate
5. engine_invalidate reset the metadata bits to invalid, but since cache
   lines had waiters registered, the occupancy wasn't decremented as
   there was an assumption that the new owner (in this case, the write
   request) would do the bookkeeping
6. Upon receiving cache line locks, the write request detected that
   the mapping changed so it was completed with an error without
   decrementing the occupancy
7. The incorrect value of cached cache lines was persisted for the whole
   lifetime of the cache

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-24 12:22:25 +01:00
Michal Mielewczyk
96e527049a Refactor __set_cache_line_invalid() pt.2
Get rid of nested ifs

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-24 12:02:34 +01:00
Michal Mielewczyk
4a01ff957d Refactor __set_cache_line_invalid() pt.1
Better naming

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-24 12:02:34 +01:00
Michal Mielewczyk
67eb940589 Refactor metadata collision API
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-24 12:02:32 +01:00
Michal Mielewczyk
e1d2ff12d8 FIX metadata collision API
If `is_valid` was NULL, OCF would crash

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-24 11:38:32 +01:00
Michal Mielewczyk
69987bd20c detach: Don't deinitialize cleaning policy twice
The cleaning metadata has been deinitialized in the previous pipeline step
together with other services

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-17 15:28:09 +01:00
Michal Mielewczyk
1e75a9826d stop&detach: Deinit services before removing cores
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-17 15:28:09 +01:00
Michal Mielewczyk
9c2da08ffe stop pipeline: flush_metadata as a separate step
Flushing metadata has nothing to do with dinitializing services so it
should be a separate step in the stop pipeline

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-17 15:28:07 +01:00
Michal Mielewczyk
75c4c9b473 Move _ocf_mngt_cache_deinit_services() definition
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-17 15:27:17 +01:00
Michal Mielewczyk
942825146a Simplify _ocf_mngt_cache_deinit_services()
Move flushing metadata outside cache_detinit_services(), so the function
can be shared between stop() and detach() without redundant ifs.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-17 15:27:16 +01:00
Michal Mielewczyk
eca7872299 detach: Rename update_metadata() to remove_cores()
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-17 15:19:55 +01:00
Michal Mielewczyk
03338d798c detach pipeline: remove unused completion
The completion callback is called only in the cache stop scenario, after
flushing the metadata

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-17 15:19:55 +01:00
Michal Mielewczyk
5e55bf78b4 Rename cache_unplug() to deinit_services()
The function doesn't unplug anything, it just deinitializes cleaning and
promotion.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-17 15:19:53 +01:00
Michal Mielewczyk
8dc462e08e Fix using request after free
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-03-14 13:36:55 +01:00
Rafal Stefanowski
794fa125e8 Check if cache is attached before setting promotion and seqcutoff params
Fixes null pointer dereference if setting those params is attempted
on detached cache.

Signed-off-by: Rafal Stefanowski <rafal.stefanowski@huawei.com>
2025-03-11 16:47:53 +01:00
Robert Baldyga
a12496320c
Merge pull request #849 from mmichal10/refcnt-per-cpu
Refcnt per cpu
2025-02-06 17:28:07 +01:00
Roel Apfelbaum
b02481cf74 A utility to continue pipeline on zero refcnt
Signed-off-by: Roel Apfelbaum <roel.apfelbaum@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-02-06 12:04:40 +01:00
Robert Baldyga
7685b70810 Protect cache lock against locking during lock deinitialization
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2025-02-06 12:04:37 +01:00
Adam Rutkowski
53ee7c1d3a Per-cpu refcounters
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
Signed-off-by: Jan Musial <jan.musial@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
Signed-off-by: Rafal Stefanowski <rafal.stefanowski@huawei.com>
2025-02-06 12:04:34 +01:00
Daniel Madej
d8feef301d Change type of pages count variables to uint32_t
Signed-off-by: Daniel Madej <daniel.madej@huawei.com>
2025-02-06 11:54:53 +01:00
Daniel Madej
a15003d43e Split count_pages and update on metadata deinit
This resets count_pages_variable on cache-detach, so during the following
cache-attach metadata size is calculated properly.

Signed-off-by: Daniel Madej <daniel.madej@huawei.com>
2025-02-06 11:54:53 +01:00
Daniel Madej
95c9c8987e Zero metadata superblock on detach
Metadata from a detached cache device is not meant to be loaded.

Signed-off-by: Daniel Madej <daniel.madej@huawei.com>
2025-02-06 09:24:40 +01:00
Robert Baldyga
c200c24344
Merge pull request #851 from robertbaldyga/core-stat-fix-inv-waiter
Decrement core stats only if the cache line mapping is cleaned
2025-02-06 06:15:33 +01:00
Robert Baldyga
be068df400
Merge pull request #853 from mmichal10/repart
Repart
2025-02-04 16:39:49 +01:00
Robert Baldyga
08eb00665c
Merge pull request #854 from robertbaldyga/request-cleanup
A little cleanup between ocf_request and ocf_io
2025-02-04 15:20:44 +01:00
Robert Baldyga
c029f78e95 Make alock_rw a bit field
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2025-02-04 12:05:26 +01:00
Daniel Madej
8ce129de06 ocf_cleaner_refcnt_unfreeze bug fix
During core remove/detach ocf_cleaner_refcnt_freeze was called only
when cache was attached, but ocf_cleaner_refcnt_unfreeze was called
regardless of cache state.

Signed-off-by: Daniel Madej <daniel.madej@huawei.com>
2025-01-15 18:51:42 +01:00
Robert Baldyga
0d06b3a597 Fix race condition during cache attach
After attaching new cache device handle all the IOs in Pass-Through mode
until all the d2c requests are completed.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-11-21 21:26:00 +01:00
Robert Baldyga
2da05343e2 Avoid UBSAN false positive - continuation
Address issue in two more instances.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-10-30 11:33:17 +01:00
Michal Mielewczyk
6bfd2122d2 Repart all misclassified cache lines
Remapped cache lines my require repartitioning as well

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-10-16 18:37:42 +02:00
Michal Mielewczyk
b3fa1fc96a Reset repart flag during refreshing request status
The flag isn't reset before retraversation so it might be true even if cache
line was reparted in the meantime

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-10-16 18:37:42 +02:00
Robert Baldyga
b3332793bb Remove unused request field
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-10-15 16:15:02 +02:00
Robert Baldyga
0cf4e8124b Remove io.ref_count
There is already refcounting on the request. No need for additional one.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-10-15 09:55:56 +02:00
Robert Baldyga
85513332d7 Remove ocf_io_get()
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-10-15 09:55:56 +02:00
Robert Baldyga
a9718eeab1 Simplify fastpath handling
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-10-15 09:55:56 +02:00
Robert Baldyga
1ab882aa61
Merge pull request #852 from robertbaldyga/forward_io-fix-error-accounting
Fix error accounting in forward_io
2024-10-15 08:44:47 +02:00
Robert Baldyga
a1af1809d8 Fix error accounting in forward_io
Resetting cache_error/core_error in ocf_req_forward_* functions may lead
to overwriting already reported error if the forward is being done in the
loop.

To avoid this potential problem, introduce set of forward init functions
intended to be called before the entire forward operation, which resets
the error code and sets a forward callback.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-10-14 16:54:51 +02:00
Robert Baldyga
3959f58f1c Decrement core stats only if the cache line mapping is cleaned
We skip cleaning the mapping and moving the cache line to the free list
in a situation when there are waiters on the cache line lock.
Refrain from decrementing core stats in that situation as well, and let
repart of the waiter request do the updates as needed.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2024-10-14 13:28:56 +02:00
Michal Mielewczyk
1b2a9e03c3 Add missing cache unlock in init rollback
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-10-10 07:32:38 +02:00
Michal Mielewczyk
c82fd173c6 Remove redundant list_del(ctx->caches) during init
New caches are added to the list at the point where they are already
initialized and no errors are possible at this point, hence list_del() in error
handling is redundant.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-10-10 07:32:38 +02:00
Michal Mielewczyk
e8e7a1600c Log errors on cache init
The more (logging) the merrier

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-10-10 07:32:38 +02:00
Michal Mielewczyk
f6bdd354d0 Don't bug on cache init
Even if locking the new cache should never fail it's not an unrecoverable
state.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-10-08 11:14:20 +02:00
Roel Apfelbaum
1d1561649c Remove redundant fallback-PT counter accesses
The fewer (atomic variable accesses on IO path) the better fare

Signed-off-by: Roel Apfelbaum <roel.apfelbaum@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-10-08 11:14:20 +02:00
Robert Baldyga
6f02a625ad pipeline: Introduce debug logging
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-10-08 11:14:20 +02:00