Skip to content

Commit

Permalink
Move querying for atomic device params before cache start
Browse files Browse the repository at this point in the history
This needs to be done in caller application context. As part of asynchronous
management API rework, volume_open callback was moved to kernel worker thread
context. To work around this, atomic parameters are now read before cache
attach/load/probe and provided to bottom volume via volume params.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
  • Loading branch information
Adam Rutkowski committed Apr 2, 2019
1 parent 21abb82 commit 9670adf
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 23 deletions.
9 changes: 6 additions & 3 deletions modules/cas_cache/layer_cache_management.c
Original file line number Diff line number Diff line change
Expand Up @@ -905,10 +905,10 @@ static int cache_mng_initialize_core_objects(ocf_cache_t cache)

int cache_mng_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg,
struct ocf_mngt_cache_device_config *device_cfg,
struct atomic_dev_params *atomic_params,
struct kcas_start_cache *cmd)
{
int init_cache, result;
struct atomic_dev_params atomic_params = { 0 };
struct block_device *bdev;
int part_count;
char holder[] = "CAS START\n";
Expand Down Expand Up @@ -965,12 +965,15 @@ int cache_mng_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg,
return -KCAS_ERR_CONTAINS_PART;

result = cas_blk_identify_type_atomic(device_cfg->uuid.data,
&device_cfg->volume_type, &atomic_params);
&device_cfg->volume_type, atomic_params);
if (result)
return result;

if (device_cfg->volume_type == ATOMIC_DEVICE_VOLUME)
device_cfg->volume_params = atomic_params;

cmd->metadata_mode_optimal =
block_dev_is_metadata_mode_optimal(&atomic_params,
block_dev_is_metadata_mode_optimal(atomic_params,
device_cfg->volume_type);

return 0;
Expand Down
3 changes: 3 additions & 0 deletions modules/cas_cache/layer_cache_management.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#define CAS_BLK_DEV_REQ_TYPE_BIO 1
#define CAS_BLK_DEV_REQ_TYPE_REQ 3

struct atomic_dev_params;

int cache_mng_set_cleaning_policy(ocf_cache_id_t cache_id, uint32_t type);

int cache_mng_get_cleaning_policy(ocf_cache_id_t cache_id, uint32_t *type);
Expand All @@ -32,6 +34,7 @@ int cache_mng_exit_instance(ocf_cache_id_t id, int flush);

int cache_mng_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg,
struct ocf_mngt_cache_device_config *device_cfg,
struct atomic_dev_params *atomic_params,
struct kcas_start_cache *cmd);

int cache_mng_core_pool_get_paths(struct kcas_core_pool_path *cmd_info);
Expand Down
20 changes: 15 additions & 5 deletions modules/cas_cache/layer_upgrade.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,9 @@ static int _cas_upgrade_restore_conf_main(struct cas_properties *cache_props,
uint64_t cache_mode, cache_line_size;
uint64_t cache_type, version;
char *cache_path = NULL;
struct ocf_mngt_cache_config cfg;
struct ocf_mngt_cache_device_config device_cfg;
struct ocf_mngt_cache_config cfg = {};
struct ocf_mngt_cache_device_config device_cfg = {};
struct atomic_dev_params atomic_params = {};

CAS_DEBUG_TRACE();

Expand Down Expand Up @@ -853,9 +854,6 @@ static int _cas_upgrade_restore_conf_main(struct cas_properties *cache_props,
if (cache_mode >= ocf_cache_mode_max)
cache_mode = ocf_cache_mode_default;

memset(&cfg, 0, sizeof(cfg));
memset(&device_cfg, 0, sizeof(device_cfg));

cfg.id = *cache_id;
cfg.cache_mode = cache_mode;
/* cfg.eviction_policy = TODO */
Expand All @@ -876,6 +874,18 @@ static int _cas_upgrade_restore_conf_main(struct cas_properties *cache_props,
device_cfg.perform_test = true;
device_cfg.force = false;

if (device_cfg.volume_type == ATOMIC_DEVICE_VOLUME) {
result = cas_blk_identify_type_atomic(device_cfg.uuid.data,
&device_cfg.volume_type, &atomic_params);
if (result)
goto error;
if (device_cfg.volume_type != ATOMIC_DEVICE_VOLUME) {
result = -OCF_ERR_INVAL_VOLUME_TYPE;
goto error;
}
device_cfg.volume_params = &atomic_params;
}

result = cache_mng_init_instance(&cfg, &device_cfg, NULL);

error:
Expand Down
4 changes: 3 additions & 1 deletion modules/cas_cache/service_ui_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd,
struct kcas_start_cache *cmd_info;
struct ocf_mngt_cache_config cfg;
struct ocf_mngt_cache_device_config device_cfg;
struct atomic_dev_params atomic_params = { 0 };

GET_CMD_INFO(cmd_info, arg);

retval = cache_mng_prepare_cache_cfg(&cfg, &device_cfg, cmd_info);
retval = cache_mng_prepare_cache_cfg(&cfg, &device_cfg,
&atomic_params, cmd_info);
if (retval)
RETURN_CMD_RESULT(cmd_info, arg, retval);

Expand Down
18 changes: 7 additions & 11 deletions modules/cas_cache/volume/vol_atomic_dev_bottom.c
Original file line number Diff line number Diff line change
Expand Up @@ -986,26 +986,22 @@ void cas_atomic_close_object(ocf_volume_t volume)
block_dev_close_object(volume);
}

int cas_atomic_open_object(ocf_volume_t volume)
int cas_atomic_open_object(ocf_volume_t volume, void *volume_params)
{
int result;
uint8_t type;
struct bd_object *bdobj = NULL;

result = block_dev_open_object(volume);
if (!volume_params)
return -EINVAL;

result = block_dev_open_object(volume, volume_params);
if (result)
return result;

bdobj = bd_object(volume);

result = cas_blk_identify_type_by_bdev(bdobj->btm_bd,
&type, &bdobj->atomic_params);

if (type != ATOMIC_DEVICE_VOLUME) {
cas_atomic_close_object(volume);
result = -OCF_ERR_INVAL_VOLUME_TYPE;
goto end;
}
memcpy(&bdobj->atomic_params, volume_params,
sizeof(bdobj->atomic_params));

bdobj->workqueue = create_workqueue("CAS_AT_ZER");
if (!bdobj->workqueue) {
Expand Down
2 changes: 1 addition & 1 deletion modules/cas_cache/volume/vol_blk_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ int cas_blk_open_volume_by_bdev(ocf_volume_t *vol,
bdobj->btm_bd = bdev;
bdobj->opened_by_bdev = true;

ocf_volume_open(*vol);
ocf_volume_open(*vol, &atomic_params);

return 0;

Expand Down
2 changes: 1 addition & 1 deletion modules/cas_cache/volume/vol_block_dev_bottom.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define CAS_DEBUG_PARAM(format, ...)
#endif

int block_dev_open_object(ocf_volume_t vol)
int block_dev_open_object(ocf_volume_t vol, void *volume_params)
{
struct bd_object *bdobj = bd_object(vol);
const struct ocf_volume_uuid *uuid = ocf_volume_get_uuid(vol);
Expand Down
2 changes: 1 addition & 1 deletion modules/cas_cache/volume/vol_block_dev_bottom.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "../cas_cache.h"

int block_dev_open_object(ocf_volume_t vol);
int block_dev_open_object(ocf_volume_t vol, void *volume_params);

void block_dev_close_object(ocf_volume_t vol);

Expand Down

0 comments on commit 9670adf

Please sign in to comment.