From 9784abefd730a662ec16c04fb4915a934426e9f1 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Thu, 7 Apr 2022 09:08:38 +0200 Subject: [PATCH 1/2] casadm: remove dead code Signed-off-by: Michal Mielewczyk --- casadm/cas_lib.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/casadm/cas_lib.c b/casadm/cas_lib.c index eff10fd..43d2cc8 100644 --- a/casadm/cas_lib.c +++ b/casadm/cas_lib.c @@ -1033,20 +1033,12 @@ int start_cache(uint16_t cache_id, unsigned int cache_init, } } - check_cache_scheduler(cache_device, - cmd.cache_elevator); - - status = SUCCESS; + check_cache_scheduler(cache_device, cmd.cache_elevator); check_cache_state_incomplete(cache_id, fd); close(fd); - if (status == SUCCESS) { - cas_printf(LOG_INFO, "Successfully added cache instance %u\n", cache_id); - } else { - cas_printf(LOG_ERR, "Failed to start cache\n"); - return FAILURE; - } + cas_printf(LOG_INFO, "Successfully added cache instance %u\n", cache_id); return SUCCESS; } @@ -1826,14 +1818,14 @@ int remove_core(unsigned int cache_id, unsigned int core_id, } void check_cache_state_incomplete(int cache_id, int fd) { - struct cache_device *cache; + struct cache_device *cache; int i; - + for (i = 0; i < CORE_ADD_MAX_TIMEOUT; i++) { cache = get_cache_device_by_id_fd(cache_id, fd, false); - + if (cache == NULL) { - return; + return; } if (cache->core_count == cache->expected_core_count) { @@ -1844,7 +1836,7 @@ void check_cache_state_incomplete(int cache_id, int fd) { cache = NULL; return; } - + free(cache); cache = NULL; @@ -3055,7 +3047,7 @@ int standby_activate(int cache_id, const char *cache_device) if(fd == -1) return FAILURE; - check_cache_state_incomplete(cache_id, fd); + check_cache_state_incomplete(cache_id, fd); close(fd); cas_printf(LOG_INFO, "Successfully activated cache instance %hu\n", From 4dd6aae999b54aef1d48d2ef6f247652a0ebb5f1 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Thu, 7 Apr 2022 12:15:02 +0200 Subject: [PATCH 2/2] casadm: refactor printing cache incompleteness msg Signed-off-by: Michal Mielewczyk --- casadm/cas_lib.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/casadm/cas_lib.c b/casadm/cas_lib.c index 43d2cc8..b596258 100644 --- a/casadm/cas_lib.c +++ b/casadm/cas_lib.c @@ -665,8 +665,7 @@ int get_core_info(int fd, int cache_id, int core_id, return SUCCESS; } -static int get_core_device(int cache_id, int core_id, - struct core_device *core, bool by_id_path) +static int get_core_device(int cache_id, int core_id, struct core_device *core, bool by_id_path) { int fd; struct kcas_core_info cmd_info; @@ -1818,30 +1817,18 @@ int remove_core(unsigned int cache_id, unsigned int core_id, } void check_cache_state_incomplete(int cache_id, int fd) { - struct cache_device *cache; - int i; + struct cache_device *cache = + get_cache_device_by_id_fd(cache_id, fd, false); - for (i = 0; i < CORE_ADD_MAX_TIMEOUT; i++) { - cache = get_cache_device_by_id_fd(cache_id, fd, false); + if (cache == NULL) + return; - if (cache == NULL) { - return; - } - - if (cache->core_count == cache->expected_core_count) { - if (cache->state & (1 << ocf_cache_state_incomplete)) { - cas_printf(LOG_WARNING, "WARNING: Cache is in incomplete state - at least one core is inactive\n"); - } - free(cache); - cache = NULL; - return; - } - - free(cache); - cache = NULL; - - sleep(1); + if (cache->state & (1 << ocf_cache_state_incomplete)) { + cas_printf(LOG_WARNING, "WARNING: Cache is in incomplete state - " + "at least one core is inactive\n"); } + + free(cache); } int remove_inactive_core(unsigned int cache_id, unsigned int core_id,