Commit Graph

99 Commits

Author SHA1 Message Date
Adam Rutkowski
048f25379b Check dirty status in case of metadata mismatch
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2021-04-06 15:37:44 -05:00
Michal Mielewczyk
12db6b4443 Remove redundant cache being stopped check
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2021-03-12 09:20:19 +01:00
Slawomir Jankowski
461a4f2d96 Introduce "remove inactive core" to cas_cache module
Create module-side handling of inactive core removal.
Extract core functionality of core removal that applies to inactive core
and copy it to `cache_mngt_remove_inactive_core` function.
Return proper error if core is active.

Signed-off-by: Slawomir Jankowski <slawomir.jankowski@intel.com>
2021-03-10 14:39:07 +01:00
Slawomir Jankowski
f955ce890c Remove inactive core handling from "remove core"
FLush only active core during core removal.
During core removal with `casadm -R` there's a flush triggered.
This flush shall be skipped for inactive cores.
Change return code when `casadm -R` is called with `force` flag.
There was no info about dirty data when core was removed without flush.
Do not destroy exported object while core is inactive.
Perform detach only on active cores.
Skip removing inactive core with command for active cores.

Signed-off-by: Slawomir Jankowski <slawomir.jankowski@intel.com>
2021-03-10 14:26:09 +01:00
Michal Mielewczyk
35602acb8f Prohibit locking cache while its is being stopped
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2021-03-09 10:46:47 +01:00
Robert Baldyga
e6710e0016 cas_cache: Add promotion count parameter
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2021-03-07 20:36:57 +01:00
Michal Mielewczyk
099eeca864 Ioclass min_size removed from public ocf api
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2021-03-05 16:09:37 +01:00
Adam Rutkowski
68b68db9c0 Zero metadata if on-disk version differs from current
Kernel adapter now returns is_cache_device=1 and newly added
metadata_compatible=0 in case of metadata detected with
differing version (instead of is_cache_device = 0).

This allows zero-superblock command to recognize old
cache instance and clear it.

casadm --script --check-cache-device still returns 'Is cache'='no'
in this case, as this layer only cares about metadata in current
version to be able to detect dirty datas tatus.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2021-01-21 14:47:54 -06:00
Rafal Stefanowski
43f43068ad Update copyright statements (2021)
Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
2021-01-21 13:15:38 +01:00
Michal Mielewczyk
4d61ded26d Fix use after free bug
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2021-01-20 02:28:19 -05:00
Slawomir Jankowski
a057a0082f Handle cache stopping interruption
Ignore the interruption of the stop operation - will finish asynchronously.
Remove redundant `ocf_queue_put`.
Move creating the `finish_thread` during the cache stop
from the `_cache_mngt_cache_stop_sync` to the `cache_mngt_exit_instance`
and give it a proper handling.

Signed-off-by: Slawomir Jankowski <slawomir.jankowski@intel.com>
2021-01-19 16:25:11 +01:00
Robert Baldyga
02c3910677 Handle error in ocf_metadata_probe() complete callback properly
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2021-01-13 15:20:54 +01:00
Robert Baldyga
42c3f3ed8c
Merge pull request #613 from robertbaldyga/start-finalize-sync
Handle cache start finalize synchronously
2020-12-31 21:11:24 +01:00
Robert Baldyga
238b11846b Handle cache start finalize synchronously
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2020-12-31 19:49:03 +01:00
Robert Baldyga
f87e6970a5 Fix listing caches
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2020-12-30 17:58:16 +01:00
Robert Baldyga
48c3598ef5 configure: Add bdev_disk_changed() wrapper
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2020-12-22 11:33:38 +01:00
Jan Musial
b217e406be Perform volume test only for atomic device
Signed-off-by: Jan Musial <jan.musial@intel.com>
2020-11-02 11:39:37 +01:00
Michal Mielewczyk
017c4261b0 cas_cache: log failed creating exported object
To avoid logging the same message each time _cache_mngt_create_exported_object()
is called, print error message within it.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-07-07 08:28:53 -04:00
Michal Mielewczyk
296cb0ef86 cas_cache: log failed activating exported object
To avoid logging the same message each time block_dev_activate_exported_object()
is called, print error message within it.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-07-07 08:28:53 -04:00
Michal Mielewczyk
c71b5fcbd3 Access attach command conditionaly
If cache is restored after upgrade, NULL is passed instead of
`struct kcas_start_cache`. This leads to null pointer dereference.

To prevent null pointer dereference, `struct kcas_start_cache` is tested before
each use

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-06-16 04:20:51 -04:00
Michal Mielewczyk
975ec6f32a Keep pointer to rollback thread in start_finalize
If cache is initialized successfully, `struct _cache_mngt_attach_context` might
be freed in `cache_mngt_init_instance()`. In such case pointer to rollback
thread can't be accessed and thread can't be stopped.

To prevent such scenario pointer should be kept in separate variable.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-06-16 04:20:51 -04:00
Robert Baldyga
1e25420f86
Merge pull request #404 from rafalste/copyright_update
Update copyright statements
2020-05-19 11:25:11 +02:00
Michal Mielewczyk
3b62e40a2e Purge core command
Purge invalidates all cache lines which belongs to given core. It is very
usefull feature for tests.

Calling purge is possbile with casadm `--script` swtich.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-05-12 11:32:01 -04:00
Michal Mielewczyk
d24288a9b1 Purge cache command
Purge invalidates all cache lines. It is very usefull feature for tests.

Calling purge is possbile with casadm `--script` swtich.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-05-12 11:32:01 -04:00
Rafal Stefanowski
44b4020cc1 Update copyright statements
Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
2020-05-04 16:47:38 +02:00
Michal Mielewczyk
e1b8ddbc40 Pass remove core result to cli
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-04-01 22:30:43 -04:00
Robert Baldyga
6bb4dde213
Merge pull request #369 from mmichal10/async-stop-compl
Before stop wait for start to be finished
2020-03-27 13:59:18 +01:00
Michal Mielewczyk
3edaf30a73 Before stop wait for start to be finished
To prevent cache being stopped before async start finialize has finished, stop
routine have to check if worker responsible for finalizing is not running
anymore.

To create link between start finalize and stop functions, work_struct had to be
moved from attach_context to cache_priv.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-03-25 06:24:23 -04:00
Michal Mielewczyk
33223bacb9 Fix flush sync wrappers
Call completion function in case of allocation error

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-03-25 01:52:04 -04:00
Michal Mielewczyk
17d5c8599d Use wrapper function to flush cache during stop
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-03-25 01:52:04 -04:00
Michal Mielewczyk
dca9769298 Acquire read lock for flushing cache
Read lock allows to retrieve informations about flushing progress and printing
progress bar during changing cache mode.

Flushing dirty data during changing cache mode is done twice - first flush might
be interrupted by user and the second one, called with write lock acquired, is
uninterruptable.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-03-25 01:52:04 -04:00
Michal Mielewczyk
2fffd789c0 Create finalize thread during stop
Creating finalize thread on cache start causes soft lookups during whole
instance lifetime

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-03-24 07:45:33 -04:00
Robert Baldyga
ef94a0df22
Merge pull request #362 from mmichal10/fix-core-removing
Fix core removing
2020-03-23 14:41:17 +01:00
Michal Mielewczyk
9e692435f6 Allocate stop context on during start
To make cache stop as simple as possibe and to reduce number of errors, stop
context should be allocated during cache initialize.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-03-23 03:28:26 -04:00
Michal Mielewczyk
f93019165f Hold reference to module for each thread
To prevent removing cas_cache module when not all thread were stopped yet, each
of them should keep reference.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-03-20 11:17:00 -04:00
Michal Mielewczyk
55d53867cc Complete cache stop from kthread
To enable stopping management queue from completion context, last queue_put()
have to be called from separate thread.

After cache is fully deinitialized, thread calls module_put_and_exit() to
prevent scenario when code is still executed, but there are no references to
module.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-03-20 11:17:00 -04:00
Michal Mielewczyk
91c8c02860 Simplify functions managing core ids
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-03-20 10:39:17 -04:00
Michal Mielewczyk
5ca9287b53 Refactor core removing function
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-03-20 10:39:17 -04:00
Michal Mielewczyk
3eab28cf44 Add missing module_put() in casse of alloc error
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-03-07 08:47:24 -05:00
Jan Musial
19c334c4cf Move classifier init after cache device attach completion
Right now the classifier is instantiated before device is attached.
This way if we have any IO-classes present on cache device the
classifier will have no knowledge of them and fail to classify IO
correctly.

After moving the classifier init to cache finalization routine we have
all the information needed to initialize properly both in new instance
start path and in load path.

Signed-off-by: Jan Musial <jan.musial@intel.com>
2020-02-25 14:00:07 +01:00
Michal Mielewczyk
a0937758b7 Handle flush core interruption.
When flushing core, acquiring write lock is not necessary, so it was replaced
with read lock wherever possible.

If flushing operation is interrupted by signal, not only waiting for it to be
finished is interrupted but also OCF flush operation is stopped.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-01-28 15:41:31 -05:00
Michal Mielewczyk
3e033df9c6 Handle flushing cache interruption.
When flushing cache, acquiring write lock is not necessary, so it was replaced
with read lock wherever possible.

If flushing operation is interrupted by signal, not only waiting for it to be
finished is interrupted but also OCF flush operation is stopped.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-01-28 15:41:31 -05:00
Michal Rakowski
fe2a8706e9 prepare_cache_cfg: change bug_on to returning err instead
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2020-01-24 15:14:49 +01:00
Jan Musial
b5f014f689 Fix upgrade errors
Signed-off-by: Jan Musial <jan.musial@intel.com>
2020-01-14 09:53:03 +01:00
Michal Mielewczyk
79631867b8 Remove semicolons after 'if' condition
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-01-07 09:41:16 -05:00
Michal Mielewczyk
36e34b5a69 Don't try to restore cache after stop error.
In current OCF cache stop implemetation no error should occur, so there is no
need to handle it in adapter.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-01-02 18:34:30 -05:00
Michal Mielewczyk
232f13a8a4 Allow to interrupt cache init, load and stop.
When device used as cache had a big size, it took a lot of time to initialize.
If user would interrupt waiting, asyc OCF init procedure would continue, but
after finish, there was nobody to perfrom kernel part of start nor error
handling.

Now error handling and kernel part of start procedure are moved to completion.
If user will interrupt waiting at any point, newly started cache instance will
be stopped.

Since cache init and load vary only with check for old metadata and initializing
exported objects, they are now merged into one function.

Async cache stop is part of this commit because it was needed for rollback path.

Load, init and stop have common context, because in case of non interrupted
attach CAS needs to wait for rollback to be completed. Common context makes
passing `struct completion` easier between load, init and stop.

This commit is part of patch that will allow to interrupt waiting for OCF
operations.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-01-02 18:34:30 -05:00
Michal Mielewczyk
0b5ed3f00b Allow flush operations to be interrupted.
When context was allocated on the stack and waiting for completion was
interrupted, completion function would attempt to save flush result in
memory which might in use by other process. This would cause a system crash.

To prevent such scenario, context is allocated dynamiclly and extended with
reference counter. In case of interrupt, completion function doesn't have to
save result in context, it can simply free it's memory.

This commit also enables possibility to interrupt regular flush properly, by
seding SIGING to casadm.

This commit is part of patch that will allow to interrupt waiting for OCF
operations.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-01-02 18:34:30 -05:00
Michal Mielewczyk
b7f1dd69a9 Allow waiting for metadata flush to be interrupted.
When context was allocated on the stack and waiting for completion was
interrupted, completion function would attempt to save flush result in
memory which might in use by other process. This would cause a system crash.

To prevent such scenario, context is allocated dynamiclly and extended with
reference counter. In case of interrupt, completion function doesn't have to
save result in context, it can simply free it's memory.

This commit is part of patch that will allow to interrupt waiting for OCF
operations.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-01-02 18:34:30 -05:00
Michal Mielewczyk
de823b15fc Allow cache r&w locks to be interrupted.
When context was allocated on the stack and waiting for completion was
interrupted, completion function would attempt to save lock/unlock result in
memory which might in use by other process. This would cause a system crash.

To prevent such scenario, context is allocated dynamiclly and extended with
reference counter. In case of interrupt, completion function doesn't have to
save result in context, it can simply free it's memory.

This commit is part of patch that will allow to interrupt waiting for OCF
operations.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-01-02 18:34:30 -05:00