Commit Graph

505 Commits

Author SHA1 Message Date
Robert Baldyga
d1c2fc0c67 discard: Make max_length aligned to sector size
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2020-01-21 12:44:04 +01:00
Michal Rakowski
65756a8160 Moved setting ctx for temporary cache object before metadata init
This way debug prints during metadata init phase won't cause crash
(because of the fact that temporary cache object does not have proper
ctx set hence does not have logger obj).

Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2020-01-16 21:53:40 +01:00
Robert Baldyga
ce28c71475
Merge pull request #326 from Ostrokrzew/upstream
Change error code
2020-01-10 13:38:18 +01:00
Ostrokrzew
3fca309e51 Change error code and add new
Change 'OCF_ERR_START_CACHE_FAIL' to 'OCF_ERR_NO_MEM' while CAS fails in case of memory lack on device.
Add new error code for case, when device doesn't satisfy CAS requirements - 'OCF_ERR_INVAL_CACHE_DEV'.
Use 'OCF_ERR_INVAL_CACHE_DEV' in code.
Update error code match in test.
closes #317 issue

Signed-off-by: Ostrokrzew <slawomir.jankowski@intel.com>
2020-01-02 09:34:24 +01:00
Jan Musial
5eca548e22 Make sure NHIT won't attempt to take the same semaphore twice
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-12-31 14:16:18 +01:00
Jan Musial
4536a51f59 Fix init of nhit + code styling
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-12-31 14:16:18 +01:00
Michal Mielewczyk
6ac3195823 Keep stop pipeline in struct cache.
To eliminate possibility of allocation error in cache stop, pipeline is
allocated on attach.

Due this change, the only possible non-zero status of  ocf_mngt_cache_stop() is
just a warning and cache is always stopped after executing it.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-12-27 18:54:15 -05:00
Adam Rutkowski
92b36c3484 Change DIV_ROUND_UP to OCF_DIV_ROUND_UP
This fixes compilation in SPDK env

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-12-28 18:24:12 -05:00
Robert Baldyga
d1249e5238 Limit number of concurrent io submitted by metadata_io_i_asynch()
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-12-19 16:50:41 +01:00
Robert Baldyga
e06832426d cleaner: Retrieve core object properly
Cleaner doesn't set core object in req as it works in domain of cache
lines, which may belong to various cores. It this case should retrieve
core object not from the req, but from the map instead.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-12-19 14:44:04 +01:00
Michal Rakowski
a074026773
Merge pull request #329 from robertbaldyga/fix-cleaner-queue-change-before-put
Put a queue before calling cleaner completion callback
2019-12-19 11:33:27 +01:00
Robert Baldyga
32fd371583 Put a queue before calling cleaner completion callback
This ensures that cleaner queue will not be changed
by starting another cleaning iteration before we put it.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-12-18 20:49:56 +01:00
Michal Mielewczyk
fb95f048fd Revert "Limit number of concurrent io submitted by metadata_io_i_asynch()"
Starting big caches hangs.

This reverts commit c2c9307b9b.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-12-17 10:29:44 -05:00
Ostrokrzew
fc1847cf55 Add reschedule to metadata hash init
Signed-off-by: Ostrokrzew <slawomir.jankowski@intel.com>
2019-12-17 09:56:45 +01:00
Adam Rutkowski
57e6b96791
Merge pull request #323 from arutk/remove_fallthrough
Remove switch/case fallthrough
2019-12-12 11:49:08 +01:00
Adam Rutkowski
867e06ebf1 Remove switch/case fallthrough
This construction breaks compilation on latest kernels.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-12-12 13:48:47 -05:00
Robert Baldyga
c2c9307b9b Limit number of concurrent io submitted by metadata_io_i_asynch()
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-12-11 14:57:20 +01:00
Jan Musial
94d27c0f43 Fix counting occupancy on WB write insert error
During error handling in WB write insert we didn't invalidate affected
cache lines. Because of that the cache stopped properly (as it's
supposed to), but cache lines were marked as inserted which caused
occupancy stats to increase even though nothing was succesfully
inserted.

Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-12-09 11:01:28 +01:00
Michal Mielewczyk
b61843d7df Reset initial ioclass stats value when retrieving.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-10-29 09:53:36 -04:00
Adam Rutkowski
6423c48dfe cacheline concurrency: move allocation outside critical section
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-10-18 18:41:01 -04:00
Adam Rutkowski
07b1f0c064 Replace global concurrency rw spinlock with rw semaphore
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-10-18 18:19:05 -04:00
Michal Mielewczyk
db06783d56 Fix cache stats updating.
When single request to cache was issued, stats updating function was called with
0 bytes as value to update. In case of many request issued to cache, stats were
updated only in case of error.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-10-08 08:49:24 -04:00
Robert Baldyga
f51f7f7e1e Update stats before calling completion callback
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-10-02 18:49:59 +02:00
Adam Rutkowski
94a0b5392b Fix hash bucket iterator
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-10-02 19:03:52 -04:00
Adam Rutkowski
cf5a92b527 Lock cachelines under hash bucket locks
.. or when holding exclusive global metadata lock.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-10-01 17:09:27 -04:00
Adam Rutkowski
5113542c7f
Merge pull request #297 from mmichal10/pp-params-in-sb
Store PP config params in cache superblock.
2019-10-01 12:32:15 +02:00
Michal Mielewczyk
e16d4e6dda Initialize promotion policy on cache attach.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-10-01 06:11:53 -04:00
Michał Mielewczyk
ee3f2205fd
Merge pull request #300 from arutk/revert_cl_lock_opt
Revert "Optimize cacheline locking in ocf_engine_prepare_clines"
2019-10-01 11:50:20 +02:00
Michal Rakowski
fc971b9961 Add missing env wrapper
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-10-01 09:05:59 +02:00
Adam Rutkowski
09b68297b2 Revert "Optimize cacheline locking in ocf_engine_prepare_clines"
This change introduced a race condition. In some code paths after
cacheline trylock failed, hash bucket lock needed bo be upgraded
in order to obtain asynchronous lock. During hash bucket lock
upgrade, hash read locks were released followed by obtaining
hash write locks. After read locks were released, concurrent
thread could obtain hash bucket locks and modify cacheline
state. The thread upgrading hash bucket lock would need to
repeat traversation in order to safely continue.

This reverts commit 30f22d4f47.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-30 23:53:10 -04:00
Adam Rutkowski
944d70288e
Merge pull request #296 from micrakow/sec_rev_fixes
Env fixes & more
2019-09-30 17:42:40 +02:00
Michal Rakowski
325994074e env: change env_strncmp to take 4 args
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-09-30 17:26:47 +02:00
Michal Rakowski
2575be83fa Error handling for env_rwsem_init added
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-09-30 17:16:37 +02:00
Michal Rakowski
b78557a2cc Change env_spinlock_init to non-void function
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-09-30 17:15:27 +02:00
Michal Rakowski
8426d662cb Changed err handling to BUG_ON in case of refcnt_int fail durign cache init.
Since we do not expect that incrementing cache's reference counter
during cache init will fail at any condition it is can be changed
to an assert instead of error handling.

Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-09-30 17:15:27 +02:00
Michal Rakowski
9504cb044d discard: Added missing io_put in case of error
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-09-30 17:15:27 +02:00
Michal Rakowski
f1cfc800e2 Add check for part_id in ocf_stats_collect_part_*
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-09-30 17:15:27 +02:00
Michal Rakowski
888ac74e32 Removed redundand include
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-09-30 17:15:27 +02:00
Slawomir_Jankowski
cdf0caf704 **ocf_mngt.h**: In core name change
pointer type to array which is 32 characters long;
**core.py**: Add missing import and modify class' field type
to keep consistency;
**ocf_mngt_core**: Remove local variable 'name';
remove env_vmalloc for 'name' - isn't no longer needed;
remove initialization 'name' - as above;
remove env_vfree for context->cfg.name - variable isn't no allocated
in memory;
check if cfg->name exists;
change label in goto from deleted err_name to the closest err_pipeline.

Signed-off-by: Slawomir_Jankowski <slawomir.jankowski@intel.com>
2019-09-30 15:55:33 +02:00
Michal Mielewczyk
dfc55538ce Store PP config params in cache superblock.
It allows to modify and retrieve particular PP params event if it isn't active
and store values between cache stop and load.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-27 10:55:58 -04:00
Robert Baldyga
96a1fdb17e Deinitialize locks on cache stop instead of put
Cache lock waiters hold cache refcount. Because of that,
if there were some waiters, deinitialization of cache
lock on the last put did never happen and putting the
cache was effectively impossible.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-09-27 12:02:04 +02:00
Robert Bałdyga
75569ecaba
Merge pull request #284 from mmichal10/prevent-cache-name-duplicate
Prevent cache name duplicate
2019-09-25 15:36:08 +02:00
Michal Mielewczyk
6c076a7c07 Remove set_cache_name() from public API.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-25 09:21:42 -04:00
Michał Mielewczyk
9e707d81b5
Merge pull request #287 from micrakow/nhit_fixe
Nhit fixes
2019-09-25 15:11:47 +02:00
Michal Rakowski
5efa5ac414 nhit PP: Prevent setting nhit policy again if it was already set 2019-09-25 14:59:23 +02:00
Michal Rakowski
547306efea nhit PP: change trigger_threshold to percent value
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-09-25 14:59:23 +02:00
Michał Mielewczyk
9613c325fc
Merge pull request #285 from arutk/fix_io_class_configure
Fix error handling in IO ocf_mngt_cache_io_classes_configure
2019-09-25 14:42:06 +02:00
Michał Wysoczański
aafe870e44
Merge pull request #280 from arutk/metadata_sync_2
Additional metadata synchronization
2019-09-25 14:11:59 +02:00
Adam Rutkowski
a934b43aec Add missing error handling in hash bucket locks initialization
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-25 14:26:17 -04:00
Adam Rutkowski
6de280283a Fix hash_table_entries param type in ocf_metadata_concurrency_attached_init
Number of hash buckets is 32 bit integer.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-25 14:26:17 -04:00
Adam Rutkowski
937b010ef6 Synchronize access to cleaner shared structures
Cleaning policy callbacks are typically  called with hash buckets or
cache lines locked. However cleaning policies maintain structures
which are shared across multiple cache lines (e.g. ALRU list).
Additional synchronization is required for theese structures to
maintain integrity.

ACP already implements hash bucket locks. This patch is adding
ALRU list mutex.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-25 14:26:17 -04:00
Adam Rutkowski
5e28474322 Adding partition locks
Adding locks to assure partition list consistency. Partition
lists is typically modified under cacheline or hash bucket lock.
This is not sufficient synchronization as adding/removing cacheline
from partition list affects neighbouring cachelines state as well.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-25 14:26:17 -04:00
Adam Rutkowski
41d3542952 Lock collision page in metadata flush
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-25 14:26:15 -04:00
Michal Mielewczyk
f461f3c62e Extend probe informations with cache name.
Since ocf requires loading cache with the same name as it was stopped, it should
also allow to read name from metadata.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-25 07:59:50 -04:00
Michal Mielewczyk
39c5819a51 Set cache name before adding it to context list.
This change allows to check if specified cache name name is unique. To prevent
adding cache instance with the same name, context lock is acquired until name
isn't set.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-25 07:59:50 -04:00
Michal Mielewczyk
c04ea4898f Check if loaded cache name is valid.
When loading cache, it's name should be the same as the loaded one.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-25 05:06:37 -04:00
Michal Rakowski
23aba6a9f3 nhit PP: Added info about setting nhit params
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-09-25 11:04:51 +02:00
Adam Rutkowski
be3b402162 Synchronization of collision table
Adding synchronization around metadata collision segment pages.
This part of metadata is modified when cacheline is mapped/unmapped
and when dirty status changes.

Synchronization on page level is required on top of cacheline
and hash bucket locks to assure metadata flush always reads
consistent state when copying entire collision table memory
page.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-25 00:26:29 -04:00
Adam Rutkowski
5684b53d9b Adding collision table locks
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-24 22:59:35 -04:00
Adam Rutkowski
727a6d2e4b Fix error handling in IO ocf_mngt_cache_io_classes_configure
Modifying _ocf_mngt_io_class_configure and _ocf_mngt_io_class_remove
to never return -OCF_ERR_IO_CLASS_NOT_EXIST error code. This
return code was ignored by the caller anyway. In _ocf_mngt_io_class_remove
-OCF_ERR_IO_CLASS_NOT_EXIST indicated the IO class is already
removed, which is not an error. In _ocf_mngt_io_class_configure
-OCF_ERR_IO_CLASS_NOT_EXIST indicated empty IO class name, which
is actualy invalid input. This change made it possible to remove
erroneous error handling for -OCF_ERR_IO_CLASS_NOT_EXIST case in
ocf_mngt_cache_io_classes_configure.

This change fixes IO class configuration.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-24 21:51:43 -04:00
Michał Wysoczański
07aa29fc56
Merge pull request #283 from rafalste/fix_nhit_param_value
Accept max values of nhit PP as valid.
2019-09-24 10:46:38 +02:00
Rafal Stefanowski
9cb5c60c80 Accept max values of nhit PP as valid.
Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
2019-09-23 15:58:57 +02:00
Robert Baldyga
b8f5f135fe ocf_async_lock: Replace mutex with spinlocks
The ocf_async_lock may be used in atomic context, thus we need
to replace synchronization primitives to non-sleeping variants.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-09-23 15:54:25 +02:00
Robert Baldyga
dd0a39eea7 Create new volume instead of using non-allocated one
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-09-23 14:01:17 +02:00
Adam Rutkowski
30f22d4f47 Optimize cacheline locking in ocf_engine_prepare_clines
Hash bucket read/write lock is sufficient to safely attempt
cacheline trylock/lock. This change removes cacheline lock
global RW semaprhore and moves cacheline trylock/lock under
hash bucket read/write lock respectively.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-20 17:21:00 -04:00
Adam Rutkowski
5248093e1f Move common mapping and locking logic to dedicated function
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-20 17:21:00 -04:00
Adam Rutkowski
d2bd807e49 Remove calls to OCF_METADATA_(UN)LOCK_WR(RD)
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-20 17:21:00 -04:00
Adam Rutkowski
2333d837fb Add single hash bucket lock interface
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-20 17:21:00 -04:00
Adam Rutkowski
3a70d68d38 Switch from global metadata locks to hash-bucket locks in engines
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-20 17:21:00 -04:00
Adam Rutkowski
b39bcf86d4 Separate engine map/evict (refactoring)
This temporarily increases amount of boiler-plate code, but
this is going to be mitigated in the following commits.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-20 17:21:00 -04:00
Adam Rutkowski
d91012f4b4 Introduce hash bucket locks
There is one RW lock per hash bucket. Write lock is required
to map cacheline, read lock is sufficient for traversing.
Hash bucket locks are always acquired under global metadata
read lock. This assures mutual exclusion with eviction and
management paths, where global metadata write lock is held.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-20 17:21:00 -04:00
Adam Rutkowski
42f65c3fbb Change ocf_metadata_(un)lock -> OCF_METADATA_(UN)LOCK
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-20 17:21:00 -04:00
Adam Rutkowski
f34cacf150 Move resume callback to async lock function params (refactoring)
This is a step towards common async lock interface in OCF.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-20 17:21:00 -04:00
Jan Musial
827273645c Use better function for calculating occupancy 2019-09-20 14:56:17 +02:00
Kamil Łepek
7131178e71
Merge pull request #272 from imjfckm/fix-pp-validation
Add PP type validation
2019-09-18 17:30:23 +02:00
Jan Musial
0c1ccddf8a Add PP type validation
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-09-18 15:12:23 +02:00
Jan Musial
0e85ebe4a3 Get PP params in line with rest of OCF
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-09-18 11:15:41 +02:00
Jan Musial
e9bd139349 Add validation of PP for cache start config
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-09-18 09:53:13 +02:00
Jan Musial
e8fc2c24f1 Add missing stuff from get_param in PP
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-09-17 15:05:29 +02:00
Michał Mielewczyk
f86287ef06
Merge pull request #261 from micrakow/coverity_19_9
Fixed some bugs found by the coverity tool
2019-09-17 09:25:18 +02:00
Michal Rakowski
83e23c5593 Fixed some bugs found by the coverity tool
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-09-16 15:49:37 +02:00
Michal Mielewczyk
c5edc60345 Fix stats update in cleaner.
Core is not assigned to request in cleaner, so to increase it's stats it has to
be retrieved from mapping.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-16 05:59:28 -04:00
Michał Mielewczyk
0391fc17b7
Merge pull request #255 from imjfckm/pp-tests
Add promotion policies functional tests
2019-09-16 09:34:16 +02:00
Jan Musiał
58012cd14b
Merge pull request #260 from mmichal10/unify-inactive-cores-stats
Unify inactive cores stats
2019-09-16 09:03:08 +02:00
Michal Mielewczyk
f226f978f0 Unify inactive cores stats.
Inactive core stats should be caluculated and returned to adapter in unified
from, just like all stats are.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-16 02:49:42 -04:00
Michal Mielewczyk
494a1ccc79 Extract stats builder utils to separate file.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-12 05:21:17 -04:00
Jan Musial
703a757db1 Fix minor bugs in promotion policy
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-09-11 10:31:14 +02:00
Jan Musial
633f31716e Make NHIT API naming convention similar to cleaning
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-09-11 07:31:50 +02:00
Michal Rakowski
29c1c7f9e8
Merge pull request #253 from mmichal10/stats-refactor
Stats builder for ioclasses
2019-09-10 14:56:26 +02:00
Michal Mielewczyk
e6f032cae9 Fix typo.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-10 08:01:10 -04:00
Michal Mielewczyk
01ce586e6a Use API instead of raw variables to update block stats.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-10 08:01:09 -04:00
Michal Mielewczyk
51c9c516a4 Use API instead of raw variables to update req stats.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-10 08:01:09 -04:00
Michal Mielewczyk
b4c384eb2d Use API instead of raw variables to update error stats.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-10 08:01:09 -04:00
Michal Mielewczyk
0d4f4d3294 Added API for updating statistics.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-10 08:01:09 -04:00
Michal Mielewczyk
42d6dbbf11 Remove low-level stats getters from public API.
Since stats builder is implemented for retrieving cache, core and ioclass stats,
adapters should use it instead.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-10 08:01:09 -04:00
Michal Mielewczyk
89de6038c1 Split retrieving core stats and config info into two functions.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-10 08:01:09 -04:00
Michal Mielewczyk
f9da89263b Stats builder for ioclass statistics.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-10 04:32:21 -04:00
Adam Rutkowski
13cf871a13 Per-execution-context freelists
Global free cacheline list is divided into a set of freelists, one
per execution context. When attempting to map addres to cache, first
the freelist for current execution context is considered (fast path).
If current execution context freelist is empty (fast path failure),
mapping function attempts to get freelist from other execution context
list (slow path).

The purpose of this change is improve concurrency in freelist access.
It is part of fine granularity metadata lock implementation.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-09-09 16:19:52 -04:00
Michal Mielewczyk
2450d3da4b Move block stats counters to ioclass section.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-09 02:46:45 -04:00
Michal Mielewczyk
8304ed84b8 More precise percentage value in stats builder.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-09-09 02:46:45 -04:00
Robert Bałdyga
5fd239d2bb
Merge pull request #245 from imjfckm/switching-pp
Switching mechanism for promotion policies
2019-08-30 11:35:16 +02:00
Robert Bałdyga
1f9f79f11d
Merge pull request #250 from robertbaldyga/parts-meta-new-section
Move parts metadata to separate section
2019-08-29 14:15:31 +02:00
Jan Musial
ee3fdb0506 Change nhit_hash names to avoid collision with kernel
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-08-29 13:24:54 +02:00
Jan Musial
a1d3cf0c4d Switching mechanism for promotion policies
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-08-29 13:24:26 +02:00
Robert Baldyga
d10c618065 Move parts metadata to separate section
Fix problem introduced by increasing partition name size to 1024 bytes,
which effectively made superblock bigger than one page. Due to this
flushing superblock required more than one io, which in case of dirty
shutdown between these ios resulted in CRC missmatch and made cache
recovery impossible.

Moving parts metadata to separate sections makes superblock fitting
in one page, effectively solving described problem.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-08-29 10:23:13 +02:00
Jan Musiał
0a9f197b10
Merge pull request #238 from arutk/split_cacheline_lock_trylock
Split cacheline locking implementation into trylock and lock
2019-08-29 09:49:53 +02:00
Adam Rutkowski
6dd1af7df7 Split cacheline locking implementation into trylock and lock
This change refactors the code in order to prepare for removing
global concurrency lock, which won't be needed after per-bucket
metadata locking is in place.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-08-28 18:54:19 -04:00
Robert Bałdyga
358c529eff
Merge pull request #243 from arutk/simplify_freelist_striping_init
Initialize freelist using metadata layout implementation
2019-08-27 17:12:04 +02:00
Michal Rakowski
e3a20c0da0
Merge pull request #239 from imjfckm/pp-implementation
nhit promotion policy implementation
2019-08-27 12:42:03 +02:00
Adam Rutkowski
860c8c7a0f Initialize freelist using metadata layout implementation
Metadata layout (seq / striping) is already encapsulated
in ocf_metadata_layout_iface, no need to double this logic
in freelist initialization.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-08-26 15:48:11 -04:00
Jan Musial
62a0ccdd9f nhit promotion policy implementation
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-08-22 13:34:38 +02:00
Michal Mielewczyk
2c27e9a433 Store name for newly initialized cache in array instead of passing pointer.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-08-20 01:43:11 -04:00
Robert Bałdyga
8ed525ae7f
Merge pull request #234 from mdnfiras/sync-prim-destroyers
Adding synchronization primitives destroyers
2019-08-13 15:46:26 +02:00
Firas Medini
33c96d226e Verifying IO address and size
IO address and size must be multiple of sector size. If not, ocf_io_new() will return NULL.

Signed-off-by: Firas Medini <mdnfiras@yahoo.com>
2019-08-13 05:37:14 -07:00
Firas Medini
1f979f630b Adding synchronization primitives destroyers
Environment should provide calls for destroying primitives (i.e. env_mutex_destroy()) and OCF should call these functions in its cleanup paths.

Signed-off-by: Firas Medini <mdnfiras@yahoo.com>
2019-08-13 05:13:11 -07:00
Robert Baldyga
9730b2bd1f Remove remaining core_id occurrences from public API
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-08-07 16:12:06 +02:00
Michal Rakowski
d499ef1c05
Merge pull request #227 from mmichal10/mark-core-added-false
Don't try to remove invalid cores

If valid cache metadata was read, but environment has changed (i.e. number of cache lines has changed) ocf (in error handling path) was trying to close cores which were not opened. It happened due to cores were marked in cache metadata as added, but any cache inserting operation didn't take place.

In this patch 'added' flag in cache metadata was replaced with more meaningful 'valid' - it is set if given core is stored in cache metadata. Moreover, new 'added' flag was added to core run-time metadata and it is set if given core is added to cache.
2019-08-07 13:37:59 +02:00
Michal Mielewczyk
cdc0a575a1 Added 'added' flag in core runtime data.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-08-06 07:36:39 -04:00
Michal Mielewczyk
433a25a1b2 Renamed 'added' flag in core metadata to 'valid'.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-08-06 07:08:12 -04:00
Michal Mielewczyk
5dd09e823b Initialize promotion policy before cleaning policy.
If cleaning policy didn't have init() function,
   '_ocf_mngt_init_instance_load_complete' returned early and promotion policy
   wasn't initialized at all.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-08-06 06:37:14 -04:00
Adam Rutkowski
9649f25415
Merge pull request #229 from robertbaldyga/cleanup-metadata
Metadata interface cleanup
2019-08-05 14:11:04 +02:00
Michal Mielewczyk
340ca76159 Move check for valid cache size in load.
Loaded cache size should be compared with acutal cache size after loading
superblock.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-08-05 07:58:38 -04:00
Michal Mielewczyk
80f82cab2b Deinitialize volume types in ocf internally.
Adapter can provide ops for data type deinitialization, if any additional
operations are required on deinitialization procedure.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-08-05 06:16:46 -04:00
Robert Baldyga
fdf6d07b85 Fix typo "collisioin" -> "collision"
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-08-03 20:04:23 +02:00
Robert Baldyga
4b1a3fa4b5 Simplify metadata_raw interface
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-08-03 20:04:23 +02:00
Robert Baldyga
a31ddd44cb Remove ocf_metadata_hash_entries_hash()
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-08-03 20:04:23 +02:00
Robert Baldyga
ff7583c6da Simplify partition metadata interface
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-08-03 20:04:23 +02:00
Robert Baldyga
3108f36e42 Simplify collision matadata interface
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-08-03 20:04:23 +02:00
Robert Baldyga
0b0546302f Remove ocf_metadata_get_core_sector()
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-08-03 20:04:23 +02:00
Robert Baldyga
0ca0ea1343 Remove ocf_metadata_line_size_is_valid()
This function is no longer used.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-08-03 20:04:23 +02:00
Robert Baldyga
92c7e12549 Remove core id from public API
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-07-30 09:26:26 +02:00
Robert Baldyga
1100cb0b4f Remove cache id from public API
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-07-30 09:26:26 +02:00
Robert Baldyga
259df7ace9 Store core name in metadata
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-07-30 09:26:26 +02:00
Robert Baldyga
eb4272afa9 Store cache name in metadata
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-07-30 09:26:17 +02:00
Robert Baldyga
4f0735b503 Ensure that core name is set and unique
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-07-29 17:37:48 +02:00
Robert Baldyga
901b39031f Ensure that cache name is set and unique
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-07-29 17:37:43 +02:00
Robert Baldyga
331b99397f Change ctx lock to rmutex
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-07-29 15:08:44 +02:00
Kamil Łepek
05be67a72b
Merge pull request #220 from arutk/metadata_offset_hash
New hash function formula
2019-07-29 13:03:04 +02:00
Jan Musiał
fa14d6a4b5
Merge pull request #221 from arutk/metadata_rename_concurrency
Restrutcure concurrency code
2019-07-29 09:42:37 +02:00
Robert Baldyga
3355a6cd56 engine: discard: Add missing put on error path
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-07-27 19:06:11 +02:00
Adam Rutkowski
494861c994 Rename cache_concurrency to cache_line_concurrency
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-07-24 15:32:12 -04:00
Adam Rutkowski
e5bed8825c Move metadata concurrency to a separate file
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-07-24 15:32:09 -04:00
Adam Rutkowski
3dd4263bc8 Change hash function
Modify ocf_metadata_hash_func to return consecutive (modulo @hash_table_entries)
values for consecutive @core_line_num. This way it is trivial to sort all
core lines within a single request according to their hash value. This kind
of sorting will be required to assure that future hash bucket metadata locks
are always acquired in fixed order, eliminating the risk of dead locks.

This change is part of fine granularity metadata lock implementation.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-07-24 15:02:34 -04:00
Adam Rutkowski
7184f7787c Cleanup map_info struct
1. Rename hash_key -> hash
2. Better comments for hash and coll_idx

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-07-24 13:12:05 -04:00
Michal Rakowski
aa02f56b05
Merge pull request #218 from robertbaldyga/rm-includes-metadata-superblock
Remove unneeded includes in metadata_superblock.h
2019-07-23 13:56:39 +02:00
Jan Musiał
1fd1a6fe17
Merge pull request #209 from arutk/stop_no_queue
Allow to stop cache without management queue
2019-07-23 13:51:21 +02:00
Robert Baldyga
ab2f8b199a Remove unneeded includes in metadata_superblock.h
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-07-23 13:00:05 +02:00
Jan Musiał
232f0cd8d7
Merge pull request #216 from robertbaldyga/io-and-req-in-single-allocation
Allocate io and req in single allocation
2019-07-23 11:40:30 +02:00
Jan Musiał
08abf69224
Merge pull request #217 from Open-CAS/remove-redundant-field
Remove redundant field from struct ocf_cache_device
2019-07-23 09:55:03 +02:00
Jan Musial
917cbd859a Add promotion policy API and use it in I/O path
Promotion policy is supposed to perform ALRU noise filtering by
eliminating one-hit wonders being added to cache and polluting it.

Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-07-19 13:52:00 +02:00
Robert Baldyga
6822ab6140 Remove redundant field from struct ocf_cache_device
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-07-19 12:59:14 +02:00
Robert Baldyga
e64bb50a4b Allocate io and request in single allocation
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-07-17 10:31:23 +02:00
Robert Baldyga
61414f889e Introduce OCF IO allocator
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-07-17 10:31:23 +02:00
Robert Baldyga
e254c9b587 Merge new_io and configure into one function
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-07-17 10:31:23 +02:00
Robert Baldyga
4d2d31ff76 Introduce ocf_io_internal
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-07-17 09:54:51 +02:00
Adam Rutkowski
4f04b2762f Simplified stop path for cache detached case
When cache is detached we cannot assume there is a management
queue created. This change introduces simplified cache stop
path, performing all the necessary deinit without using
IO queues.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-07-08 18:26:35 -04:00
Michal Mielewczyk
636834dae3 Check for existing metadata when attaching cache.
Instead of overriding existing metadata silently, return appropriate error.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-07-08 09:23:32 -04:00
Jan Musial
aab3c4fbaa Fix typo in metadata_hash_entries fcn
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-07-04 14:01:27 +02:00
Jan Musial
ede2bcdf48 Fix volumes deinit routine
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-06-28 13:03:14 +02:00
Jan Musiał
e7e0ad957d
Merge pull request #201 from mmichal10/fix-load-error-handling
Fix error handling in case of failed load
2019-06-26 12:24:02 +02:00
Jan Musial
2c629be4c2 Fix leaking front and core volumes
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-06-26 10:00:49 +02:00
Michal Mielewczyk
52f6d6280b Fix error handling in case of failed load
Store default metadata values and restore them in case of failed load.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-06-25 09:31:05 -04:00
Jan Musial
4a20ce9c25 Fix leaking cache references
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-06-25 11:43:28 +02:00
Michal Rakowski
b1a6c467a0 Introduce core_is_dirty mngt method
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-06-25 09:12:44 +02:00
Michal Rakowski
a818ffabfd Move ocf_mngt_cache_is_dirty to public mngt interface 2019-06-24 15:23:06 +02:00
Michal Rakowski
2925147395 Remove reduntant dirty check
When flush completion is called there could be some clines marked as dirty since those could be in-use during flushing.
2019-06-24 14:24:34 +02:00
Jan Musial
aec01f216c Revert "Disallow ocf_cache_mode_max in io_class config"
This reverts commit 5ad5c521df.

This change broke setting IO-classes with allocation. We use max as a
special value to indicate that the partition should use cache global
caching mode.
2019-06-14 14:08:28 +02:00
Michał Mielewczyk
f9f75e7265
Merge branch 'master' into wo_improvements 2019-06-13 11:32:06 +02:00
Adam Rutkowski
6bb1d21489 Do not repartition cachelines in WO read
WO cache mode should not repartition cachelines nor affect cacheline
status in any way when servicing read. Reading data from the cache
is just an internal optimization. Also WO cache mode is designed to
be used with partitioning based on write life-time hints and read
requests do not carry write lifetime hint by definition.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-06-13 13:14:30 -04:00
Michal Mielewczyk
e8b24d811b Check if all required ops are provided by adapter.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-06-13 04:46:03 -04:00
Adam Rutkowski
9dc1381b77 Refactor ocf_submit_cache_reqs map indexing
Refactoring ocf_submit_cache_reqs to make it clear that
req->map is accessed at index derived from offset argument,
not necesarily starting at 0.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-06-12 18:56:40 -04:00
Adam Rutkowski
b82ed3af26 Initialize @increment in ocf_read_wo_cache_do
Static code analyzers fail to understand that this variable
is always assigned to before usage.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-06-12 13:44:01 -04:00
Adam Rutkowski
b97bb6f53b Add function to check for lazy write cache mode (WO or WB)
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-06-12 12:07:02 -04:00
Adam Rutkowski
82e8c55f4a Write-only cache mode
Write-only cache mode is similar to writeback, however read
operations do not promote data to cache. Reads are mostly serviced
by the core device, only dirty sectors are fetched from the cache.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-06-12 12:07:02 -04:00
Adam Rutkowski
ae6164a49c Helper functions to get request start/end sector in cacheline
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-06-12 12:07:02 -04:00
Michal Mielewczyk
328d27846a Prevent overriding null terminator in cache name 2019-06-11 12:12:07 +02:00
Michal Mielewczyk
46c17144f6 Remove redundant check for core id 2019-06-11 12:12:07 +02:00
Michal Mielewczyk
6cdbac82bc Check for valid core_id value 2019-06-11 12:12:07 +02:00
Michal Mielewczyk
fc5334e419 Return memcpy result 2019-06-11 12:12:07 +02:00
Michal Rakowski
29199cb5d4 Added missing metadata_unlock
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-06-11 12:12:07 +02:00
Michal Rakowski
4789fb38f0 Added asserts in sample env for synchronization functions
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-06-11 11:01:06 +02:00
Michal Rakowski
b1cf6c4642 Changed always returning 0 to void foo
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-06-11 09:53:40 +02:00
Michal Rakowski
30ac3abd74 Small get_ram_needed fix, proper volume is initialized now. 2019-06-11 09:53:40 +02:00
Michal Mielewczyk
be64173066 Fix order of operations in cache stop completion
Prevent metadata updater being freed by pyocf before it's deinitialized by ocf.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-06-06 09:03:26 -04:00
Michal Rakowski
d714f6235b Use rate limited logging in case of engine error
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-06-06 11:27:25 +02:00
Michal Mielewczyk
e6bedb692c Unified management functions prefix.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-06-05 09:31:59 -04:00
Michal Rakowski
9f4536c6e3 Error codes in IO path changed to OCF-specific
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-06-05 09:10:54 +02:00
Robert Baldyga
f240f81641 Make request structure more compressed
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-06-03 19:19:29 +02:00
Adam Rutkowski
d7b3a187e4 Fix condition for setting req->info.dirty_all
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-05-31 19:10:11 -04:00
Michal Wysoczanski
d27f81c588 Add missing new line in error message
Signed-off-by: Michal Wysoczanski <michal.wysoczanski@intel.com>
2019-05-30 00:03:09 +02:00
Robert Baldyga
711de86bff Associate core metadata with core object
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-28 14:49:59 +02:00
Robert Baldyga
417ea8c06f Make atomic recovery path truly asynchronous
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-28 11:31:50 +02:00
Robert Baldyga
46ae8b2ff1 Remove unused OCF_ERR_CACHE_IN_USE error code
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-28 11:20:48 +02:00
Robert Baldyga
8a82be339f Introduce asynchronous cache lock
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-28 11:20:48 +02:00
Robert Baldyga
f9447fda75 Remove all the trailing whitespaces
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-27 17:00:39 +02:00
Robert Baldyga
bdcd4df0ef Remove utils_device.h
Move core mngt related code to ocf_mngt_core.c

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-27 17:00:39 +02:00
Robert Baldyga
7de56940a4 Move ocf_request from utils
ocf_request has always been first class citizen in OCF,
so lets place it along with another essential objects.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-27 15:51:27 +02:00
Robert Baldyga
57bc19103d Remove unused core_io_allocator
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-27 14:19:10 +02:00
Robert Baldyga
ab2fc6d3c3 Rename utils_allocator to utils_realloc
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-27 13:10:17 +02:00
Robert Baldyga
cda536a14a Remove mpool from OCF utils
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-27 13:04:40 +02:00