diff --git a/inc/ocf_cache.h b/inc/ocf_cache.h index dc96487..4f2b909 100644 --- a/inc/ocf_cache.h +++ b/inc/ocf_cache.h @@ -27,6 +27,9 @@ struct ocf_cache_info { uint8_t volume_type; /*!< Cache volume type */ + uint8_t state; + /*!< Cache state (running/flushing/stopping etc...) */ + uint32_t size; /*!< Actual cache size (in cache lines) */ @@ -69,9 +72,6 @@ struct ocf_cache_info { set as a result of reaching IO error threshold */ } fallback_pt; - uint8_t state; - /*!< Cache state (running/flushing/stopping etc...) */ - ocf_eviction_t eviction_policy; /*!< Eviction policy selected */ diff --git a/inc/ocf_io.h b/inc/ocf_io.h index daa7c89..b41bc36 100644 --- a/inc/ocf_io.h +++ b/inc/ocf_io.h @@ -83,16 +83,6 @@ struct ocf_io { */ ocf_start_io_t start; - /** - * @brief OCF IO handle function - */ - ocf_handle_io_t handle; - - /** - * @brief OCF IO completion function - */ - ocf_end_io_t end; - /** * @brief OCF IO private 1 */ @@ -102,6 +92,16 @@ struct ocf_io { * @brief OCF IO private 2 */ void *priv2; + + /** + * @brief OCF IO handle function + */ + ocf_handle_io_t handle; + + /** + * @brief OCF IO completion function + */ + ocf_end_io_t end; }; /** diff --git a/inc/ocf_mngt.h b/inc/ocf_mngt.h index 46becb2..db48410 100644 --- a/inc/ocf_mngt.h +++ b/inc/ocf_mngt.h @@ -851,25 +851,25 @@ struct ocf_mngt_io_class_config { */ uint32_t class_id; + /** + * @brief IO class maximum size + */ + uint32_t max_size; + /** * @brief IO class name */ const char *name; - /** - * @brief IO class eviction priority - */ - int16_t prio; - /** * @brief IO class cache mode */ ocf_cache_mode_t cache_mode; /** - * @brief IO class maximum size + * @brief IO class eviction priority */ - uint32_t max_size; + int16_t prio; }; struct ocf_mngt_io_classes_config { diff --git a/inc/ocf_volume.h b/inc/ocf_volume.h index e4d858e..7331bb6 100644 --- a/inc/ocf_volume.h +++ b/inc/ocf_volume.h @@ -101,6 +101,15 @@ struct ocf_volume_ops { */ void (*close)(ocf_volume_t volume); + /** + * @brief Get volume length + * + * @param[in] volume Volume + * + * @return Volume length in bytes + */ + uint64_t (*get_length)(ocf_volume_t volume); + /** * @brief Get maximum io size * @@ -109,15 +118,6 @@ struct ocf_volume_ops { * @return Maximum io size in bytes */ unsigned int (*get_max_io_size)(ocf_volume_t volume); - - /** - * @brief Get volume length - * - * @param[in] volume Volume - * - * @return Volume lenght in bytes - */ - uint64_t (*get_length)(ocf_volume_t volume); }; /** @@ -136,14 +136,14 @@ struct ocf_volume_properties { struct ocf_volume_caps caps; /*!< Volume capabilities */ - struct ocf_volume_ops ops; - /*!< Volume operations */ - struct ocf_io_ops io_ops; /*!< IO operations */ void (*deinit)(void); /*!< Deinitialize volume type */ + + struct ocf_volume_ops ops; + /*!< Volume operations */ }; /** diff --git a/src/concurrency/ocf_cache_line_concurrency.c b/src/concurrency/ocf_cache_line_concurrency.c index 80990ed..c94330e 100644 --- a/src/concurrency/ocf_cache_line_concurrency.c +++ b/src/concurrency/ocf_cache_line_concurrency.c @@ -37,8 +37,8 @@ struct __waiter { ocf_cache_line_t line; - void *ctx; uint32_t ctx_id; + void *ctx; ocf_req_async_lock_cb cb; struct list_head item; int rw; diff --git a/src/metadata/metadata.h b/src/metadata/metadata.h index 3bb788e..a084bb9 100644 --- a/src/metadata/metadata.h +++ b/src/metadata/metadata.h @@ -199,8 +199,8 @@ struct ocf_metadata_load_properties { enum ocf_metadata_shutdown_status shutdown_status; uint8_t dirty_flushed; ocf_metadata_layout_t layout; - ocf_cache_line_size_t line_size; ocf_cache_mode_t cache_mode; + ocf_cache_line_size_t line_size; char *cache_name; }; diff --git a/src/metadata/metadata_partition_structs.h b/src/metadata/metadata_partition_structs.h index 93feb55..3c4567a 100644 --- a/src/metadata/metadata_partition_structs.h +++ b/src/metadata/metadata_partition_structs.h @@ -14,8 +14,6 @@ struct ocf_user_part_config { char name[OCF_IO_CLASS_NAME_MAX]; uint32_t min_size; uint32_t max_size; - int16_t priority; - ocf_cache_mode_t cache_mode; struct { uint8_t valid : 1; uint8_t added : 1; @@ -24,6 +22,8 @@ struct ocf_user_part_config { * and means that can evict from this partition */ } flags; + int16_t priority; + ocf_cache_mode_t cache_mode; }; struct ocf_user_part_runtime { @@ -40,12 +40,12 @@ typedef bool ( *_lru_hash_locked_pfn)(struct ocf_request *req, in round robin order */ struct ocf_lru_iter { + /* per-partition cacheline iterator */ + ocf_cache_line_t curr_cline[OCF_NUM_EVICTION_LISTS]; /* cache object */ ocf_cache_t cache; /* target partition */ struct ocf_user_part *part; - /* per-partition cacheline iterator */ - ocf_cache_line_t curr_cline[OCF_NUM_EVICTION_LISTS]; /* available (non-empty) eviction list bitmap rotated so that current @evp is on the most significant bit */ unsigned long long next_avail_evp; diff --git a/src/metadata/metadata_structs.h b/src/metadata/metadata_structs.h index d2e7d3f..a6b2221 100644 --- a/src/metadata/metadata_structs.h +++ b/src/metadata/metadata_structs.h @@ -56,12 +56,12 @@ struct ocf_metadata_lock struct ocf_metadata_global_lock global[OCF_NUM_GLOBAL_META_LOCKS]; /*!< global metadata lock (GML) */ env_rwlock eviction[OCF_NUM_EVICTION_LISTS]; /*!< Fast lock for eviction policy */ + env_spinlock partition[OCF_IO_CLASS_MAX]; /* partition lock */ env_rwsem *hash; /*!< Hash bucket locks */ env_rwsem *collision_pages; /*!< Collision table page locks */ - env_spinlock partition[OCF_IO_CLASS_MAX]; /* partition lock */ + ocf_cache_t cache; /*!< Parent cache object */ uint32_t num_hash_entries; /*!< Hash bucket count */ uint32_t num_collision_pages; /*!< Collision table page count */ - ocf_cache_t cache; /*!< Parent cache object */ }; /** diff --git a/src/metadata/metadata_superblock.h b/src/metadata/metadata_superblock.h index b160955..cbc866f 100644 --- a/src/metadata/metadata_superblock.h +++ b/src/metadata/metadata_superblock.h @@ -20,6 +20,10 @@ struct ocf_superblock_config { * shouldn't change!! */ uint8_t clean_shutdown; uint8_t dirty_flushed; + + /* Current core sequence number */ + ocf_core_id_t curr_core_seq_no; + uint32_t magic_number; uint32_t metadata_version; @@ -47,9 +51,6 @@ struct ocf_superblock_config { ocf_eviction_t eviction_policy_type; - /* Current core sequence number */ - ocf_core_id_t curr_core_seq_no; - /* * Checksum for each metadata region. * This field has to be the last one! diff --git a/src/metadata/metadata_updater_priv.h b/src/metadata/metadata_updater_priv.h index 9876ed2..232f0d5 100644 --- a/src/metadata/metadata_updater_priv.h +++ b/src/metadata/metadata_updater_priv.h @@ -14,7 +14,7 @@ struct ocf_metadata_updater { struct ocf_metadata_io_syncher { struct list_head in_progress_head; struct list_head pending_head; - env_mutex lock; + env_mutex lock __attribute__((aligned(64))); } syncher; void *priv; diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index c75f5a6..65a832b 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -39,8 +39,6 @@ * @brief Helpful struct to start cache */ struct ocf_cache_mngt_init_params { - bool metadata_volatile; - ocf_ctx_t ctx; /*!< OCF context */ @@ -50,6 +48,8 @@ struct ocf_cache_mngt_init_params { uint8_t locked; /*!< Keep cache locked */ + bool metadata_volatile; + /** * @brief initialization state (in case of error, it is used to know * which assets have to be deallocated in premature exit from function diff --git a/src/ocf_cache_priv.h b/src/ocf_cache_priv.h index 44cbf9a..e80c8b4 100644 --- a/src/ocf_cache_priv.h +++ b/src/ocf_cache_priv.h @@ -81,57 +81,60 @@ struct ocf_cache { struct ocf_lst lst_part; struct ocf_user_part user_parts[OCF_IO_CLASS_MAX + 1]; - struct ocf_metadata metadata; - ocf_freelist_t freelist; ocf_eviction_t eviction_policy_init; + uint32_t fallback_pt_error_threshold; + ocf_queue_t mngt_queue; + + struct ocf_metadata metadata; + struct { /* cache get/put counter */ - struct ocf_refcnt cache; + struct ocf_refcnt cache __attribute__((aligned(64))); /* # of requests potentially dirtying cachelines */ - struct ocf_refcnt dirty; + struct ocf_refcnt dirty __attribute__((aligned(64))); /* # of requests accessing attached metadata, excluding * management reqs */ - struct ocf_refcnt metadata; + struct ocf_refcnt metadata __attribute__((aligned(64))); } refcnt; - uint32_t fallback_pt_error_threshold; + struct ocf_core core[OCF_CORE_MAX]; + + ocf_pipeline_t stop_pipeline; + env_atomic fallback_pt_error_counter; env_atomic pending_read_misses_list_blocked; env_atomic pending_read_misses_list_count; - env_atomic last_access_ms; - env_atomic pending_eviction_clines; - struct list_head io_queues; - ocf_queue_t mngt_queue; - - uint16_t ocf_core_inactive_count; - struct ocf_core core[OCF_CORE_MAX]; - env_atomic flush_in_progress; + env_mutex flush_mutex; + + struct ocf_metadata_updater metadata_updater; struct ocf_cleaner cleaner; - struct ocf_metadata_updater metadata_updater; + + struct list_head io_queues; ocf_promotion_policy_t promotion_policy; - struct ocf_async_lock lock; + struct { + uint32_t max_queue_size; + uint32_t queue_unblock_size; + } backfill; + + void *priv; /* * Most of the time this variable is set to 0, unless user requested * interruption of flushing process. */ int flushing_interrupted; - env_mutex flush_mutex; - struct { - uint32_t max_queue_size; - uint32_t queue_unblock_size; - } backfill; + uint16_t ocf_core_inactive_count; bool pt_unaligned_io; @@ -139,9 +142,9 @@ struct ocf_cache { struct ocf_trace trace; - ocf_pipeline_t stop_pipeline; - - void *priv; + struct ocf_async_lock lock; + // This should be on it's own cacheline ideally + env_atomic last_access_ms; }; static inline ocf_core_t ocf_cache_get_core(ocf_cache_t cache, diff --git a/src/ocf_ctx_priv.h b/src/ocf_ctx_priv.h index 9cba8a5..3ff69b0 100644 --- a/src/ocf_ctx_priv.h +++ b/src/ocf_ctx_priv.h @@ -17,22 +17,25 @@ * @brief OCF main control structure */ struct ocf_ctx { - const struct ocf_ctx_ops *ops; - const struct ocf_ctx_config *cfg; - struct ocf_logger logger; struct ocf_volume_type *volume_type[OCF_VOLUME_TYPE_MAX]; - env_atomic ref_count; + env_rmutex lock; + struct ocf_logger logger; + + const struct ocf_ctx_ops *ops; + struct { + struct env_mpool *req; + struct env_mpool *mio; + } resources; struct list_head caches; struct { struct list_head core_pool_head; int core_pool_count; } core_pool; - struct { - struct env_mpool *req; - struct env_mpool *mio; - } resources; + + const struct ocf_ctx_config *cfg; + env_atomic ref_count; }; #define ocf_log_prefix(ctx, lvl, prefix, fmt, ...) \ diff --git a/src/ocf_queue_priv.h b/src/ocf_queue_priv.h index a96b358..ad27571 100644 --- a/src/ocf_queue_priv.h +++ b/src/ocf_queue_priv.h @@ -11,12 +11,9 @@ struct ocf_queue { ocf_cache_t cache; - env_atomic io_no; - - env_atomic ref_count; + void *priv; struct list_head io_list; - env_spinlock io_list_lock; /* per-queue free running global metadata lock index */ unsigned lock_idx; @@ -24,20 +21,22 @@ struct ocf_queue { /* per-queue free running eviction list index */ unsigned eviction_idx; - /* Tracing reference counter */ - env_atomic64 trace_ref_cntr; - - /* Tracing stop request */ - env_atomic trace_stop; + struct ocf_seq_cutoff *seq_cutoff; struct list_head list; const struct ocf_queue_ops *ops; - struct ocf_seq_cutoff *seq_cutoff; + /* Tracing reference counter */ + env_atomic64 trace_ref_cntr; - void *priv; -}; + /* Tracing stop request */ + env_atomic trace_stop; + env_atomic io_no; + + env_atomic ref_count; + env_spinlock io_list_lock; +} __attribute__((__aligned__(64))); static inline void ocf_queue_kick(ocf_queue_t queue, bool allow_sync) { diff --git a/src/ocf_request.h b/src/ocf_request.h index 945ec42..b3db712 100644 --- a/src/ocf_request.h +++ b/src/ocf_request.h @@ -106,9 +106,6 @@ struct ocf_request { struct ocf_io_internal ioi; /*!< OCF IO associated with request */ - const struct ocf_engine_callbacks *engine_cbs; - /*!< Engine owning the request */ - env_atomic ref_count; /*!< Reference usage count, once OCF request reaches zero it * will be de-initialed. Get/Put method are intended to modify @@ -128,6 +125,9 @@ struct ocf_request { env_atomic master_remaining; /*!< Atomic counter for core device */ + const struct ocf_engine_callbacks *engine_cbs; + /*!< Engine owning the request */ + ocf_cache_t cache; /*!< Handle to cache instance */ diff --git a/src/ocf_volume_priv.h b/src/ocf_volume_priv.h index e297196..cf361be 100644 --- a/src/ocf_volume_priv.h +++ b/src/ocf_volume_priv.h @@ -23,17 +23,17 @@ struct ocf_volume_type { struct ocf_volume { ocf_volume_type_t type; struct ocf_volume_uuid uuid; + struct { + unsigned discard_zeroes:1; + /* true if reading discarded pages returns 0 */ + } features; bool opened; bool uuid_copy; void *priv; ocf_cache_t cache; struct list_head core_pool_item; - struct { - unsigned discard_zeroes:1; - /* true if reading discarded pages returns 0 */ - } features; - struct ocf_refcnt refcnt; -}; + struct ocf_refcnt refcnt __attribute__((aligned(64))); +} __attribute__((aligned(64))); int ocf_volume_type_init(struct ocf_volume_type **type, const struct ocf_volume_properties *properties, diff --git a/src/promotion/nhit/nhit_hash.c b/src/promotion/nhit/nhit_hash.c index 4a31860..2ef77ea 100644 --- a/src/promotion/nhit/nhit_hash.c +++ b/src/promotion/nhit/nhit_hash.c @@ -96,6 +96,7 @@ struct nhit_list_elem { }; struct nhit_hash { + env_spinlock rb_pointer_lock; ocf_cache_line_t hash_entries; uint64_t rb_entries; @@ -104,7 +105,6 @@ struct nhit_hash { struct nhit_list_elem *ring_buffer; uint64_t rb_pointer; - env_spinlock rb_pointer_lock; }; static uint64_t calculate_hash_buckets(uint64_t hash_size) diff --git a/src/utils/utils_list.h b/src/utils/utils_list.h index 5dfd4f7..c8a069d 100644 --- a/src/utils/utils_list.h +++ b/src/utils/utils_list.h @@ -41,13 +41,13 @@ typedef int (*ocf_mlst_cmp)(struct ocf_cache *cache, struct ocf_lst { struct ocf_lst_entry *head; ocf_cache_line_t invalid; - ocf_mlst_getter getter; - ocf_mlst_cmp cmp; - struct ocf_cache *cache; - struct { uint32_t active : 1; } flags; + + ocf_mlst_getter getter; + ocf_mlst_cmp cmp; + struct ocf_cache *cache; }; static inline void ocf_lst_init_entry(struct ocf_lst *lst, diff --git a/tests/functional/pyocf/types/io.py b/tests/functional/pyocf/types/io.py index 3ea35b8..8a3daa8 100644 --- a/tests/functional/pyocf/types/io.py +++ b/tests/functional/pyocf/types/io.py @@ -43,10 +43,10 @@ class Io(Structure): ("_dir", c_uint32), ("_io_queue", c_void_p), ("_start", START), - ("_handle", HANDLE), - ("_end", END), ("_priv1", c_void_p), ("_priv2", c_void_p), + ("_handle", HANDLE), + ("_end", END), ] @classmethod diff --git a/tests/functional/pyocf/types/ioclass.py b/tests/functional/pyocf/types/ioclass.py index e5bafdb..908f281 100644 --- a/tests/functional/pyocf/types/ioclass.py +++ b/tests/functional/pyocf/types/ioclass.py @@ -23,10 +23,10 @@ class IoClassInfo(Structure): class IoClassConfig(Structure): _fields_ = [ ("_class_id", c_uint32), - ("_name", c_char_p), - ("_prio", c_uint16), - ("_cache_mode", c_int), ("_max_size", c_uint32), + ("_name", c_char_p), + ("_cache_mode", c_int), + ("_prio", c_uint16), ] diff --git a/tests/functional/pyocf/types/stats/cache.py b/tests/functional/pyocf/types/stats/cache.py index d4ef4ff..521416d 100644 --- a/tests/functional/pyocf/types/stats/cache.py +++ b/tests/functional/pyocf/types/stats/cache.py @@ -19,6 +19,7 @@ class CacheInfo(Structure): _fields_ = [ ("attached", c_bool), ("volume_type", c_uint8), + ("state", c_uint8), ("size", c_uint32), ("inactive", _Inactive), ("occupancy", c_uint32), @@ -27,7 +28,6 @@ class CacheInfo(Structure): ("dirty_for", c_uint64), ("cache_mode", c_uint32), ("fallback_pt", _FallbackPt), - ("state", c_uint8), ("eviction_policy", c_uint32), ("cleaning_policy", c_uint32), ("promotion_policy", c_uint32), diff --git a/tests/functional/pyocf/types/volume.py b/tests/functional/pyocf/types/volume.py index ae682a5..29bf090 100644 --- a/tests/functional/pyocf/types/volume.py +++ b/tests/functional/pyocf/types/volume.py @@ -53,8 +53,8 @@ class VolumeOps(Structure): ("_submit_write_zeroes", SUBMIT_WRITE_ZEROES), ("_open", OPEN), ("_close", CLOSE), - ("_get_max_io_size", GET_MAX_IO_SIZE), ("_get_length", GET_LENGTH), + ("_get_max_io_size", GET_MAX_IO_SIZE), ] @@ -64,9 +64,9 @@ class VolumeProperties(Structure): ("_io_priv_size", c_uint32), ("_volume_priv_size", c_uint32), ("_caps", VolumeCaps), - ("_ops", VolumeOps), ("_io_ops", IoOps), ("_deinit", c_char_p), + ("_ops", VolumeOps), ]