Some helper threads are created at the very beginning of cache start/stop
operations, but they are used only after OCF start/stop finishes, which
may take significant amount of time. Kernel by default creates threads
that wait for the first wake up in uninterruptible state, which may trigger
hung task warning if the first wake up is called more than 120 seconds
after thread creation. To mitigate this problem we create lazy thread
abstraction that waits for a wake up in interruptible state.
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
OCF cannot allocate request map bigger than 4MiB (due to kmalloc
limitations), thus we need to split bigger IOs into series smaller
ones to reduce request map size.
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
It's defined on every single supported kernel, so there is actually no need
for this define at all.
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This patch fixes adding core after core addition failure.
The queue wasn't cleaned before and following core addition cannot
re-initialize queue properly.
Signed-off-by: Slawomir Jankowski <slawomir.jankowski@intel.com>
In case of initial flush error stop is aborted. In case
of failure during the second flush, appropriate error
message is presetned to the user.
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
Don't remove inactive core if it has dirt cache lines assigned unless `force`
flag is specified.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
The data->size field can be initialized to a lower value than bio->bi_vcnt,
if the bio is split. The bio_for_each_segment then iterates based on the original
indexes and the mismatch eventually causes a BUG_ON.
Fixes#714
Signed-off-by: Kozlowski Mateusz <mateusz.kozlowski@intel.com>
If time is counted in jiffies, machine reboot brokes `dirty for`
statistic for caches loaded at boot. The counter overflows and
`dirty for` shows some huge values.
Cast ticks to unsigned long.
Add necessary header.
Move `env_msleep` to `TIME` subgroup of header.
Move `env_time_after` below time converting functions.
Signed-off-by: Slawomir Jankowski <slawomir.jankowski@intel.com>
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>
New error code will allow to properly handle issues caused by wrong
usage of `remove inactive core` command.
It will also allow to print meaningful error messages.
Signed-off-by: Slawomir Jankowski <slawomir.jankowski@intel.com>
Change extended error message for `KCAS_ERR_REMOVED_DIRTY`.
Print informative messages when `remove core` command fails.
Make separate error messages for detaching.
Update help printouts.
Update documentation comments.
Signed-off-by: Slawomir Jankowski <slawomir.jankowski@intel.com>
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>
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>
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>
This method produced too optimistic free memory value, which in result
led to oom killer activation. This patch restores more conservative
free memory calculation method.
This reverts commit 1e9b7a4262.
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
Since kernel 5.7 kallsyms_on_each_symbol() is not available.
NOTE: This affects ability to perform upgrade in flight on kernels 5.7+.
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This counter is not accurate (missing required memory barrier
to avoid unwanted behavior due to processor optimizations)
and performance gain is not clear - generally global
atomic variables are something we would like to avoid
going forward.
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
Since commit 8b3238cabd50e27 in linux kernel removed blk_bidi_rq() marco, it
has to be wrapped in CAS `configure` script
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
Since there is no kernel-kernel api available to communicate
with nvme driver it is more convenient to use some nvme-dedicated
software (e.g. nvme-cli) to manage nvme devices.
It is even not possible to format nvme device with CAS using current
implementation on newest kernels.
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
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>
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>
In case of error `blk_mq_init_queue()` does not return NULL, but
`ERR_PTR(error_code)` instead.
`IS_ERR_OR_NULL()` should be used to check if `blk_mq_init_queue()` actually
failed.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
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>
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>
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>
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>
Sorting can take a long time with big cache sizes and a lot of dirty
data. Make sure we reschedule frome time to time to avoid lockups.
Signed-off-by: Jan Musial <jan.musial@intel.com>
Since stopping threads have to be done synchronusly, there is no need to keep
reference to cas_cache module in each thread.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This change assures that data array is always optimally aligned.
Additionally item boolean flags are put into the same uint32
as cpu number in order to save space for future additions.
This change fixes ~50% performance degradation introduced by
commit d822a1d1.
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
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>
- add a 'pckgen' script to generate various OpenCAS packages like
release archives (tar, zip), RPMs (source and binary) as well as to
create version file with metadata
- add a SPEC file for RPM creation
- add Makefile targets to use 'pckgen' script through 'make <package>'
'pckgen' script has a bunch of features for package generation.
Read './pckgen --help' for more information on usage scenarios.
Script is also prepared to easily add new packages creation in the future.
Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
If _cas_create_thread() thread failed, queue should be stopped by ocf. One of steps
done during queue stop is stopping kernel thread.
To avoid stopping thread which is not running, additional check was added in
_cas_stop_thread().
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>
After marking thread as ready to stop, CAS was waiting this for thread to exit
out of main execution loop (in _cas_io_queue_thread()). In case of management
queue it lead to deadlock because both stoping queue and main execution loop was
performed in the same execution context.
Since freeing memory is the only operation after stopping thread, it can be
moved just after the main thread loop. After this little reordering,
synchronising between _cas_stop_thread() and _cas_io_queue_thread() in no longer
needed, and no deadlock will occur.
This change is needed to put management qeueue from completion context. Without
this cachnge, there will be no possiblitiy to stop cache from completion context
and to make rollback.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
Returning non-const char* doesn't have any benefits since
the only caller casts the output pointer to const char *.
This change fixes compilation on 5.3 kernel.
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
CAS does not need atomic alocations virtually anywhere. GFP_NOIO
should be sufficient in IO path. When allocation buffers during
module initialization use GFP_KERNEL.
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
1. cas_vfree implementation is now properly selected based on kernel version
2. cas_vfree semantics now accepts NULL pionter as a valid input
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@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>
Check if provided log level isn't greater than number of available log levels
Prevoius check was comparing log level to size of array with avaiable log levels
(in bytes).
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>