Commit Graph

73 Commits

Author SHA1 Message Date
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
Michal Mielewczyk
f7d88c4b3f Don't allow core add, remove nor detach interruptions
They are usually not time comsuming operations, so risk of hung task is low.
So it's easier to temporarily disable interrupts instead of properly handle
async completion.

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

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-01-02 18:34:30 -05:00
Michal Mielewczyk
2ac8214379 Don't allow probe interruption.
Usually metadata probe is non time consuming. To avoid dealing with
synchronization problems, noninterruptible wait is performed.

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

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-01-02 18:34:30 -05:00
Michal Mielewczyk
3eda503095 Additional null check when starting cache instance
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2020-01-02 09:22:13 -05:00
Jan Musial
4c9465b3bf Fix removing clean inactive core
When removing core that's inactive, allow it without "--force" option if
that core is clean.

Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-12-11 13:50:22 +01:00
Michal Mielewczyk
fe7da3220d Mark removed core id as free.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-10-01 10:00:08 -04:00
Michal Mielewczyk
296db39ea0 Adapt to new OCF PP param set/get API.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-10-01 06:54:32 -04:00
Michal Rakowski
4cbf555793 OCF update
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-10-01 10:32:03 +02:00
Robert Baldyga
a2d78103f2 wait interruptible in code called from ioctl handler
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-09-26 17:11:20 +02:00
Adam Rutkowski
186bfbc704 Fix cache reference management in get/set seq cutoff threshold
ocf_core_get_cache does not increment cache reference count, so
it shouldn't be paired with cache_put

Fixes #117

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-26 14:10:17 -04:00
Michal Mielewczyk
8b0d10952f Don't generate core name when adding core to corepool.
When core frome corepool is added to cache, it's old name is loaded and cores
in corepool cannot be referenced by name anyway so new name is not needed.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-25 15:36:02 -04:00
Adam Rutkowski
360a73ae5b
Merge pull request #125 from robertbaldyga/core-param-error-handling
Fix core set param error handling
2019-09-25 20:28:06 +02:00
Robert Baldyga
a7390aa6fc Return error on invalid core id
Instead of silently allowing for any core_id in order to set
core parameter for all cores in cache, check explicitly for
special value (OCF_CORE_ID_INVALID) which means that no core
has been selected.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-09-25 17:22:01 +02:00
Michal Mielewczyk
e96b37ecc2 Confirm cache name before load.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-25 09:44:07 -04:00
Michal Rakowski
b3dd5ead36
Merge pull request #106 from imjfckm/fix-puts
Remove unneccessary cache_puts
2019-09-19 12:55:34 +02:00
Jan Musial
9598fa76f1 Expose PP settings in IOCTL iface
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-09-19 08:38:35 +02:00
Jan Musial
0810df2a0e Add OCL wrappers for promotion policy management 2019-09-18 13:58:55 +02:00
Jan Musial
429302adfc Remove unneccessary cache_puts
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-09-18 13:02:25 +02:00
Michal Mielewczyk
5f81173844 Leave space for terminating \0 in cache name initialization.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-18 05:00:29 -04:00
Michal Mielewczyk
39a3d04c93 Handle separate functons for retrieving core stats and info.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-16 09:24:14 -04:00
Michal Mielewczyk
1abb1e7c72 Adapt ioclasses stats command to ocf stats builder.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-16 09:24:14 -04:00
Michal Mielewczyk
4726bedb50 New ioctl for retriveing ocf stats.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-16 06:30:13 -04:00
Michal Mielewczyk
76acefd831 After loading cache mark used core ids.
Since OCF doesn't use core and cache ids anymore adapter has to track occupied
ids on its own. After loading cache, ids of all loaded cores should be marked as
occupied, otherwise adding new core without explicit specifying core id will
fail.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-11 02:08:28 -04:00
Michal Mielewczyk
7ecd537170 Fix setting core params.
If core id wasn't specified, function was returning error insted of setting
given param for all cores.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-04 07:48:04 -04:00
Michal Mielewczyk
9e05950845 Reset particular core stats only if core was specified by user.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-08-20 07:20:02 -04:00
Michal Mielewczyk
341222e3d7 Treat '16384' as valid cache id.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-08-20 03:42:05 -04:00
Michal Mielewczyk
56cbc6595b Pass name for newly initialized cache in array instead of pointer.
Unitl now pointer to local variable was passed to OCF and it's content could be
overwriten after leaving function responsible for preparing cache config.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-08-20 03:42:05 -04:00