Skip to content

Commit

Permalink
Zero metadata if on-disk version differs from current
Browse files Browse the repository at this point in the history
Kernel adapter now returns is_cache_device=1 and newly added
metadata_compatible=0 in case of metadata detected with
differing version (instead of is_cache_device = 0).

This allows zero-superblock command to recognize old
cache instance and clear it.

casadm --script --check-cache-device still returns 'Is cache'='no'
in this case, as this layer only cares about metadata in current
version to be able to detect dirty datas tatus.

Signed-off-by: Adam Rutkowski <[email protected]>
  • Loading branch information
Adam Rutkowski committed Jan 21, 2021
1 parent 63eb23b commit 68b68db
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion casadm/cas_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2894,7 +2894,7 @@ int check_cache_device(const char *device_path)
fprintf(intermediate_file[1], TAG(TABLE_HEADER) "Is cache,Clean Shutdown,Cache dirty\n");

fprintf(intermediate_file[1], TAG(TABLE_ROW));
if (cmd_info.is_cache_device) {
if (cmd_info.is_cache_device && cmd_info.metadata_compatible) {
fprintf(intermediate_file[1], "yes,%s,%s\n",
cmd_info.clean_shutdown ? "yes" : "no",
cmd_info.cache_dirty ? "yes" : "no");
Expand Down
8 changes: 7 additions & 1 deletion modules/cas_cache/layer_cache_management.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,11 +1012,17 @@ static void cache_mngt_metadata_probe_end(void *priv, int error,

*context->result = error;

if (error == -OCF_ERR_NO_METADATA || error == -OCF_ERR_METADATA_VER) {
if (error == -OCF_ERR_NO_METADATA) {
cmd_info->is_cache_device = false;
cmd_info->metadata_compatible = false;
*context->result = 0;
} else if (error == -OCF_ERR_METADATA_VER) {
cmd_info->is_cache_device = true;
cmd_info->metadata_compatible = false;
*context->result = 0;
} else if (error == 0) {
cmd_info->is_cache_device = true;
cmd_info->metadata_compatible = true;
cmd_info->clean_shutdown = status->clean_shutdown;
cmd_info->cache_dirty = status->cache_dirty;
}
Expand Down
7 changes: 6 additions & 1 deletion modules/include/cas_ioctl_codes.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,12 @@ struct kcas_core_pool_remove {

struct kcas_cache_check_device {
char path_name[MAX_STR_LEN]; /**< path to a device */
bool is_cache_device;
bool is_cache_device; /* OCF metadata detected */

/* following bool flags are defined is_cache_device == 1 */
bool metadata_compatible; /* OCF metadata is in current version */

/* following bool flags are defined iff is_metadata_compatible == 1 */
bool clean_shutdown;
bool cache_dirty;
bool format_atomic;
Expand Down

0 comments on commit 68b68db

Please sign in to comment.