Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update needed RAM calculation method #1504

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 32 additions & 14 deletions modules/cas_cache/layer_cache_management.c
Original file line number Diff line number Diff line change
Expand Up @@ -2037,27 +2037,45 @@ static void init_instance_complete(struct _cache_mngt_attach_context *ctx,

}


static void calculate_min_ram_size(ocf_cache_t cache,
struct _cache_mngt_attach_context *ctx)
{
uint64_t volume_size;
int result;

ctx->min_free_ram = 0;

result = cache_mngt_create_cache_device_cfg(&ctx->device_cfg,
ctx->cache_path);
if (result)
goto end;

result = ocf_volume_open(ctx->device_cfg.volume,
ctx->device_cfg.volume_params);
if (result)
goto destroy_config;

volume_size = ocf_volume_get_length(ctx->device_cfg.volume);
ctx->min_free_ram = ocf_mngt_get_ram_needed(cache, volume_size);
ocf_volume_close(ctx->device_cfg.volume);

destroy_config:
cache_mngt_destroy_cache_device_cfg(&ctx->device_cfg);
end:
if (result)
printk(KERN_WARNING "Cannot calculate amount of DRAM needed\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it sound a bit clumsy? 😅 "Failed to calculate the required amount of DRAM"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically it did not fail to calculate it - the calculation itself is trivial and it's guaranteed to succeed. What happened here is that some prerequisites to the calculation were not satisfied, so the calculation was not possible at all. Therefore cannot to emphasise this inability to calculate.

}

static void _cache_mngt_start_complete(ocf_cache_t cache, void *priv, int error)
{
struct _cache_mngt_attach_context *ctx = priv;
int caller_status;
int result;

cache_mngt_destroy_cache_device_cfg(&ctx->device_cfg);

if (error == -OCF_ERR_NO_FREE_RAM) {
result = cache_mngt_create_cache_device_cfg(&ctx->device_cfg,
ctx->cache_path);
if (result) {
printk(KERN_WARNING "Cannot calculate amount of DRAM "
"needed\n");
ctx->min_free_ram = 0;
} else {
ocf_mngt_get_ram_needed(cache, &ctx->device_cfg,
&ctx->min_free_ram);
cache_mngt_destroy_cache_device_cfg(&ctx->device_cfg);
}
}
if (error == -OCF_ERR_NO_FREE_RAM)
calculate_min_ram_size(cache, ctx);

caller_status =_cache_mngt_async_callee_set_result(&ctx->async, error);
if (caller_status == -KCAS_ERR_WAITING_INTERRUPTED) {
Expand Down
Loading