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_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/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 3a1bf27..e80c8b4 100644 --- a/src/ocf_cache_priv.h +++ b/src/ocf_cache_priv.h @@ -86,6 +86,7 @@ struct ocf_cache { ocf_eviction_t eviction_policy_init; uint32_t fallback_pt_error_threshold; + ocf_queue_t mngt_queue; struct ocf_metadata metadata; @@ -99,39 +100,32 @@ struct ocf_cache { struct ocf_refcnt metadata __attribute__((aligned(64))); } refcnt; - ocf_pipeline_t stop_pipeline; - 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; env_atomic flush_in_progress; + env_mutex flush_mutex; - struct list_head io_queues; - ocf_queue_t mngt_queue; + 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; - - env_mutex flush_mutex; - struct { uint32_t max_queue_size; uint32_t queue_unblock_size; } backfill; - struct ocf_trace trace; - void *priv; /* @@ -145,6 +139,12 @@ struct ocf_cache { bool pt_unaligned_io; bool use_submit_io_fast; + + struct ocf_trace trace; + + 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..67b42e2 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,19 +21,21 @@ 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; }; 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 007746a..e966dae 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 5661b57..cf361be 100644 --- a/src/ocf_volume_priv.h +++ b/src/ocf_volume_priv.h @@ -23,15 +23,15 @@ 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 __attribute__((aligned(64))); } __attribute__((aligned(64))); 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,