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

Set core's rotational field during core addition #831

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 17 additions & 2 deletions modules/cas_cache/layer_cache_management.c
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ static int cache_mngt_update_core_uuid(ocf_cache_t cache, const char *core_name,
bdvol = bd_object(vol);

/* lookup block device object for device pointed by uuid */
bdev = CAS_LOOKUP_BDEV(uuid->data);
bdev = CAS_LOOKUP_BDEV(uuid->data);
if (IS_ERR(bdev)) {
printk(KERN_ERR "failed to lookup bdev%s\n", (char*)uuid->data);
return -ENODEV;
Expand Down Expand Up @@ -1224,6 +1224,20 @@ static void _cache_mngt_add_core_complete(ocf_cache_t cache,

static void _cache_mngt_remove_core_complete(void *priv, int error);

static void _blockdev_set_rotational_property(ocf_core_t core)
{
struct block_device *bdev;
struct request_queue *q;
char holder[] = "CHECK CORE ROTATIONAL\n";
const ocf_uuid_t core_uuid = (const ocf_uuid_t)ocf_core_get_uuid(core);
const char *core_path = (const char*)core_uuid->data;

bdev = blkdev_get_by_path(core_path, (FMODE_READ), holder);
q = bdev_get_queue(bdev);

ocf_core_set_rotational(core, (uint8_t)(!blk_queue_nonrot(q)));
}

int cache_mngt_add_core_to_cache(const char *cache_name, size_t name_len,
struct ocf_mngt_core_config *cfg,
struct kcas_insert_core *cmd_info)
Expand Down Expand Up @@ -1301,6 +1315,7 @@ int cache_mngt_add_core_to_cache(const char *cache_name, size_t name_len,
ocf_mngt_cache_put(cache);

_cache_mngt_log_core_device_path(core);
_blockdev_set_rotational_property(core);

return 0;

Expand Down Expand Up @@ -2065,7 +2080,7 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
/* Start cache. Returned cache instance will be locked as it was set
* in configuration.
*/
result = ocf_mngt_cache_start(cas_ctx, &cache, cfg);
result = ocf_mngt_cache_start(cas_ctx, &cache, cfg, NULL);
if (result) {
kthread_stop(context->rollback_thread);
kfree(context);
Expand Down