From f9932d8f31d9df7509c08e5c6e963b32a3c7827a Mon Sep 17 00:00:00 2001 From: Slawomir Jankowski Date: Wed, 9 Jun 2021 15:29:06 +0200 Subject: [PATCH 1/2] Set core's rotational field during core addition Check if the backend device added to the cache is an HDD or not during core addition so it would be done once. Update OCF Remove whitespace Signed-off-by: Slawomir Jankowski --- modules/cas_cache/layer_cache_management.c | 17 ++++++++++++++++- ocf | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/cas_cache/layer_cache_management.c b/modules/cas_cache/layer_cache_management.c index 0198486cc..5629048a5 100644 --- a/modules/cas_cache/layer_cache_management.c +++ b/modules/cas_cache/layer_cache_management.c @@ -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; @@ -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) @@ -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; diff --git a/ocf b/ocf index 5b3a9606d..b8569310a 160000 --- a/ocf +++ b/ocf @@ -1 +1 @@ -Subproject commit 5b3a9606d3eab2e1157d2d692d1f4879fbb527ae +Subproject commit b8569310a1cab6b6cce277462b33e1839f18eec1 From 5c44c9258bd183345bd2fb91779b4745e5e8df47 Mon Sep 17 00:00:00 2001 From: Slawomir Jankowski Date: Wed, 9 Jun 2021 15:46:10 +0200 Subject: [PATCH 2/2] Provide empty unused argument for management function Signed-off-by: Slawomir Jankowski --- modules/cas_cache/layer_cache_management.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/cas_cache/layer_cache_management.c b/modules/cas_cache/layer_cache_management.c index 5629048a5..ac28caac0 100644 --- a/modules/cas_cache/layer_cache_management.c +++ b/modules/cas_cache/layer_cache_management.c @@ -2080,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);