diff --git a/casadm/cas_lib.c b/casadm/cas_lib.c index 33123c4..8f93077 100644 --- a/casadm/cas_lib.c +++ b/casadm/cas_lib.c @@ -956,17 +956,6 @@ int check_cache_already_added(const char *cache_device) { return SUCCESS; } -static void check_cache_scheduler(const char *cache_device, const char *elv_name) -{ - if (strnlen_s(elv_name, MAX_ELEVATOR_NAME) == 3 && - !strncmp(elv_name, "cfq", 3)) { - cas_printf(LOG_INFO, - "I/O scheduler for cache device %s is %s. This could cause performance drop.\n" - "Consider switching I/O scheduler to deadline or noop.\n", - cache_device, elv_name); - } -} - int start_cache(uint16_t cache_id, unsigned int cache_init, const char *cache_device, ocf_cache_mode_t cache_mode, ocf_cache_line_size_t line_size, int force) @@ -1032,8 +1021,6 @@ int start_cache(uint16_t cache_id, unsigned int cache_init, } } - check_cache_scheduler(cache_device, cmd.cache_elevator); - check_cache_state_incomplete(cache_id, fd); close(fd); diff --git a/configure.d/1_add_disk.conf b/configure.d/1_add_disk.conf new file mode 100644 index 0000000..3df0c54 --- /dev/null +++ b/configure.d/1_add_disk.conf @@ -0,0 +1,45 @@ +#!/bin/bash +# +# Copyright(c) 2012-2022 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause +# + +. $(dirname $3)/conf_framework.sh + +check() { + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "int t=add_disk(NULL);" "linux/blkdev.h" || + compile_module $cur_name "int t=add_disk(NULL);" "linux/genhd.h" + then + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "add_disk(NULL);" "linux/genhd.h" + then + echo $cur_name "2" >> $config_file_path + else + echo $cur_name "X" >> $config_file_path + fi +} + +apply() { + case "$1" in + "1") + add_function " + static inline int cas_add_disk(struct gendisk *gd) + { + return add_disk(gd); + }" ;; + + "2") + add_function " + static inline int cas_add_disk(struct gendisk *gd) + { + add_disk(gd); + return 0; + }" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_bd_first_part.conf b/configure.d/1_bd_first_part.conf index b29ebbb..4217889 100644 --- a/configure.d/1_bd_first_part.conf +++ b/configure.d/1_bd_first_part.conf @@ -9,7 +9,8 @@ check() { cur_name=$(basename $2) config_file_path=$1 - if compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl;" "linux/genhd.h" + if compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl;" "linux/genhd.h" || + compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl;" "linux/blkdev.h" then echo $cur_name "1" >> $config_file_path elif compile_module $cur_name "struct block_device bd; bd = *disk_part_iter_next(NULL);" "linux/blk_types.h" diff --git a/configure.d/1_bd_part_count.conf b/configure.d/1_bd_part_count.conf index d2f15e0..a65ad75 100644 --- a/configure.d/1_bd_part_count.conf +++ b/configure.d/1_bd_part_count.conf @@ -9,7 +9,8 @@ check() { cur_name=$(basename $2) config_file_path=$1 - if compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl;" "linux/genhd.h" + if compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl;" "linux/blkdev.h" || + compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl;" "linux/genhd.h" then echo $cur_name "1" >> $config_file_path elif compile_module $cur_name "struct gendisk *disk = NULL; struct disk_part_tbl *ptbl; ptbl = disk->part_tbl;" "linux/genhd.h" diff --git a/configure.d/1_bdev_nr_sectors.conf b/configure.d/1_bdev_nr_sectors.conf index 40cd4af..6c06826 100644 --- a/configure.d/1_bdev_nr_sectors.conf +++ b/configure.d/1_bdev_nr_sectors.conf @@ -10,7 +10,8 @@ check() { cur_name=$(basename $2) config_file_path=$1 - if compile_module $cur_name "bdev_nr_sectors(NULL);" "linux/genhd.h" + + if compile_module $cur_name "bdev_nr_sectors(NULL);" "linux/blkdev.h" || compile_module $cur_name "bdev_nr_sectors(NULL);" "linux/genhd.h" then echo $cur_name 1 >> $config_file_path elif compile_module $cur_name "struct block_device *bd; bd->bd_part->nr_sects;" "linux/blk_types.h" "linux/genhd.h" diff --git a/configure.d/1_bdev_whole.conf b/configure.d/1_bdev_whole.conf index 1d7bb0c..59bf3cb 100644 --- a/configure.d/1_bdev_whole.conf +++ b/configure.d/1_bdev_whole.conf @@ -9,8 +9,9 @@ check() { cur_name=$(basename $2) - config_file_path=$1 - if compile_module $cur_name "struct block_device *bd; bdev_whole(bd);" "linux/blk_types.h" "linux/genhd.h" + config_file_path=$1 + if compile_module $cur_name "struct block_device *bd; bdev_whole(bd);" "linux/blk_types.h" "linux/genhd.h" || + compile_module $cur_name "struct block_device *bd; bdev_whole(bd);" "linux/blk_types.h" "linux/blkdev.h" then echo $cur_name 1 >> $config_file_path elif compile_module $cur_name "struct block_device *bd; bd->bd_contains;" "linux/blk_types.h" "linux/fs.h" diff --git a/configure.d/1_bio_alloc.conf b/configure.d/1_bio_alloc.conf new file mode 100644 index 0000000..1ff0a19 --- /dev/null +++ b/configure.d/1_bio_alloc.conf @@ -0,0 +1,43 @@ +#!/bin/bash +# +# Copyright(c) 2012-2022 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause +# + +. $(dirname $3)/conf_framework.sh + +check() { + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "void *t=bio_alloc(0,0);" "linux/bio.h" + then + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "void *t=bio_alloc(NULL,0,0,0);" "linux/bio.h" + then + echo $cur_name "2" >> $config_file_path + else + echo $cur_name "X" >> $config_file_path + fi +} + +apply() { + case "$1" in + "1") + add_function "static inline struct bio *cas_bio_alloc(struct block_device *bdev, gfp_t gfp_mask, unsigned short num_vecs) + { + (void)bdev; + return bio_alloc(gfp_mask, num_vecs); + }" ;; + "2") + add_function "static inline struct bio *cas_bio_alloc(struct block_device *bdev, gfp_t gfp_mask, unsigned short num_vecs) + { + BUG_ON(!bdev); + return bio_alloc(bdev, num_vecs, 0, gfp_mask); + }" ;; + + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_bio_clone.conf b/configure.d/1_bio_clone.conf deleted file mode 100644 index 8d5085e..0000000 --- a/configure.d/1_bio_clone.conf +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# -# Copyright(c) 2012-2022 Intel Corporation -# SPDX-License-Identifier: BSD-3-Clause -# - -. $(dirname $3)/conf_framework.sh - -check() { - cur_name=$(basename $2) - config_file_path=$1 - if compile_module $cur_name "bio_clone(NULL, 0);" "linux/bio.h" - then - echo $cur_name "1" >> $config_file_path - elif compile_module $cur_name "bio_clone_kmalloc(NULL, 0);" "linux/bio.h" - then - echo $cur_name "2" >> $config_file_path - elif compile_module $cur_name "bio_clone_fast(NULL, 0, NULL);" "linux/bio.h" - then - echo $cur_name "3" >> $config_file_path - else - echo $cur_name "X" >> $config_file_path - fi -} - -apply() { - case "$1" in - "1") - add_function "static inline struct bio *cas_bio_clone(struct bio *bio, gfp_t gfp_mask) - { - return bio_clone(bio, gfp_mask); - }" ;; - "2") - add_function "static inline struct bio *cas_bio_clone(struct bio *bio, gfp_t gfp_mask) - { - return bio_clone_kmalloc(bio, gfp_mask); - }" ;; - "3") - add_function "static inline struct bio *cas_bio_clone(struct bio *bio, gfp_t gfp_mask) - { - return bio_clone_fast(bio, gfp_mask, NULL); - }" ;; - *) - exit 1 - esac -} - -conf_run $@ diff --git a/configure.d/1_cas_blkdev_default_rq.conf b/configure.d/1_cas_blkdev_default_rq.conf new file mode 100644 index 0000000..6afbaee --- /dev/null +++ b/configure.d/1_cas_blkdev_default_rq.conf @@ -0,0 +1,35 @@ +#!/bin/bash +# +# Copyright(c) 2012-2022 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause +# + +. $(dirname $3)/conf_framework.sh + + +check() { + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "int x = BLKDEV_DEFAULT_RQ;" "linux/blk-mq.h" + then + echo $cur_name 1 >> $config_file_path + elif compile_module $cur_name "int x = BLKDEV_MAX_RQ;" "linux/blkdev.h" + then + echo $cur_name 2 >> $config_file_path + else + echo $cur_name X >> $config_file_path + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_BLKDEV_DEFAULT_RQ (BLKDEV_DEFAULT_RQ)" ;; + "2") + add_define "CAS_BLKDEV_DEFAULT_RQ (BLKDEV_MAX_RQ)" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_cas_flags.conf b/configure.d/1_cas_flags.conf new file mode 100644 index 0000000..a5f8e42 --- /dev/null +++ b/configure.d/1_cas_flags.conf @@ -0,0 +1,40 @@ +#!/bin/bash +# +# Copyright(c) 2012-2022 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause +# + +. $(dirname $3)/conf_framework.sh + + +check() { + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "int x = GENHD_FL_NO_PART_SCAN | GENHD_FL_EXT_DEVT;" "linux/genhd.h" + then + echo $cur_name 1 >> $config_file_path + elif compile_module $cur_name "int x = GENHD_FL_EXT_DEVT;" "linux/genhd.h" + then + echo $cur_name 2 >> $config_file_path + elif compile_module $cur_name "int x = GENHD_FL_NO_PART;" "linux/blkdev.h" + then + echo $cur_name 3 >> $config_file_path + else + echo $cur_name X >> $config_file_path + fi +} + +apply() { + case "$1" in + "1") + add_define "_CAS_GENHD_FLAGS (GENHD_FL_NO_PART_SCAN | GENHD_FL_EXT_DEVT)" ;; + "2") + add_define "_CAS_GENHD_FLAGS (GENHD_FL_EXT_DEVT)" ;; + "3") + add_define "_CAS_GENHD_FLAGS (GENHD_FL_NO_PART)" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_complete_and_exit.conf b/configure.d/1_complete_and_exit.conf new file mode 100644 index 0000000..79bb57c --- /dev/null +++ b/configure.d/1_complete_and_exit.conf @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Copyright(c) 2012-2022 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause +# + +. $(dirname $3)/conf_framework.sh + + +check() { + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "kthread_complete_and_exit(NULL, 0);" "linux/kthread.h" + then + echo $cur_name 1 >> $config_file_path + else + echo $cur_name 2 >> $config_file_path + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_COMPLETE_AND_EXIT(compl, code) kthread_complete_and_exit(compl, code)" ;; + "2") + add_define "CAS_COMPLETE_AND_EXIT(compl, code) complete_and_exit(compl, code)" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_get_disk_max_part.conf b/configure.d/1_get_disk_max_part.conf new file mode 100644 index 0000000..2e29ef2 --- /dev/null +++ b/configure.d/1_get_disk_max_part.conf @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Copyright(c) 2012-2022 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause +# + +. $(dirname $3)/conf_framework.sh + +check() { + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "disk_max_parts(NULL);" "linux/genhd.h" + then + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "int i = DISK_MAX_PARTS;" "linux/blkdev.h" + then + echo $cur_name "2" >> $config_file_path + else + echo $cur_name "X" >> $config_file_path + fi +} + +apply() { + case "$1" in + "1") + add_define "GET_DISK_MAX_PARTS(x) disk_max_parts(x)" + ;; + "2") + add_define "GET_DISK_MAX_PARTS(x) DISK_MAX_PARTS" + ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_module_put_and_exit.conf b/configure.d/1_module_put_and_exit.conf new file mode 100644 index 0000000..242a2a0 --- /dev/null +++ b/configure.d/1_module_put_and_exit.conf @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Copyright(c) 2012-2022 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause +# + +. $(dirname $3)/conf_framework.sh + + +check() { + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "module_put_and_kthread_exit(0);" "linux/module.h" + then + echo $cur_name 1 >> $config_file_path + else + echo $cur_name 2 >> $config_file_path + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_MODULE_PUT_AND_EXIT(code) module_put_and_kthread_exit(code)" ;; + "2") + add_define "CAS_MODULE_PUT_AND_EXIT(code) module_put_and_exit(code)" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_queue_limits.conf b/configure.d/1_queue_limits.conf index 0eb6572..34beead 100644 --- a/configure.d/1_queue_limits.conf +++ b/configure.d/1_queue_limits.conf @@ -15,10 +15,15 @@ check() { echo $cur_name "1" >> $config_file_path elif compile_module $cur_name "struct queue_limits q; q.max_write_zeroes_sectors;" "linux/blkdev.h" then - echo $cur_name "2" >> $config_file_path + if compile_module $cur_name "struct queue_limits q; q.max_write_same_sectors;" "linux/blkdev.h" + then + echo $cur_name "2" >> $config_file_path + else + echo $cur_name "3" >> $config_file_path + fi elif compile_module $cur_name "struct queue_limits q; q.max_write_same_sectors;" "linux/blkdev.h" then - echo $cur_name "3" >> $config_file_path + echo $cur_name "4" >> $config_file_path else echo $cur_name "X" >> $config_file_path fi @@ -55,7 +60,18 @@ apply() { exp_q->limits.max_write_same_sectors = 0; exp_q->limits.max_write_zeroes_sectors = 0; }" ;; - "3") + "3") + add_function " + static inline void cas_copy_queue_limits(struct request_queue *exp_q, + struct request_queue *cache_q, struct request_queue *core_q) + { + exp_q->limits = cache_q->limits; + exp_q->limits.max_sectors = core_q->limits.max_sectors; + exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors; + exp_q->limits.max_segments = core_q->limits.max_segments; + exp_q->limits.max_write_zeroes_sectors = 0; + }" ;; + "4") add_function " static inline void cas_copy_queue_limits(struct request_queue *exp_q, struct request_queue *cache_q, struct request_queue *core_q) @@ -66,6 +82,8 @@ apply() { exp_q->limits.max_segments = core_q->limits.max_segments; exp_q->limits.max_write_same_sectors = 0; }" ;; + + *) exit 1 esac diff --git a/configure.d/1_reread_partitions.conf b/configure.d/1_reread_partitions.conf index a4b645a..9ff4d51 100644 --- a/configure.d/1_reread_partitions.conf +++ b/configure.d/1_reread_partitions.conf @@ -12,7 +12,8 @@ check() { if compile_module $cur_name "bdev_disk_changed((struct block_device *)NULL, false);" "linux/genhd.h" then echo $cur_name "1" >> $config_file_path - elif compile_module $cur_name "bdev_disk_changed((struct gendisk *)NULL, false);" "linux/genhd.h" + elif compile_module $cur_name "bdev_disk_changed((struct gendisk *)NULL, false);" "linux/genhd.h" || + compile_module $cur_name "bdev_disk_changed((struct gendisk *)NULL, false);" "linux/blkdev.h" then echo $cur_name "2" >> $config_file_path else diff --git a/configure.d/1_submit_bio.conf b/configure.d/1_submit_bio.conf index 5437330..3e3ae0c 100644 --- a/configure.d/1_submit_bio.conf +++ b/configure.d/1_submit_bio.conf @@ -6,26 +6,16 @@ . $(dirname $3)/conf_framework.sh -# submit_bio() can be defined in "bio.h" or in "fs.h" -# If it is defind in fs.h, three possibilities are available: -# * it takes one argument and retuns non-void -# * it takes two arguments and returns non-void -# * it takse two arguments and is void-type check() { cur_name=$(basename $2) config_file_path=$1 - if compile_module $cur_name "submit_bio(NULL);" "linux/bio.h" + if compile_module $cur_name "submit_bio(NULL);" "linux/bio.h" || + compile_module $cur_name "submit_bio(NULL);" "linux/fs.h" then - echo $cur_name "1" >> $config_file_path - elif compile_module $cur_name "submit_bio(NULL);" "linux/fs.h" - then - echo $cur_name "2" >> $config_file_path - elif compile_module $cur_name "void *t=submit_bio(0, NULL);" "linux/fs.h" - then - echo $cur_name "4" >> $config_file_path + echo $cur_name "1" >> $config_file_path elif compile_module $cur_name "submit_bio(0, NULL);" "linux/fs.h" then - echo $cur_name "4" >> $config_file_path + echo $cur_name "2" >> $config_file_path else echo $cur_name "X" >> $config_file_path fi @@ -35,26 +25,14 @@ apply() { case "$1" in "1") add_function " - static inline blk_qc_t cas_submit_bio(int rw, struct bio *bio) + static inline void cas_submit_bio(int rw, struct bio *bio) { CAS_BIO_OP_FLAGS(bio) |= rw; - return submit_bio(bio); + submit_bio(bio); }" ;; + "2") add_function " - static inline blk_qc_t cas_submit_bio(int rw, struct bio *bio) - { - CAS_BIO_OP_FLAGS(bio) |= rw; - return submit_bio(bio); - }" ;; - "3") - add_function " - static inline blk_qc_t cas_submit_bio(int rw, struct bio *bio) - { - return submit_bio(rw, bio); - }" ;; - "4") - add_function " static inline void cas_submit_bio(int rw, struct bio *bio) { submit_bio(rw, bio); diff --git a/configure.d/Makefile b/configure.d/Makefile index fdd8005..b0afc0f 100644 --- a/configure.d/Makefile +++ b/configure.d/Makefile @@ -1,9 +1,9 @@ -#!/bin/bash # -# Copyright(c) 2012-2021 Intel Corporation +# Copyright(c) 2012-2022 Intel Corporation # SPDX-License-Identifier: BSD-3-Clause # + obj-m += test_mod.o MAKE_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) @@ -13,9 +13,9 @@ check_cflag=$(shell echo "" | \ if [ $$? -eq 0 ]; then echo 1; else echo 0; fi; ) ifeq ($(call check_cflag,-Werror=int-conversion), 1) -EXTRA_CFLAGS += -Werror=int-conversion +EXTRA_CFLAGS += -Werror=int-conversion endif - +KBUILD_CFLAGS += -Wno-error all: make -C $(KERNEL_DIR) M=$(MAKE_DIR) modules clean: diff --git a/modules/cas_cache/exp_obj.c b/modules/cas_cache/exp_obj.c index eff582b..c259430 100644 --- a/modules/cas_cache/exp_obj.c +++ b/modules/cas_cache/exp_obj.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include "disk.h" @@ -31,7 +30,10 @@ static inline void bd_release_from_disk(struct block_device *bdev, return bd_unlink_disk_holder(bdev, disk); } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0) + #define KRETURN(x) return + #define MAKE_RQ_RET_TYPE void +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) #define KRETURN(x) ({ return (x); }) #define MAKE_RQ_RET_TYPE blk_qc_t #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) @@ -161,12 +163,6 @@ out_map_bpart: return result; } -#ifdef GENHD_FL_NO_PART_SCAN -static int _cas_flags = GENHD_FL_NO_PART_SCAN | GENHD_FL_EXT_DEVT; -#else -static int _cas_flags = GENHD_FL_EXT_DEVT; -#endif - static int _cas_exp_obj_hide_parts(struct cas_disk *dsk) { struct cas_exp_obj *exp_obj = dsk->exp_obj; @@ -177,7 +173,7 @@ static int _cas_exp_obj_hide_parts(struct cas_disk *dsk) /* It is partition, no more job required */ return 0; - if (disk_max_parts(dsk->bd->bd_disk) > 1) { + if (GET_DISK_MAX_PARTS(dsk->bd->bd_disk) > 1) { if (_cas_del_partitions(dsk)) { printk(KERN_ERR "Error deleting a partition on thedevice %s\n", gdsk->disk_name); @@ -189,11 +185,11 @@ static int _cas_exp_obj_hide_parts(struct cas_disk *dsk) } /* Save original flags and minors */ - exp_obj->gd_flags = gdsk->flags & _cas_flags; + exp_obj->gd_flags = gdsk->flags & _CAS_GENHD_FLAGS; exp_obj->gd_minors = gdsk->minors; /* Setup disk of bottom device as not partitioned device */ - gdsk->flags &= ~_cas_flags; + gdsk->flags &= ~_CAS_GENHD_FLAGS; gdsk->minors = 1; /* Rescan partitions */ cas_reread_partitions(bd); @@ -217,7 +213,7 @@ static int _cas_exp_obj_set_dev_t(struct cas_disk *dsk, struct gendisk *gd) { struct cas_exp_obj *exp_obj = dsk->exp_obj; int flags; - int minors = disk_max_parts(cas_disk_get_gendisk(dsk)); + int minors = GET_DISK_MAX_PARTS(cas_disk_get_gendisk(dsk)); struct block_device *bdev; bdev = cas_disk_get_blkdev(dsk); @@ -346,7 +342,7 @@ static void _cas_init_queues(struct cas_disk *dsk) { struct request_queue *q = dsk->exp_obj->queue; struct blk_mq_hw_ctx *hctx; - int i; + unsigned long i; queue_for_each_hw_ctx(q, hctx, i) { if (!hctx->nr_ctx || !hctx->tags) @@ -365,7 +361,7 @@ static int _cas_init_tag_set(struct cas_disk *dsk, struct blk_mq_tag_set *set) set->nr_hw_queues = num_online_cpus(); set->numa_node = NUMA_NO_NODE; /*TODO: Should we inherit qd from core device? */ - set->queue_depth = BLKDEV_MAX_RQ; + set->queue_depth = CAS_BLKDEV_DEFAULT_RQ; set->cmd_size = 0; set->flags = BLK_MQ_F_SHOULD_MERGE | CAS_BLK_MQ_F_STACKING | CAS_BLK_MQ_F_BLOCKING; @@ -490,7 +486,8 @@ int cas_exp_obj_create(struct cas_disk *dsk, const char *dev_name, goto error_set_geometry; } - add_disk(gd); + if (cas_add_disk(gd)) + goto error_add_disk; result = bd_claim_by_disk(dsk->bd, dsk, gd); if (result) @@ -500,6 +497,7 @@ int cas_exp_obj_create(struct cas_disk *dsk, const char *dev_name, error_bd_claim: del_gendisk(dsk->exp_obj->gd); +error_add_disk: error_set_geometry: exp_obj->private = NULL; _cas_exp_obj_clear_dev_t(dsk); diff --git a/modules/cas_cache/layer_cache_management.c b/modules/cas_cache/layer_cache_management.c index 4d8ccc3..d5a80bd 100644 --- a/modules/cas_cache/layer_cache_management.c +++ b/modules/cas_cache/layer_cache_management.c @@ -601,12 +601,11 @@ static int exit_instance_finish(void *data) if (result == -KCAS_ERR_WAITING_INTERRUPTED) kfree(ctx); - module_put_and_exit(0); + CAS_MODULE_PUT_AND_EXIT(0); } struct _cache_mngt_attach_context { struct _cache_mngt_async_context async; - char cache_elevator[MAX_ELEVATOR_NAME]; uint64_t min_free_ram; struct ocf_mngt_cache_device_config device_cfg; char cache_path[MAX_STR_LEN]; @@ -649,7 +648,7 @@ static int cache_start_rollback(void *data) if (result == -KCAS_ERR_WAITING_INTERRUPTED) kfree(ctx); - module_put_and_exit(0); + CAS_MODULE_PUT_AND_EXIT(0); return 0; } @@ -2021,7 +2020,7 @@ static void init_instance_complete(struct _cache_mngt_attach_context *ctx, ocf_volume_t cache_obj; struct bd_object *bd_cache_obj; struct block_device *bdev; - const char *name; + //const char *name; cache_obj = ocf_cache_get_volume(cache); BUG_ON(!cache_obj); @@ -2033,11 +2032,6 @@ static void init_instance_complete(struct _cache_mngt_attach_context *ctx, if (cas_bdev_whole(bdev) == bdev) cas_reread_partitions(bdev); - /* Set other back information */ - name = block_dev_get_elevator_name( - cas_disk_get_queue(bd_cache_obj->dsk)); - if (name) - strlcpy(ctx->cache_elevator, name, MAX_ELEVATOR_NAME); } static void _cache_mngt_start_complete(ocf_cache_t cache, void *priv, int error) @@ -2572,9 +2566,6 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg, if (result) goto err; - strlcpy(cmd->cache_elevator, context->cache_elevator, - MAX_ELEVATOR_NAME); - result = _cache_start_finalize(cache, cmd->init_cache, false); if (result) goto err; diff --git a/modules/cas_cache/linux_kernel_version.h b/modules/cas_cache/linux_kernel_version.h index 6d6dc63..a9682fd 100644 --- a/modules/cas_cache/linux_kernel_version.h +++ b/modules/cas_cache/linux_kernel_version.h @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/modules/cas_cache/threads.c b/modules/cas_cache/threads.c index 12f1635..8b4e210 100644 --- a/modules/cas_cache/threads.c +++ b/modules/cas_cache/threads.c @@ -1,5 +1,5 @@ /* -* Copyright(c) 2012-2021 Intel Corporation +* Copyright(c) 2012-2022 Intel Corporation * SPDX-License-Identifier: BSD-3-Clause */ @@ -51,7 +51,7 @@ static int _cas_io_queue_thread(void *data) /* If we get here, then thread was signalled to terminate. * So, let's complete and exit. */ - complete_and_exit(&info->compl, 0); + CAS_COMPLETE_AND_EXIT(&info->compl, 0); return 0; } @@ -110,7 +110,7 @@ static int _cas_cleaner_thread(void *data) } } while (true); - complete_and_exit(&info->compl, 0); + CAS_COMPLETE_AND_EXIT(&info->compl, 0); return 0; } diff --git a/modules/cas_cache/volume/vol_block_dev_bottom.c b/modules/cas_cache/volume/vol_block_dev_bottom.c index 5ecc07e..de2c560 100644 --- a/modules/cas_cache/volume/vol_block_dev_bottom.c +++ b/modules/cas_cache/volume/vol_block_dev_bottom.c @@ -4,7 +4,6 @@ */ #include - #include "cas_cache.h" #define CAS_DEBUG_IO 0 @@ -82,57 +81,14 @@ uint64_t block_dev_get_byte_length(ocf_volume_t vol) return sector_length << SECTOR_SHIFT; } -#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 3, 0) -static const char *__block_dev_get_elevator_name(struct request_queue *q) -{ - if (q->elevator->elevator_type == NULL) - return NULL; - - if (q->elevator->elevator_type->elevator_name == NULL) - return NULL; - - if (q->elevator->elevator_type->elevator_name[0] == 0) - return NULL; - - return q->elevator->elevator_type->elevator_name; -} -#else -static const char *__block_dev_get_elevator_name(struct request_queue *q) -{ - if (q->elevator->type == NULL) - return NULL; - - if (q->elevator->type->elevator_name == NULL) - return NULL; - - if (q->elevator->type->elevator_name[0] == 0) - return NULL; - - return q->elevator->type->elevator_name; -} -#endif - /* * */ -const char *block_dev_get_elevator_name(struct request_queue *q) -{ - if (!q) - return NULL; - - if (q->elevator == NULL) - return NULL; - - return __block_dev_get_elevator_name(q); -} - -/* - * - */ -static inline struct bio *cas_bd_io_alloc_bio(struct blkio *bdio) +static inline struct bio *cas_bd_io_alloc_bio(struct block_device *bdev, + struct blkio *bdio) { struct bio *bio - = bio_alloc(GFP_NOIO, cas_io_iter_size_left(&bdio->iter)); + = cas_bio_alloc(bdev, GFP_NOIO, cas_io_iter_size_left(&bdio->iter)); if (bio) return bio; @@ -145,7 +101,7 @@ static inline struct bio *cas_bd_io_alloc_bio(struct blkio *bdio) } /* Retry with smaller */ - return bio_alloc(GFP_NOIO, MAX_LINES_PER_IO); + return cas_bio_alloc(bdev, GFP_NOIO, MAX_LINES_PER_IO); } /* @@ -221,7 +177,7 @@ static void block_dev_submit_flush(struct ocf_io *io) goto out; } - bio = bio_alloc(GFP_NOIO, 0); + bio = cas_bio_alloc(bdev, GFP_NOIO, 0); if (bio == NULL) { CAS_PRINT_RL(KERN_ERR "Couldn't allocate memory for BIO\n"); blkio->error = -ENOMEM; @@ -281,7 +237,7 @@ void block_dev_submit_discard(struct ocf_io *io) start = io->addr >> SECTOR_SHIFT; while (sects) { - bio = bio_alloc(GFP_NOIO, 1); + bio = cas_bio_alloc(bd, GFP_NOIO, 1); if (!bio) { CAS_PRINT_RL(CAS_KERN_ERR "Couldn't allocate memory for BIO\n"); blkio->error = -ENOMEM; @@ -390,7 +346,7 @@ static void block_dev_submit_io(struct ocf_io *io) /* Still IO vectors to be sent */ /* Allocate BIO */ - struct bio *bio = cas_bd_io_alloc_bio(bdio); + struct bio *bio = cas_bd_io_alloc_bio(bdobj->btm_bd, bdio); if (!bio) { bdio->error = -ENOMEM; diff --git a/modules/cas_cache/volume/vol_block_dev_bottom.h b/modules/cas_cache/volume/vol_block_dev_bottom.h index 1ef1fc8..e037a14 100644 --- a/modules/cas_cache/volume/vol_block_dev_bottom.h +++ b/modules/cas_cache/volume/vol_block_dev_bottom.h @@ -1,5 +1,5 @@ /* -* Copyright(c) 2012-2021 Intel Corporation +* Copyright(c) 2012-2022 Intel Corporation * SPDX-License-Identifier: BSD-3-Clause */ @@ -12,8 +12,6 @@ int block_dev_open_object(ocf_volume_t vol, void *volume_params); void block_dev_close_object(ocf_volume_t vol); -const char *block_dev_get_elevator_name(struct request_queue *q); - int block_dev_try_get_io_class(struct bio *bio, int *io_class); int block_dev_init(void); diff --git a/modules/include/cas_ioctl_codes.h b/modules/include/cas_ioctl_codes.h index 1a2c6b2..78912aa 100644 --- a/modules/include/cas_ioctl_codes.h +++ b/modules/include/cas_ioctl_codes.h @@ -23,11 +23,6 @@ */ #define MAX_STR_LEN PATH_MAX -/** - * Max size of elevator name (including null terminator) - */ -#define MAX_ELEVATOR_NAME 16 - /** \cond SKIP_IN_DOC */ #define CACHE_LIST_ID_LIMIT 20 @@ -76,8 +71,6 @@ struct kcas_start_cache { uint64_t min_free_ram; /**< Minimum free RAM memory for cache metadata */ - char cache_elevator[MAX_ELEVATOR_NAME]; - int ext_err_code; }; @@ -391,7 +384,7 @@ struct kcas_standby_activate * 18 * KCAS_IOCTL_GET_CAPABILITIES * DEPRECATED * * 19 * KCAS_IOCTL_UPGRADE * DEPRACATED * * 20 * KCAS_IOCTL_NVME_FORMAT * DEPRECATED * - * 21 * KCAS_IOCTL_START_CACHE * OK * + * 21 * KCAS_IOCTL_START_CACHE * DEPRECATED * * 22 * KCAS_IOCTL_INSERT_CORE * OK * * 23 * KCAS_IOCTL_REMOVE_CORE * OK * * 24 * KCAS_IOCTL_CACHE_INFO * OK * @@ -411,6 +404,7 @@ struct kcas_standby_activate * 38 * KCAS_IOCTL_STANDBY_DETACH * OK * * 39 * KCAS_IOCTL_STANDBY_ACTIVATE * OK * * 40 * KCAS_IOCTL_CORE_INFO * OK * + * 41 * KCAS_IOCTL_START_CACHE * OK * ******************************************************************************* */ @@ -450,9 +444,6 @@ struct kcas_standby_activate /** List valid cache ids within Open CAS module */ #define KCAS_IOCTL_LIST_CACHE _IOWR(KCAS_IOCTL_MAGIC, 17, struct kcas_cache_list) -/** Start new cache instance, load cache or recover cache */ -#define KCAS_IOCTL_START_CACHE _IOWR(KCAS_IOCTL_MAGIC, 21, struct kcas_start_cache) - /** Add core object to an running cache instance */ #define KCAS_IOCTL_INSERT_CORE _IOWR(KCAS_IOCTL_MAGIC, 22, struct kcas_insert_core) @@ -509,6 +500,9 @@ struct kcas_standby_activate /** Rretrieve statisting of a given core object */ #define KCAS_IOCTL_CORE_INFO _IOWR(KCAS_IOCTL_MAGIC, 40, struct kcas_core_info) +/** Start new cache instance, load cache or recover cache */ +#define KCAS_IOCTL_START_CACHE _IOWR(KCAS_IOCTL_MAGIC, 41, struct kcas_start_cache) + /** * Extended kernel CAS error codes */