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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
In case of error during cache stop exported object is not being restored after destroying.
This may result in bug in case of calling stop once more.
This commit fixes this issue - exported objects are restored.
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
Due the changes in ocf error codes adapter misinterpreted information about no
preexisting metadata.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
Functions and macros dependent on different kernel versions are now generated
before compilation basing on current kernel capabilities instead of hardcoding
them for specific kernels.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
struct ocf_mngt_core_config no longer contains this information,
so we need to pass it as separate argument.
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
We should only proceed with deinitialization in case of cache
write error, not just any error.
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This needs to be done in caller application context. As part of asynchronous
management API rework, volume_open callback was moved to kernel worker thread
context. To work around this, atomic parameters are now read before cache
attach/load/probe and provided to bottom volume via volume params.
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>