Merge pull request #600 from robertbaldyga/kernel-5.8

Add support for kernels up to 5.8
This commit is contained in:
Robert Baldyga 2020-12-22 15:29:25 +01:00 committed by GitHub
commit 4799a2e788
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 460 additions and 114 deletions

View File

@ -0,0 +1,54 @@
#!/bin/bash
#
# Copyright(c) 2012-2020 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. $(dirname $3)/conf_framework
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "blk_mq_make_request(NULL, NULL);" "linux/blk-mq.h"
then
echo $cur_name "1" >> $config_file_path
else
echo $cur_name "2" >> $config_file_path
fi
}
apply() {
case "$1" in
"1")
add_function "
static inline void *cas_get_default_mk_request_fn(struct request_queue *q)
{
if (q->make_request_fn)
return q->make_request_fn;
return blk_mq_make_request;
}"
add_function "
static inline void cas_call_default_mk_request_fn(make_request_fn *fn,
struct request_queue *q, struct bio *bio)
{
percpu_ref_get(&q->q_usage_counter);
fn(q, bio);
}" ;;
"2")
add_function "
static inline void *cas_get_default_mk_request_fn(struct request_queue *q)
{
return q->make_request_fn;
}"
add_function "
static inline void cas_call_default_mk_request_fn(make_request_fn *fn,
struct request_queue *q, struct bio *bio)
{
fn(q, bio);
}" ;;
*)
exit 1
esac
}
conf_run $@

View File

@ -9,18 +9,21 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "generic_start_io_acct(NULL, 0, 0, NULL)" "linux/bio.h"
if compile_module $cur_name "bio_start_io_acct(NULL)" "linux/blkdev.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "generic_start_io_acct(0, 0, NULL)" "linux/bio.h"
elif compile_module $cur_name "generic_start_io_acct(NULL, 0, 0, NULL)" "linux/bio.h"
then
echo $cur_name "2" >> $config_file_path
elif compile_module $cur_name "part_round_stats(1, 1)" "linux/genhd.h"
elif compile_module $cur_name "generic_start_io_acct(0, 0, NULL)" "linux/bio.h"
then
echo $cur_name "3" >> $config_file_path
elif compile_module $cur_name "part_round_stats(NULL, 1, 1)" "linux/genhd.h"
elif compile_module $cur_name "part_round_stats(1, 1)" "linux/genhd.h"
then
echo $cur_name "4" >> $config_file_path
elif compile_module $cur_name "part_round_stats(NULL, 1, 1)" "linux/genhd.h"
then
echo $cur_name "5" >> $config_file_path
else
echo $cur_name "X" >> $config_file_path
fi
@ -29,79 +32,111 @@ check() {
apply() {
case "$1" in
"1")
add_function "
static inline void cas_generic_start_io_acct(struct request_queue *q,
int rw, unsigned long sectors, struct hd_struct *part) {
generic_start_io_acct(q, rw, sectors, part);
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
int rw, struct hd_struct *part, unsigned long start_time)
{
generic_end_io_acct(q, rw, part, start_time);
}" ;;
add_function "
static inline unsigned long long cas_generic_start_io_acct(
struct request_queue *q, struct bio *bio,
struct hd_struct *part)
{
return bio_start_io_acct(bio);
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
struct bio *bio, struct hd_struct *part,
unsigned long start_time)
{
bio_end_io_acct(bio, start_time);
}" ;;
"2")
add_function "
static inline void cas_generic_start_io_acct(struct request_queue *q,
int rw, unsigned long sectors, struct hd_struct *part)
{
generic_start_io_acct(rw, sectors, part);
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
int rw, struct hd_struct *part, unsigned long start_time)
{
generic_end_io_acct(rw, part, start_time);
}" ;;
"3")
add_function "
static inline void cas_generic_start_io_acct(struct request_queue *q,
int rw, unsigned long sectors, struct hd_struct *part)
{
int cpu = part_stat_lock();
part_round_stats(cpu, part);
part_stat_inc(cpu, part, ios[rw]);
part_stat_add(cpu, part, sectors[rw], sectors);
part_inc_in_flight(part, rw);
part_stat_unlock();
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
int rw, struct hd_struct *part, unsigned long start_time)
{
unsigned long duration = jiffies - start_time;
int cpu = part_stat_lock();
part_stat_add(cpu, part, ticks[rw], duration);
part_round_stats(cpu, part);
part_dec_in_flight(part, rw);
part_stat_unlock();
}" ;;
"4")
add_function "
static inline void cas_generic_start_io_acct(struct request_queue *q,
int rw, unsigned long sectors, struct hd_struct *part)
{
int cpu = part_stat_lock();
part_round_stats(NULL, cpu, part);
part_stat_inc(cpu, part, ios[rw]);
part_stat_add(cpu, part, sectors[rw], sectors);
part_inc_in_flight(NULL, part, rw);
part_stat_unlock();
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
int rw, struct hd_struct *part, unsigned long start_time)
{
unsigned long duration = jiffies - start_time;
int cpu = part_stat_lock();
part_stat_add(cpu, part, ticks[rw], duration);
part_round_stats(NULL, cpu, part);
part_dec_in_flight(NULL, part, rw);
part_stat_unlock();
}" ;;
*)
add_function "
static inline unsigned long long cas_generic_start_io_acct(
struct request_queue *q, struct bio *bio,
struct hd_struct *part)
{
generic_start_io_acct(q, bio_data_dir(bio), bio_sectors(bio), part);
return jiffies;
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
struct bio *bio, struct hd_struct *part,
unsigned long start_time)
{
generic_end_io_acct(q, bio_data_dir(bio), part, start_time);
}" ;;
"3")
add_function "
static inline unsigned long long cas_generic_start_io_acct(
struct request_queue *q, struct bio *bio,
struct hd_struct *part)
{
generic_start_io_acct(bio_data_dir(bio), bio_sectors(bio), part);
return jiffies;
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
struct bio *bio, struct hd_struct *part,
unsigned long start_time)
{
generic_end_io_acct(bio_data_dir(bio), part, start_time);
}" ;;
"4")
add_function "
static inline unsigned long long cas_generic_start_io_acct(
struct request_queue *q, struct bio *bio,
struct hd_struct *part)
{
int rw = bio_data_dir(bio);
int cpu = part_stat_lock();
part_round_stats(cpu, part);
part_stat_inc(cpu, part, ios[rw]);
part_stat_add(cpu, part, sectors[rw], bio_sectors(bio));
part_inc_in_flight(part, rw);
part_stat_unlock();
return jiffies;
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
struct bio *bio, struct hd_struct *part,
unsigned long start_time)
{
int rw = bio_data_dir(bio);
unsigned long duration = jiffies - start_time;
int cpu = part_stat_lock();
part_stat_add(cpu, part, ticks[rw], duration);
part_round_stats(cpu, part);
part_dec_in_flight(part, rw);
part_stat_unlock();
}" ;;
"5")
add_function "
static inline unsigned long long cas_generic_start_io_acct(
struct request_queue *q, struct bio *bio,
struct hd_struct *part)
{
int rw = bio_data_dir(bio);
int cpu = part_stat_lock();
part_round_stats(NULL, cpu, part);
part_stat_inc(cpu, part, ios[rw]);
part_stat_add(cpu, part, sectors[rw], bio_sectors(bio));
part_inc_in_flight(NULL, part, rw);
part_stat_unlock();
return jiffies;
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
struct bio *bio, struct hd_struct *part,
unsigned long start_time)
{
int rw = bio_data_dir(bio);
unsigned long duration = jiffies - start_time;
int cpu = part_stat_lock();
part_stat_add(cpu, part, ticks[rw], duration);
part_round_stats(NULL, cpu, part);
part_dec_in_flight(NULL, part, rw);
part_stat_unlock();
}" ;;
*)
exit 1
esac
esac
}
conf_run $@

View File

@ -0,0 +1,31 @@
#!/bin/bash
#
# Copyright(c) 2012-2020 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. $(dirname $3)/conf_framework
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "kallsyms_on_each_symbol(NULL, NULL)" "linux/fs.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 "SYMBOL_LOOKUP_SUPPORTED 1" ;;
"2")
;;
*)
exit 1
esac
}
conf_run $@

View File

@ -0,0 +1,41 @@
#!/bin/bash
#
# Copyright(c) 2012-2020 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. $(dirname $3)/conf_framework
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "blk_queue_make_request" "linux/blkdev.h"
then
echo $cur_name "1" >> $config_file_path
else
echo $cur_name "2" >> $config_file_path
fi
}
apply() {
case "$1" in
"1")
add_function "
static inline void cas_blk_queue_make_request(struct request_queue *q,
make_request_fn *mfn)
{
blk_queue_make_request(q, mfn);
}" ;;
"2")
add_function "
static inline void cas_blk_queue_make_request(struct request_queue *q,
make_request_fn *mfn)
{
q->make_request_fn = mfn;
}" ;;
*)
exit 1
esac
}
conf_run $@

View File

@ -0,0 +1,39 @@
#!/bin/bash
#
# Copyright(c) 2012-2020 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. $(dirname $3)/conf_framework
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "bdev_disk_changed(NULL, false);" "linux/genhd.h"
then
echo $cur_name "1" >> $config_file_path
else
echo $cur_name "2" >> $config_file_path
fi
}
apply() {
case "$1" in
"1")
add_function "
static inline void cas_reread_partitions(struct block_device *bdev)
{
bdev_disk_changed(bdev, false);
}" ;;
"2")
add_function "
static inline void cas_reread_partitions(struct block_device *bdev)
{
ioctl_by_bdev(bdev, BLKRRPART, (unsigned long)NULL);
}" ;;
*)
exit 1
esac
}
conf_run $@

View File

@ -0,0 +1,50 @@
#!/bin/bash
#
# Copyright(c) 2012-2020 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. $(dirname $3)/conf_framework
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "vfs_ioctl(NULL, 0, 0);" "linux/fs.h"
then
echo $cur_name "1" >> $config_file_path
else
echo $cur_name "2" >> $config_file_path
fi
}
apply() {
case "$1" in
"1")
add_function "
static inline int cas_vfs_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
return vfs_ioctl(file, cmd, arg);
}" ;;
"2")
add_function "
static inline int cas_vfs_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
int error = -ENOTTY;
if (!file->f_op->unlocked_ioctl)
goto out;
error = file->f_op->unlocked_ioctl(file, cmd, arg);
if (error == -ENOIOCTLCMD)
error = -ENOTTY;
out:
return error;
}" ;;
*)
exit 1
esac
}
conf_run $@

View File

@ -0,0 +1,42 @@
#!/bin/bash
#
# Copyright(c) 2012-2020 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. $(dirname $3)/conf_framework
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "__vmalloc(0, 0);" "linux/vmalloc.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct pgprot x; __vmalloc(0, 0, x);" "linux/vmalloc.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 void *cas_vmalloc(unsigned long size, gfp_t gfp_mask)
{
return __vmalloc(size, gfp_mask);
}" ;;
"2")
add_function "
static inline void *cas_vmalloc(unsigned long size, gfp_t gfp_mask)
{
return __vmalloc(size, gfp_mask, PAGE_KERNEL);
}" ;;
*)
exit 1
esac
}
conf_run $@

View File

@ -1090,11 +1090,7 @@ static struct cas_classifier *_cas_cls_init(void)
INIT_LIST_HEAD(&cls->rules);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
cls->wq = alloc_workqueue("kcas_clsd", WQ_UNBOUND | WQ_FREEZABLE, 1);
#else
cls->wq = create_singlethread_workqueue("kcas_clsd");
#endif
if (!cls->wq) {
kfree(cls);
return ERR_PTR(-ENOMEM);

View File

@ -1824,7 +1824,7 @@ static void init_instance_complete(struct _cache_mngt_attach_context *ctx,
/* If we deal with whole device, reread partitions */
if (bdev->bd_contains == bdev)
ioctl_by_bdev(bdev, BLKRRPART, (unsigned long)NULL);
cas_reread_partitions(bdev);
/* Set other back information */
name = block_dev_get_elevator_name(

View File

@ -51,6 +51,8 @@ bool in_upgrade;
ocf_ctx_t cas_ctx;
struct casdsk_functions_mapper casdisk_functions;
#ifdef SYMBOL_LOOKUP_SUPPORTED
struct exported_symbol {
char *name;
unsigned long addr;
@ -74,6 +76,16 @@ int static cas_find_symbol(void *data, const char *namebuf,
return -EINVAL; \
})
#else
#include "../cas_disk/cas_disk.h"
#include "../cas_disk/exp_obj.h"
#define cas_lookup_symbol(f) ({ \
casdisk_functions.f = (void *)f; \
})
#endif
int static cas_casdisk_lookup_funtions(void)
{
mutex_lock(&module_mutex);

View File

@ -41,7 +41,7 @@ static inline void env_free(const void *ptr)
static inline void *env_vmalloc_flags(size_t size, int flags)
{
return __vmalloc(size, flags | __GFP_HIGHMEM, PAGE_KERNEL);
return cas_vmalloc(size, flags | __GFP_HIGHMEM);
}
static inline void *env_vzalloc_flags(size_t size, int flags)

View File

@ -77,17 +77,18 @@ static env_allocator *cas_mpool_get_allocator(
void *cas_mpool_new_f(struct cas_mpool *mpool, uint32_t count, int flags)
{
unsigned long size;
void *items = NULL;
env_allocator *allocator;
allocator = cas_mpool_get_allocator(mpool, count);
if (allocator)
if (allocator) {
items = env_allocator_new(allocator);
else
items = __vmalloc(mpool->hdr_size + (mpool->item_size * count),
flags | __GFP_ZERO | __GFP_HIGHMEM,
PAGE_KERNEL);
} else {
size = mpool->hdr_size + (mpool->item_size * count);
items = cas_vmalloc(size, flags | __GFP_ZERO | __GFP_HIGHMEM);
}
#ifdef ZERO_OR_NULL_PTR
if (ZERO_OR_NULL_PTR(items))

View File

@ -3,6 +3,8 @@
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#if defined(CAS_NVME_PARTIAL)
#include "cas_cache.h"
#include "utils_nvme.h"
#include "utils_blk.h"
@ -62,3 +64,5 @@ out:
cas_vm_munmap(buffer, sizeof(*ns));
return ret;
}
#endif

View File

@ -57,12 +57,11 @@ static void _blockdev_set_bio_data(struct blk_data *data, struct bio *bio)
#endif
}
static inline void _blockdev_start_io_acct(struct bio *bio)
static inline unsigned long long _blockdev_start_io_acct(struct bio *bio)
{
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
cas_generic_start_io_acct(gd->queue, bio_data_dir(bio),
bio_sectors(bio), &gd->part0);
return cas_generic_start_io_acct(gd->queue, bio, &gd->part0);
}
static inline void _blockdev_end_io_acct(struct bio *bio,
@ -70,8 +69,7 @@ static inline void _blockdev_end_io_acct(struct bio *bio,
{
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
cas_generic_end_io_acct(gd->queue, bio_data_dir(bio),
&gd->part0, start_time);
cas_generic_end_io_acct(gd->queue, bio, &gd->part0, start_time);
}
void block_dev_start_bio_fast(struct ocf_io *io)
@ -79,7 +77,7 @@ void block_dev_start_bio_fast(struct ocf_io *io)
struct blk_data *data = ocf_io_get_data(io);
struct bio *bio = data->master_io_req;
_blockdev_start_io_acct(bio);
data->start_time = _blockdev_start_io_acct(bio);
}
void block_dev_complete_bio_fast(struct ocf_io *io, int error)
@ -761,7 +759,6 @@ static int _blockdev_make_request_fast(struct casdsk_disk *dsk,
_blockdev_set_bio_data(data, bio);
data->master_io_req = bio;
data->start_time = jiffies;
io = ocf_core_new_io(core, cache_priv->io_queues[smp_processor_id()],
CAS_BIO_BISECTOR(bio) << SECTOR_SHIFT,

View File

@ -50,7 +50,6 @@ extern struct casdsk_module *casdsk_module;
#define CASDSK_KERN_INFO KERN_INFO""CASDSK_PREFIX_SHORT
#define CASDSK_KERN_DEBUG KERN_DEBUG""CASDSK_PREFIX_SHORT
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 37)
static inline struct block_device *open_bdev_exclusive(const char *path,
fmode_t mode,
void *holder)
@ -74,7 +73,6 @@ static inline void bd_release_from_disk(struct block_device *bdev,
{
return bd_unlink_disk_holder(bdev, disk);
}
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
#define KRETURN(x) ({ return (x); })

View File

@ -77,7 +77,7 @@ static inline void _casdsk_exp_obj_handle_bio_att(struct casdsk_disk *dsk,
make_request_fn(dsk, q, bio, dsk->private);
if (status == CASDSK_BIO_NOT_HANDLED)
dsk->exp_obj->mk_rq_fn(q, bio);
cas_call_default_mk_request_fn(dsk->exp_obj->mk_rq_fn, q, bio);
}
CAS_DECLARE_BLOCK_CALLBACK(_casdsk_exp_obj_bio_pt_io, struct bio *bio,
@ -217,22 +217,54 @@ static int _casdsk_get_next_part_no(struct block_device *bd)
return part_no;
}
static int _casdsk_del_partitions(struct block_device *bd)
static int _casdsk_del_partitions(struct casdsk_disk *dsk)
{
int result = 0;
int part_no;
struct block_device *bd = casdsk_disk_get_blkdev(dsk);
struct file *bd_file;
unsigned long __user usr_bpart;
unsigned long __user usr_barg;
struct blkpg_partition bpart;
struct blkpg_ioctl_arg barg;
int result = 0;
int part_no;
memset(&bpart, 0, sizeof(struct blkpg_partition));
memset(&barg, 0, sizeof(struct blkpg_ioctl_arg));
barg.data = (void __force __user *) &bpart;
bd_file = filp_open(dsk->path, 0, 0);
if (IS_ERR(bd_file))
return PTR_ERR(bd_file);
usr_bpart = cas_vm_mmap(NULL, 0, sizeof(bpart));
if (IS_ERR((void *)usr_bpart)) {
result = PTR_ERR((void *)usr_bpart);
goto out_map_bpart;
}
usr_barg = cas_vm_mmap(NULL, 0, sizeof(barg));
if (IS_ERR((void *)usr_barg)) {
result = PTR_ERR((void *)usr_barg);
goto out_map_barg;
}
memset(&bpart, 0, sizeof(bpart));
memset(&barg, 0, sizeof(barg));
barg.data = (void __user *)usr_bpart;
barg.op = BLKPG_DEL_PARTITION;
result = copy_to_user((void __user *)usr_barg, &barg, sizeof(barg));
if (result) {
result = -EINVAL;
goto out_copy;
}
while ((part_no = _casdsk_get_next_part_no(bd))) {
bpart.pno = part_no;
result = ioctl_by_bdev(bd, BLKPG, (unsigned long) &barg);
result = copy_to_user((void __user *)usr_bpart, &bpart,
sizeof(bpart));
if (result) {
result = -EINVAL;
break;
}
result = cas_vfs_ioctl(bd_file, BLKPG, usr_barg);
if (result == 0) {
printk(CASDSK_KERN_INFO "Partition %d on %s hidden\n",
part_no, bd->bd_disk->disk_name);
@ -243,6 +275,12 @@ static int _casdsk_del_partitions(struct block_device *bd)
}
}
out_copy:
cas_vm_munmap(usr_barg, sizeof(barg));
out_map_barg:
cas_vm_munmap(usr_bpart, sizeof(bpart));
out_map_bpart:
filp_close(bd_file, NULL);
return result;
}
@ -262,12 +300,12 @@ static int _casdsk_exp_obj_hide_parts(struct casdsk_disk *dsk)
return 0;
if (disk_max_parts(dsk->bd->bd_disk) > 1) {
if (_casdsk_del_partitions(bd)) {
if (_casdsk_del_partitions(dsk)) {
printk(CASDSK_KERN_ERR "Error deleting a partition on thedevice %s\n",
gdsk->disk_name);
/* Try restore previous partitions by rescaning */
ioctl_by_bdev(bd, BLKRRPART, (unsigned long) NULL);
cas_reread_partitions(bd);
return -EINVAL;
}
}
@ -280,7 +318,7 @@ static int _casdsk_exp_obj_hide_parts(struct casdsk_disk *dsk)
gdsk->flags &= ~_casdsk_flags;
gdsk->minors = 1;
/* Rescan partitions */
ioctl_by_bdev(bd, BLKRRPART, (unsigned long) NULL);
cas_reread_partitions(bd);
return 0;
}
@ -325,7 +363,7 @@ static void _casdsk_exp_obj_clear_dev_t(struct casdsk_disk *dsk)
/* Restore previous configuration of bottom disk */
gdsk->minors = dsk->gd_minors;
gdsk->flags |= dsk->gd_flags;
ioctl_by_bdev(bdev, BLKRRPART, (unsigned long) NULL);
cas_reread_partitions(bdev);
}
}
@ -573,8 +611,8 @@ int casdsk_exp_obj_create(struct casdsk_disk *dsk, const char *dev_name,
gd->private_data = dsk;
strlcpy(gd->disk_name, exp_obj->dev_name, sizeof(gd->disk_name));
dsk->exp_obj->mk_rq_fn = queue->make_request_fn;
blk_queue_make_request(queue, _casdsk_exp_obj_make_rq_fn);
dsk->exp_obj->mk_rq_fn = cas_get_default_mk_request_fn(queue);
cas_blk_queue_make_request(queue, _casdsk_exp_obj_make_rq_fn);
if (exp_obj->ops->set_geometry) {
result = exp_obj->ops->set_geometry(dsk, dsk->private);

View File

@ -32,28 +32,28 @@ NVME_FULL = 0
SLES ?= $(shell cat /etc/SuSE-release 2>/dev/null)
ifneq ($(SLES),)
EXTRA_CFLAGS += -DCAS_UAPI_LINUX_NVME_IOCTL
EXTRA_CFLAGS += -DCAS_NVME_PARTIAL
EXTRA_CFLAGS += -DCAS_SLES
SLES_VERSION := $(shell cat /etc/os-release |\
sed -n 's/VERSION="\([0-9]\+\)-\(.\+\)"/\1\2/p')
EXTRA_CFLAGS += -DCAS_SLES$(SLES_VERSION)
INCDIR = ""
NVME_PARTIAL = 1
endif
ifeq ($(call check_header,$(INCDIR)/uapi/nvme.h), 1)
EXTRA_CFLAGS += -DCAS_UAPI_NVME_IOCTL
EXTRA_CFLAGS += -DCAS_UAPI_NVME
EXTRA_CFLAGS += -DCAS_NVME_PARTIAL
NVME_PARTIAL = 1
endif
ifeq ($(call check_header,$(INCDIR)/uapi/linux/nvme.h), 1)
EXTRA_CFLAGS += -DCAS_UAPI_LINUX_NVME
EXTRA_CFLAGS += -DCAS_NVME_PARTIAL
NVME_PARTIAL = 1
endif
ifeq ($(call check_header,$(INCDIR)/uapi/linux/nvme_ioctl.h), 1)
EXTRA_CFLAGS += -DCAS_UAPI_LINUX_NVME_IOCTL
EXTRA_CFLAGS += -DCAS_NVME_PARTIAL
NVME_PARTIAL = 1
ifeq ($(shell cat /etc/redhat-release 2>/dev/null | grep "\(Red Hat\|CentOS\) [a-zA-Z ]* 7\.[45]" | wc -l), 1)
NVME_FULL = 1
endif
@ -62,10 +62,18 @@ endif
KERNEL_VERSION = $(shell echo $(KERNELRELEASE) | cut -d'.' -f1)
KERNEL_MAJOR = $(shell echo $(KERNELRELEASE) | cut -d'.' -f2)
ifeq ($(shell expr $(KERNEL_VERSION) \>= 4 \& $(KERNEL_MAJOR) \> 11),1)
ifeq ($(shell expr $(KERNEL_VERSION) \> 4 \| $(KERNEL_VERSION) \== 4 \& $(KERNEL_MAJOR) \> 11),1)
NVME_FULL = 0
endif
ifeq ($(shell expr $(KERNEL_VERSION) \> 5 \| $(KERNEL_VERSION) \== 5 \& $(KERNEL_MAJOR) \> 7),1)
NVME_PARTIAL = 0
endif
ifeq ($(NVME_PARTIAL),1)
EXTRA_CFLAGS += -DCAS_NVME_PARTIAL
endif
ifeq ($(NVME_FULL),1)
EXTRA_CFLAGS += -DCAS_NVME_FULL
endif