Commit Graph

505 Commits

Author SHA1 Message Date
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
Jan Musiał
93a06686a7
Merge pull request #165 from robertbaldyga/ctx-get-put
Give ocf_ctx get/put semantics
2019-05-24 14:29:04 +02:00
Robert Baldyga
c903d13ad2 Give ocf_ctx get/put semantics
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-23 15:50:10 +02:00
Robert Baldyga
7ff4a349ec Use enum cache line values when validating config
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-23 13:29:49 +02:00
Robert Baldyga
efa96ef7bd Add ocf_cache_line_size_none
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-23 13:29:49 +02:00
Michal Rakowski
8c96270ce8
Merge pull request #164 from robertbaldyga/add-open-cores-parameter
Add open_cores parameter to ocf_mngt_cache_device_config
2019-05-23 10:44:47 +02:00
Michal Rakowski
4216ff78f1
Merge pull request #163 from robertbaldyga/put-queue-after-deallocating-req
Put queue after deallocating request
2019-05-23 10:38:13 +02:00
Robert Baldyga
2cf2a59584 Add open_cores parameter to ocf_mngt_cache_device_config
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-21 18:18:33 +02:00
Robert Baldyga
dbef4b721c Put queue after deallocating request
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-21 16:09:58 +02:00
Michal Rakowski
76bcac5b45
Merge pull request #160 from robertbaldyga/remove-unnecessary-attach-step
Remove unnecessary attach step
2019-05-21 14:02:19 +02:00
Michal Rakowski
9b3bf801e2
Merge pull request #159 from robertbaldyga/req-store-core-handle
Store core handle instead of core_id in ocf_request
2019-05-21 13:52:55 +02:00
Robert Baldyga
b551d301ff ocf_trace: Fix req naming convention
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-21 12:30:29 +02:00
Robert Baldyga
0490dd8bd4 ocf_reqest: Store core handle instead of core_id
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-21 12:30:29 +02:00
Robert Baldyga
5ad5c521df Disallow ocf_cache_mode_max in io_class config
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-21 09:33:33 +02:00
Robert Baldyga
e8bf299176 Remove unnecessary attach step
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-21 09:17:39 +02:00
Robert Baldyga
f5463d9a16 Set queue for metadata io submitted to cache volume
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-14 14:15:47 +02:00
Robert Baldyga
c263e3e9eb metadata: Put io before callback invocation
This allows for safe volume destruction in callback function.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-13 12:12:37 +02:00
Michal Rakowski
0412e05260
Merge pull request #73 from mmichal10/cleaner-kick
Add kick function for cleaner
2019-05-10 14:33:49 +02:00
Michal Mielewczyk
7165bc16c3 Add kick function for cleaner
ocf_kick_cleaner() allows to perfom cleaning immediately.

Nop cleaning policy now returns new 'OCF_CLEANER_DISABLE' macro which indicates
that cleaing shouldn't be performed. To enable it back, ocf_kick_cleaner()
should be called.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-05-10 08:09:56 -04:00
Michał Wysoczański
a145815747
Merge pull request #149 from Donaim/master
Set core_id during load if user did not specify one
2019-05-10 12:59:07 +02:00
Robert Baldyga
580d5506cd Stop treating UUID as ANSI string
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-10 12:49:51 +02:00
Vitaliy Mysak
8391300bc8 Set core_id during load if user did not specify one
If cfg->core_id is OCF_CORE_MAX and that core matches the UUID of
existing not opened one, then set cfg->core_id to id of that core.

This is useful when loading cache from metadata: if user does not store
the ids of cores but relies on OCF to assign them, there is no need to
not reassign them on load.

Previus behaviur when cfg->core_id != id of core with matching UUID is
maintained.

Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
2019-05-09 23:39:18 +00:00
Michal Rakowski
94ef5a5249
Merge pull request #148 from mmichal10/fix-cleaner-stopping
Distinguish stopping cache from attached and detached states.
2019-05-09 14:42:17 +02:00
Michal Mielewczyk
676de5254f Distinguish stopping cache from attached and detached states.
If stopping attached cache, cleaner should be stopped.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-05-09 08:21:36 -04:00
Michal Rakowski
78fea63178
Merge pull request #147 from robertbaldyga/fix-compilation-error-int-const-bool-context
Fix compilation error
2019-05-09 12:57:44 +02:00
Jan Musiał
8e4a1f10f0
Merge pull request #146 from robertbaldyga/init-core-pool-with-ctx
Initialize and deinitialize core pool with ctx
2019-05-09 12:41:00 +02:00
Robert Baldyga
0305fba4a3 Fix compilation error
Passing int constant directly to OCF_PL_NEXT_ON_SUCCESS_RET() macro caused
following compilation error (on GCC 7.4.0):

src/ocf/mngt/ocf_mngt_core.c:599:33: error: ?:
using integer constants in boolean context [-Werror=int-in-bool-context]
    error ? -OCF_ERR_WRITE_CACHE : 0);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
src/ocf/mngt/../utils/utils_pipeline.h:145:6: note:
in definition of macro ‘OCF_PL_NEXT_ON_SUCCESS_RET’
  if (error) \
      ^~~~~

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-09 12:02:41 +02:00
Robert Baldyga
6c7df8abf6 Initialize and deinitialize core pool with ctx
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-09 11:22:06 +02:00
Robert Bałdyga
1c9fe96663
Merge pull request #133 from arutk/ajrutkow_async_counters
Extended reference counting
2019-05-08 14:23:50 +02:00
Robert Baldyga
7b88aac56f Remove "interruption" argument from flush() functions
As non-interruptible flushes are no longer triggered from OCF
internals, we can get rid of "interruption" argument and let
adapters handle it themselves.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-07 17:23:19 +02:00
Adam Rutkowski
aafc067fa5 Combine cache ref counter and valid flag into ocf_refcnt
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-05-06 19:37:51 -04:00
Adam Rutkowski
4251cc63e7 Do not send zero_line request if d2c
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-05-06 19:37:51 -04:00
Adam Rutkowski
af4b9b13d0 Freeze / unfreeze cleaning reference counters in detach/attach
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-05-06 19:37:51 -04:00
Adam Rutkowski
348b0f9ab8 Async wait for cleaner completion
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-05-06 19:37:49 -04:00
Adam Rutkowski
0e15c693fd Return post modification value from ocf_refcnt_inc/dec
If counter is frozen then increment returns 0.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-05-06 19:23:11 -04:00
Adam Rutkowski
962f9d17d1 Remove functions to wait for cache pending requests
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-05-06 19:23:11 -04:00
Adam Rutkowski
92e9ae12f1 Wait for metadata requests in stop
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-05-06 19:23:11 -04:00
Adam Rutkowski
dc716d6a08 Use ref counter to track attach state
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-05-06 19:23:10 -04:00
Adam Rutkowski
979f51612f Move dirty ref counter to cache->refcnt aggregate
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-05-06 19:22:29 -04:00
Adam Rutkowski
555f477248 Do not increment attached metadata counter on behalf of mngt requests
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-05-06 19:22:29 -04:00
Robert Baldyga
42b5cd1777 Get cache on queue creation and put it on queue destruction
This prevents situation when cache object is being destroyed
while some queues still exist.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-06 17:30:32 +02:00
Robert Baldyga
a82d420ee0 Add management queue guards where needed
Prevent starting management operations that require pipeline
when management queue isn't set.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-02 17:26:04 +02:00
Robert Baldyga
c2aea209db Introduce pipeline *_RET macros
This simplifies code by allowing to express programmer intent
explicitly and helps to avoid missing return statements (this patch
fixes at least one bug related to this).

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-02 17:22:43 +02:00
Robert Baldyga
1373471af7 Introduce OCF_CMPL_RET() macro
This simplifies cases when we want to call completion callback
and immediately return from void-returning function, by allowing
to explicitly express programmers intent. That way we can avoid
cases when return statement is missing by mistake (this patch
fixes at least one bug related to this).

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-02 17:22:36 +02:00
Robert Baldyga
bcb2e670f3 metadata: Remove unnecessary check
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-05-02 17:22:28 +02:00
Adam Rutkowski
26579e53cd Refactor cache mngt stop/detach for better error handling
_ocf_mngt_cache_unplug context is now provided by the caller.
This way _ocf_mngt_cache_unplug returns only non-critical (cache write)
errors, allowing stop/detach operation to always proceed and optionally
finish with error. This eliminates the need for rolling back previous
stop/detach operations, which might turn out to be impossible e.g.
under memory pressure.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-04-23 16:16:18 -04:00
Vitaliy Mysak
bf2242fade Fix immediate reassign
Don't reassign value of cache without any previus use.
It produced warnings when analyzing with scanbuild.

Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
2019-04-19 09:25:23 -04:00
Adam Rutkowski
c7df9161be Use secure alloc in _raw_dynamic_get_item
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-04-18 23:11:12 -04:00
Michal Rakowski
3d6b3ea2e8 Added missing return in metadata_probe_cores
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-04-18 16:35:05 +02:00
Adam Rutkowski
c5a80cc488 Use env_secure_(alloc/free) macro for metadata allocations
Adapter can opt to take additional steps to securely allocate
memory used by OCF to store cache metadata. Typically this would
involve mlocking pages and zeroing memory before deallocation.

Memory allocated using secure_alloc is not expected to be zeroed
or physically continous.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-04-18 17:54:05 -04:00
Michał Mielewczyk
2af7e7b4de
Merge pull request #125 from arutk/vol_ref_cnt
Wait for IO put in volume close
2019-04-18 09:02:58 +02:00
Adam Rutkowski
1efb301462 Wait for IO put in volume close
Volume close should not close underlying device until all
I/O targeting this volume are deallocated. To achieve this
a reference counter is added to volume. Counter value
matches number of I/O objects associated with volume. Counter
is freezed when volume is closed, blocking allocation of new
I/O objects.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-04-17 23:12:04 -04:00
Adam Rutkowski
407470c25d Add reference counter init routine
This is useful when reference counter is initialized in non-zeroed
memory (or assuming atomic variable is not properly initialized by
memseting to zero).

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-04-17 23:12:04 -04:00
Michal Mielewczyk
5e52ac4ef2 Rename 'printf' field name in logger ops to 'print'.
Due the aggresive security checks in compiler 'printf' might be substituded with
'__printf_chk'. However it does not differentiate whether substituted string is
library function call whether field in structure.

By renaming field we prevent it to be unintentionally subustituted by the
preprocessor.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-04-17 11:37:47 -04:00
Michal Mielewczyk
ff079aa5b4 Initialize variable meant for keeping ocf_mngt_start_trace() result.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-04-17 11:28:05 -04:00
Jan Musiał
121b3233e4
Merge pull request #120 from arutk/core-query-api
Add API to query for core devices associated with cache
2019-04-17 13:33:04 +02:00
Adam Rutkowski
dfd89dd43a Probe core UUIDs from metadata
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-04-17 14:07:42 -04:00
Michal Rakowski
4652b009d6 Added seq_cutoff_policy check
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-04-16 14:48:41 +02:00
Adam Rutkowski
f0c3e049c6
Merge pull request #117 from mmichal10/null-ptr-on-cache-id-reuse
Fix teardown after failed start cache operation.
2019-04-11 09:03:09 -04:00
Michal Mielewczyk
fbfd17ec42 Fix teardown after failed start cache operation.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-04-11 04:33:32 -04:00
Adam Rutkowski
a6e7ee528e Fix error handling in cache unplug
Errors not related to cache disk I/O failure should force
cache stop to return with error without deinitializing cache
instance.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-04-10 15:15:12 -04:00
Jan Musial
15fb0d04bd Fix IO queue validation
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-04-08 14:40:20 +02:00
Jan Musial
5d6277e7cf Fix flushing of volatile metadata containers
Before async metadata we used to return 0 on flushing volatile
containers, this way we didn't have to special-case them.
This change brings back this behavior.

Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-04-08 12:39:53 +02:00
Michał Mielewczyk
f9e5d019df
Merge pull request #103 from arutk/arutk-force-separate-mngmt-io-queue
Do not allow top volume I/O on management queue
2019-04-05 13:22:40 +02:00
Adam Rutkowski
d88a4ac57a Do not allow top volume I/O on management queue
Core volume I/O must not be queued on management queue - this would
break I/O accounting code, resulting in use-after-free type of errors
after cache detach, core remove etc.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-04-05 14:55:28 -04:00
Adam Rutkowski
0b68e02e9a Reset interrupted flag in core_flush
This line got lost in async flush rework

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-04-05 13:26:55 -04:00
Michał Wysoczański
0192f4070d
Merge pull request #96 from micrakow/volume_move_fix
Added original uuid deinitialization without freeing
2019-04-02 11:31:46 +02:00
Michal Rakowski
a6c75b9900 Added original uuid deinitialization without freeing
There is a risk that without uuid.data pointer denitialization it will
be freed during original volume deinit, zeroing uuid.data pointer
prevents that.

Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
2019-04-02 11:02:51 +02:00
Adam Rutkowski
2aba5a2843 Add volume_params argument to bottom volume open
This pointer is used to provide optional volume specific data
from the user down to bottom volume open callback. volume_params
is provided to OCF in ocf_mngt_cache_device_config.volume_params.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-04-01 19:28:14 -04:00
Adam Rutkowski
7e9ff6456d
Merge pull request #92 from mmichal10/fix-preventing-metadata-override
Return error on start when detected old metadata of not flushed cache.
2019-03-29 16:29:22 +01:00
Michal Mielewczyk
a1075f7cf6 Return error on start when detected old metadata of not flushed cache.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-03-29 11:22:49 -04:00
Adam Rutkowski
d34942e7e5
Merge pull request #91 from mmichal10/fix-cleaning-pol-ret-val
Fix inappropriate return value when setting cleaning policy
2019-03-29 15:53:21 +01:00
Michal Mielewczyk
05be94f7e5 Fix inappropriate return value when setting cleaning policy
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-03-29 10:45:45 -04:00
Adam Rutkowski
9a3713fe74 Rename default IO class to lowercase "unclassified"
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-03-29 15:15:44 -04:00
Robert Baldyga
5699422586 Introduce ocf_cache_has_pending_cleaning() function
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-03-26 15:09:52 +01:00
Michał Wysoczański
03c95d36f0
Merge pull request #82 from robertbaldyga/asynchronous-metadata
Handle metadata asynchronously
2019-03-26 12:54:26 +01:00
Robert Baldyga
6cd84476f6 Handle metadata asynchronously
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-03-26 12:49:23 +01:00
Michał Wysoczański
bf9b85150f
Merge pull request #87 from arutk/prv-async_flush
Asynchronous flush and purge - part 2
2019-03-26 12:34:24 +01:00
Adam Rutkowski
54374639b8 Asynchronous wait for dirty requests in flush
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-03-26 15:23:42 -04:00
Adam Rutkowski
7003d38b44 Encapsulate request reference counting logic in utils_refcnt
In order to synchronize management operations with I/O OCF
maintains in-flight request counters. For example such ref
counters are used during ocf_mngt_detach to drain requests
accessing cache metadata (cache requests counter) and in
ocf_mngt_flush where we wait for outstanding requests sent
in write back mode (dirty requests counter).

Typically I/O threads increment cache/dirty counter when
creating request and decrement counter on request completion.
Management thread sets atomic variable to signal the start of
management operation. I/O threads react to this by changing
I/O requests mode so that the cache/dirty reference counter
is not incremented. As a result reference counter keeps getting
decremented. Management thread waits for the counter to drop to 0
and proceeds with management operation with assumption that no
cache/dirty requests are in progress.

This patch introduces a handy utility for requests reference
counting logic. ocf_refcnt_inc / dec are used to increment/
decrement counter. ocf_refcnt_freeze() makes subsequent
ocf_refcnt_inc() calls to return false, indicating that counter
cannot be incremented at this moment. ocf_refcnt_register_zero_cb
can be used to asynchronously wait for counter to drop to 0.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-03-26 15:22:31 -04:00
Michał Wysoczański
08a5b9d2a4
Merge pull request #86 from Donaim/delay-put-cache
Put cache after doing pipeline_destroy
2019-03-26 11:38:01 +01:00
Vitaliy Mysak
2f2f004867 Put cache after doing pipeline_destroy
Cache is used during pipeline_destroy which means that
doing put_cache before destroying pipeline may result in
accessing memory that was freed.

Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
2019-03-26 19:30:34 +00:00
Adam Rutkowski
1a234744ef Fix flush cache error handling
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-03-25 22:26:53 -04:00
Vitaliy Mysak
51396bf0e6 atomic_dec_return -> env_atomic_dec_return
Fix usage of undefined function

Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
2019-03-26 02:55:45 +00:00
Robert Bałdyga
a084c1cb1c
Merge pull request #80 from arutk/prv-async_flush
Asynchronous flush and purge operations - part 1
2019-03-22 23:24:10 +01:00
Adam Rutkowski
0d0fd0be75 Asynchronous implementation of flush and purge - part 1
For flush/purge entry points to be fully asynchronous we still
need to rework flush mutex and waiting for outstanding dirty
requests.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
2019-03-22 17:04:33 -04:00
Robert Baldyga
ae1f600b57 Add missing env_rwsem_up_write() in ocf_cleaner_run()
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-03-22 15:51:40 +01:00
Robert Baldyga
9c72aed559 Add missing context size to pipeline properties
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-03-22 10:27:42 +01:00
Michał Wysoczański
2a2f14ec42
Merge pull request #77 from robertbaldyga/async-save-core-add-remove
Implement asynchronous save, add core and remove core
2019-03-22 10:01:39 +01:00
Robert Bałdyga
70df1d80a1
Merge pull request #79 from Donaim/cleaner-set-queue
Set io_queue for cleaner IOs
2019-03-21 10:08:39 +01:00
Vitaliy Mysak
b9cae8b164 Set io_queue for cleaner IOs
Send cleaner IOs with appropriate queue set
This solves the issue of bottom adapter getting NULL in io->io_queue

Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
2019-03-21 10:03:56 +01:00
Robert Baldyga
72b6f35f52 Implement asynchronous save, add core and remove core
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-03-21 09:03:59 +01:00
Robert Baldyga
23b0a32aec Parametrize pipeline steps
This allows to reuse same step functions giving them different parameters
on each step.

Additionally move pipeline to utils, to make it accessible to other
subsystems of OCF (e.g. metadata).

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-03-20 17:06:56 +01:00
Robert Baldyga
91e0345b78 Implement asynchronous attach, load, detach and stop
NOTE: This is still not the real asynchronism. Metadata interfaces
are still not fully asynchronous.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-03-18 15:06:57 +01:00
Robert Baldyga
c5df82f2cb Make management API asynchronous
NOTE: This patch only changes API that pretends to be asynchronous.
Most of management operations are still performed synchronously.
The real asynchronism will be introduced in the next patches.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-03-12 10:33:26 +01:00
Michal Mielewczyk
d06f376627 Alru cleaning policy improvement
Instead of calling flush separatly for each IO class, it is called after
collecting number of dirty cache lines defined by user or after iterating
through all IO classes.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-03-11 04:08:16 -04:00
Michal Mielewczyk
b611c0e67a Calling completions function in nop cleaning policy.
Unlocking cache and putting queue are perormed in cleaning completion, so all
cleaning policies has to call completion.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
2019-03-11 04:08:16 -04:00
Michal Rakowski
e5227cef89 Implement pyocf adapter with sample OCF test
PyOCF is a tool written with testing OCF functionality in mind.
It is a Python3 (3.6 version required) package which wraps OCF
by providing Python objects in place of OCF objects (volumes, queues,
etc). Thin layer of translation between OCF objects and PyOCF objects
enables using customized behaviors for OCF primitives by subclassing
PyOCF classes.

This initial version implements only WT and WI modes and single,
synchronously operating Queue.

TO DO:

  - Queues/Cleaner/MetadataUpdater implemented as Python threads
  - Loading of caches from PyOCF Volumes (fix bugs in OCF)
  - Make sure it works multi-threaded for more sophisticated tests

Co-authored-by: Jan Musial <jan.musial@intel.com>
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
Signed-off-by: Jan Musial <jan.musial@intel.com>
2019-03-07 12:48:40 +01:00
Michal Rakowski
794b008127
Merge pull request #66 from robertbaldyga/metadata-probe-asynchronous
Make metadata probe asynchronous
2019-03-04 12:26:34 +01:00
Robert Baldyga
9b9b965b55 Add cache locking functions in trylock variant
- Add cache trylock and read trylock functions.
- Introduce new error code -OCF_ERR_NO_LOCK.
- Change trylock functions in env to return this code in case of
  lock contention.

[ENV CHANGES REQUIRED]
Following functions should return 0 on success or -OCF_ERR_NO_LOCK
in case of lock contention:
- env_mutex_trylock()
- env_rwsem_up_read_trylock()
- env_rwsem_up_write_trylock()

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-03-01 17:31:32 +01:00
Robert Baldyga
9c0390a6ce Make metadata probe asynchronous
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2019-03-01 15:46:16 +01:00