Skip to content

Commit

Permalink
Merge pull request #1468 from robertbaldyga/kernel-6.8
Browse files Browse the repository at this point in the history
Add support for kernel up to 6.8
  • Loading branch information
robertbaldyga authored May 14, 2024
2 parents ad8e68c + b9aa65f commit ba5bdf4
Show file tree
Hide file tree
Showing 24 changed files with 372 additions and 91 deletions.
53 changes: 53 additions & 0 deletions configure.d/1_bdev_open_by_path.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
#
# Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# 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 "blkdev_get_by_path(NULL, 0, NULL);" "linux/blkdev.h"
then
echo $cur_name 1 >> $config_file_path
elif compile_module $cur_name "blkdev_get_by_path(NULL, 0, NULL, NULL);" "linux/blkdev.h"
then
echo $cur_name 2 >> $config_file_path
elif compile_module $cur_name "bdev_open_by_path(NULL, 0, NULL, NULL);" "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_typedef "struct block_device *cas_bdev_handle_t;"
add_define "cas_bdev_open_by_path(path, mode, holder) \\
blkdev_get_by_path(path, mode, holder)"
add_define "cas_bdev_get_from_handle(handle) \\
((struct block_device *)handle)" ;;
"2")
add_typedef "struct block_device *cas_bdev_handle_t;"
add_define "cas_bdev_open_by_path(path, mode, holder) \\
blkdev_get_by_path(path, mode, holder, NULL)"
add_define "cas_bdev_get_from_handle(handle) \\
((struct block_device *)handle)" ;;
"3")
add_typedef "struct bdev_handle *cas_bdev_handle_t;"
add_define "cas_bdev_open_by_path(path, mode, holder) \\
bdev_open_by_path(path, mode, holder, NULL)"
add_define "cas_bdev_get_from_handle(handle) \\
(handle->bdev)" ;;
*)
exit 1
esac
}

conf_run $@
44 changes: 44 additions & 0 deletions configure.d/1_bdev_release.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
#
# Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# 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 "blkdev_put(NULL, FMODE_READ);" "linux/blkdev.h"
then
echo $cur_name 1 >> $config_file_path
elif compile_module $cur_name "blkdev_put(NULL, NULL);" "linux/blkdev.h"
then
echo $cur_name 2 >> $config_file_path
elif compile_module $cur_name "bdev_release(NULL);" "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_bdev_release(handle, mode, holder) \\
blkdev_put((struct block_device *)handle, mode)" ;;
"2")
add_define "cas_bdev_release(handle, mode, holder) \\
blkdev_put((struct block_device *)handle, holder)" ;;
"3")
add_define "cas_bdev_release(handle, mode, holder) \\
bdev_release(handle)" ;;
*)
exit 1
esac
}

conf_run $@
42 changes: 42 additions & 0 deletions configure.d/1_cas_blk_mode.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
#
# Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# 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 = FMODE_EXCL;" "linux/fs.h"
then
echo $cur_name 1 >> $config_file_path
elif compile_module $cur_name "int x = BLK_OPEN_EXCL;" "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_BLK_MODE fmode_t"
add_define "CAS_BLK_MODE_READ FMODE_READ"
add_define "CAS_BLK_MODE_WRITE FMODE_WRITE"
add_define "CAS_BLK_MODE_EXCL FMODE_EXCL" ;;
"2")
add_define "CAS_BLK_MODE blk_mode_t"
add_define "CAS_BLK_MODE_READ BLK_OPEN_READ"
add_define "CAS_BLK_MODE_WRITE BLK_OPEN_WRITE"
add_define "CAS_BLK_MODE_EXCL BLK_OPEN_EXCL" ;;
*)
exit 1
esac
}

conf_run $@
35 changes: 35 additions & 0 deletions configure.d/1_class_create.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
#
# Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# 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 "class_create(NULL, NULL);" "linux/device.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "class_create(NULL);" "linux/device.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_class_create(owner, name) \\
class_create(owner, name)";;
"2")
add_define "cas_class_create(owner, name) \\
class_create(name)";;
esac
}

conf_run $@
48 changes: 48 additions & 0 deletions configure.d/2_bdev_close.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
#
# Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# 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 "struct block_device_operations bdo; bdo.release(NULL, 0);" "linux/blkdev.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct block_device_operations bdo; bdo.release(NULL);" "linux/blkdev.h"
then
echo $cur_name "2" >> $config_file_path
else
echo $cur_name "X" >> $config_file_path
fi
}

apply() {
add_define "CAS_REFER_BDEV_CLOSE_CALLBACK(name) \\
name##_callback_wrapper"
case "$1" in
"1")
add_define "CAS_BDEV_CLOSE(name, DISK) \\
static void name##_callback(DISK); \\
static void name##_callback_wrapper(struct gendisk *gd, \\
CAS_BLK_MODE _mode) \\
{ \\
name##_callback(gd); \\
} \\
static void name##_callback(DISK)";;
"2")
add_define "CAS_BDEV_CLOSE(name, DISK) \\
static void name##_callback(DISK); \\
static void name##_callback_wrapper(struct gendisk *gd) \\
{ \\
name##_callback(gd); \\
} \\
static void name##_callback(DISK)";;
esac
}

conf_run $@
49 changes: 49 additions & 0 deletions configure.d/2_bdev_open.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
#
# Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# 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 "struct block_device_operations *ops; struct block_device *bd; ops->open(bd, 0);" "linux/blkdev.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct block_device_operations *ops; struct gendisk *gd; ops->open(gd, 0);" "linux/blkdev.h"
then
echo $cur_name "2" >> $config_file_path
else
echo $cur_name "X" >> $config_file_path
fi
}

apply() {
add_define "CAS_REFER_BDEV_OPEN_CALLBACK(name) \\
name##_callback_wrapper"
case "$1" in
"1")
add_define "CAS_BDEV_OPEN(name, DISK) \\
static int name##_callback(DISK); \\
static int name##_callback_wrapper(struct block_device *bdev, \\
CAS_BLK_MODE _mode) \\
{ \\
return name##_callback(bdev->bd_disk); \\
} \\
static int name##_callback(DISK)";;
"2")
add_define "CAS_BDEV_OPEN(name, DISK) \\
static int name##_callback(DISK); \\
static int name##_callback_wrapper(struct gendisk *gd, \\
CAS_BLK_MODE _mode) \\
{ \\
return name##_callback(gd->part0->bd_disk); \\
} \\
static int name##_callback(DISK)";;
esac
}

conf_run $@
5 changes: 3 additions & 2 deletions configure.d/2_bio_cmpl.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#
# Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause
#

Expand Down Expand Up @@ -33,14 +34,14 @@ apply() {
add_define "CAS_BIO_ENDIO(BIO, BYTES_DONE, ERROR) \\
bio_endio(BIO, ERROR)"
add_define "CAS_DECLARE_BLOCK_CALLBACK(name, BIO, BYTES_DONE, ERROR) \\
void name##_callback(BIO, ERROR)"
static void name##_callback(BIO, ERROR)"
add_define "CAS_BLOCK_CALLBACK_ERROR(BIO, ERROR) \\
ERROR" ;;
"2")
add_define "CAS_BIO_ENDIO(BIO, BYTES_DONE, ERROR) \\
({ CAS_BIO_OP_STATUS(BIO) = ERROR; bio_endio(BIO); })"
add_define "CAS_DECLARE_BLOCK_CALLBACK(name, BIO, BYTES_DONE, ERROR) \\
void name##_callback(BIO)"
static void name##_callback(BIO)"
add_define "CAS_BLOCK_CALLBACK_ERROR(BIO, ERROR) \\
CAS_BIO_OP_STATUS(BIO)" ;;
esac
Expand Down
5 changes: 5 additions & 0 deletions configure.d/conf_framework.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#
# Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause
#

Expand All @@ -20,6 +21,10 @@ add_function() {
printf "%s\n" $1 >> $DEFINE_FILE
}

add_typedef() {
printf "typedef %s\n" $1 >> $DEFINE_FILE
}

__compile_module(){
INCLUDE=""
if [ $# -gt 1 ]
Expand Down
3 changes: 2 additions & 1 deletion modules/cas_cache/classifier.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright(c) 2019-2021 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause
*/

Expand Down Expand Up @@ -865,7 +866,7 @@ static void cas_set_classifier(ocf_cache_t cache,
cache_priv->classifier = cls;
}

void _cas_cls_rule_destroy(struct cas_classifier *cls,
static void _cas_cls_rule_destroy(struct cas_classifier *cls,
struct cas_cls_rule *r)
{
struct list_head *item, *n;
Expand Down
5 changes: 3 additions & 2 deletions modules/cas_cache/context.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause
*/

Expand Down Expand Up @@ -52,7 +53,7 @@ static void _cas_page_set_cpu(struct page *page, int cpu)
page->private = cpu;
}

void *_cas_alloc_page_rpool(void *allocator_ctx, int cpu)
static void *_cas_alloc_page_rpool(void *allocator_ctx, int cpu)
{
struct page *page;

Expand Down Expand Up @@ -81,7 +82,7 @@ static int _cas_page_get_cpu(struct page *page)
/*
*
*/
ctx_data_t *__cas_ctx_data_alloc(uint32_t pages, bool zalloc)
static ctx_data_t *__cas_ctx_data_alloc(uint32_t pages, bool zalloc)
{
struct blk_data *data;
uint32_t i;
Expand Down
3 changes: 2 additions & 1 deletion modules/cas_cache/control.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <linux/cdev.h>
Expand Down Expand Up @@ -42,7 +43,7 @@ int __init cas_ctrl_device_init(void)
goto error_cdev_add;
}

ctrl->class = class_create(THIS_MODULE, "cas");
ctrl->class = cas_class_create(THIS_MODULE, "cas");
if (IS_ERR(ctrl->class)) {
printk(KERN_ERR "Cannot create control chrdev class.\n");
result = PTR_ERR(ctrl->class);
Expand Down
Loading

0 comments on commit ba5bdf4

Please sign in to comment.