Merge pull request #1468 from robertbaldyga/kernel-6.8
Add support for kernel up to 6.8
This commit is contained in:
commit
ba5bdf4796
53
configure.d/1_bdev_open_by_path.conf
Normal file
53
configure.d/1_bdev_open_by_path.conf
Normal file
@ -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
configure.d/1_bdev_release.conf
Normal file
44
configure.d/1_bdev_release.conf
Normal file
@ -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
configure.d/1_cas_blk_mode.conf
Normal file
42
configure.d/1_cas_blk_mode.conf
Normal file
@ -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
configure.d/1_class_create.conf
Normal file
35
configure.d/1_class_create.conf
Normal file
@ -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
configure.d/2_bdev_close.conf
Normal file
48
configure.d/2_bdev_close.conf
Normal file
@ -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
configure.d/2_bdev_open.conf
Normal file
49
configure.d/2_bdev_open.conf
Normal file
@ -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 $@
|
@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright(c) 2012-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
@ -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
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright(c) 2012-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
@ -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 ]
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright(c) 2019-2021 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
@ -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;
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2022 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
@ -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>
|
||||
@ -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);
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2022 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#include <linux/module.h>
|
||||
@ -11,18 +12,18 @@
|
||||
#include "exp_obj.h"
|
||||
#include "debug.h"
|
||||
|
||||
#define CAS_DISK_OPEN_FMODE (FMODE_READ | FMODE_WRITE)
|
||||
#define CAS_DISK_OPEN_MODE (CAS_BLK_MODE_READ | CAS_BLK_MODE_WRITE)
|
||||
|
||||
static inline struct block_device *open_bdev_exclusive(const char *path,
|
||||
fmode_t mode,
|
||||
void *holder)
|
||||
static inline cas_bdev_handle_t open_bdev_exclusive(const char *path,
|
||||
CAS_BLK_MODE mode, void *holder)
|
||||
{
|
||||
return blkdev_get_by_path(path, mode | FMODE_EXCL, holder);
|
||||
return cas_bdev_open_by_path(path, mode | CAS_BLK_MODE_EXCL, holder);
|
||||
}
|
||||
|
||||
static inline void close_bdev_exclusive(struct block_device *bdev, fmode_t mode)
|
||||
static inline void close_bdev_exclusive(cas_bdev_handle_t handle,
|
||||
CAS_BLK_MODE mode)
|
||||
{
|
||||
blkdev_put(bdev, mode | FMODE_EXCL);
|
||||
cas_bdev_release(handle, mode | CAS_BLK_MODE_EXCL, NULL);
|
||||
}
|
||||
|
||||
int __init cas_init_disks(void)
|
||||
@ -67,10 +68,10 @@ struct cas_disk *cas_disk_open(const char *path)
|
||||
goto error_kstrdup;
|
||||
}
|
||||
|
||||
dsk->bd = open_bdev_exclusive(path, CAS_DISK_OPEN_FMODE, dsk);
|
||||
if (IS_ERR(dsk->bd)) {
|
||||
dsk->bdev_handle = open_bdev_exclusive(path, CAS_DISK_OPEN_MODE, dsk);
|
||||
if (IS_ERR(dsk->bdev_handle)) {
|
||||
CAS_DEBUG_ERROR("Cannot open exclusive");
|
||||
result = PTR_ERR(dsk->bd);
|
||||
result = PTR_ERR(dsk->bdev_handle);
|
||||
goto error_open_bdev;
|
||||
}
|
||||
|
||||
@ -89,11 +90,11 @@ error_kmem:
|
||||
void cas_disk_close(struct cas_disk *dsk)
|
||||
{
|
||||
BUG_ON(!dsk);
|
||||
BUG_ON(!dsk->bd);
|
||||
BUG_ON(!dsk->bdev_handle);
|
||||
|
||||
CAS_DEBUG_DISK(dsk, "Destroying (%p)", dsk);
|
||||
|
||||
close_bdev_exclusive(dsk->bd, CAS_DISK_OPEN_FMODE);
|
||||
close_bdev_exclusive(dsk->bdev_handle, CAS_DISK_OPEN_MODE);
|
||||
|
||||
kfree(dsk->path);
|
||||
kmem_cache_free(cas_module.disk_cache, dsk);
|
||||
@ -102,19 +103,18 @@ void cas_disk_close(struct cas_disk *dsk)
|
||||
struct block_device *cas_disk_get_blkdev(struct cas_disk *dsk)
|
||||
{
|
||||
BUG_ON(!dsk);
|
||||
return dsk->bd;
|
||||
BUG_ON(!dsk->bdev_handle);
|
||||
return cas_bdev_get_from_handle(dsk->bdev_handle);
|
||||
}
|
||||
|
||||
struct gendisk *cas_disk_get_gendisk(struct cas_disk *dsk)
|
||||
{
|
||||
BUG_ON(!dsk);
|
||||
BUG_ON(!dsk->bd);
|
||||
return dsk->bd->bd_disk;
|
||||
return cas_disk_get_blkdev(dsk)->bd_disk;
|
||||
}
|
||||
|
||||
struct request_queue *cas_disk_get_queue(struct cas_disk *dsk)
|
||||
{
|
||||
BUG_ON(!dsk);
|
||||
BUG_ON(!dsk->bd);
|
||||
return cas_bdev_whole(dsk->bd)->bd_disk->queue;
|
||||
struct block_device *bd = cas_disk_get_blkdev(dsk);
|
||||
|
||||
return cas_bdev_whole(bd)->bd_disk->queue;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2022 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef __CASDISK_DISK_H__
|
||||
@ -16,7 +17,7 @@ struct cas_exp_obj;
|
||||
struct cas_disk {
|
||||
char *path;
|
||||
|
||||
struct block_device *bd;
|
||||
cas_bdev_handle_t bdev_handle;
|
||||
|
||||
struct cas_exp_obj *exp_obj;
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2022 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#include <linux/module.h>
|
||||
@ -173,7 +174,7 @@ static int _cas_exp_obj_hide_parts(struct cas_disk *dsk)
|
||||
/* It is partition, no more job required */
|
||||
return 0;
|
||||
|
||||
if (GET_DISK_MAX_PARTS(dsk->bd->bd_disk) > 1) {
|
||||
if (GET_DISK_MAX_PARTS(cas_disk_get_gendisk(dsk)) > 1) {
|
||||
if (_cas_del_partitions(dsk)) {
|
||||
printk(KERN_ERR "Error deleting a partition on thedevice %s\n",
|
||||
gdsk->disk_name);
|
||||
@ -255,9 +256,9 @@ static void _cas_exp_obj_clear_dev_t(struct cas_disk *dsk)
|
||||
}
|
||||
}
|
||||
|
||||
static int _cas_exp_obj_open(struct block_device *bdev, fmode_t mode)
|
||||
CAS_BDEV_OPEN(_cas_exp_obj_open, struct gendisk *gd)
|
||||
{
|
||||
struct cas_disk *dsk = bdev->bd_disk->private_data;
|
||||
struct cas_disk *dsk = gd->private_data;
|
||||
struct cas_exp_obj *exp_obj = dsk->exp_obj;
|
||||
int result = -ENAVAIL;
|
||||
|
||||
@ -276,7 +277,7 @@ static int _cas_exp_obj_open(struct block_device *bdev, fmode_t mode)
|
||||
return result;
|
||||
}
|
||||
|
||||
static void _cas_exp_obj_close(struct gendisk *gd, fmode_t mode)
|
||||
CAS_BDEV_CLOSE(_cas_exp_obj_close, struct gendisk *gd)
|
||||
{
|
||||
struct cas_disk *dsk = gd->private_data;
|
||||
struct cas_exp_obj *exp_obj = dsk->exp_obj;
|
||||
@ -291,8 +292,8 @@ static void _cas_exp_obj_close(struct gendisk *gd, fmode_t mode)
|
||||
|
||||
static const struct block_device_operations _cas_exp_obj_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = _cas_exp_obj_open,
|
||||
.release = _cas_exp_obj_close,
|
||||
.open = CAS_REFER_BDEV_OPEN_CALLBACK(_cas_exp_obj_open),
|
||||
.release = CAS_REFER_BDEV_CLOSE_CALLBACK(_cas_exp_obj_close),
|
||||
CAS_SET_SUBMIT_BIO(_cas_exp_obj_submit_bio)
|
||||
};
|
||||
|
||||
@ -476,7 +477,7 @@ int cas_exp_obj_create(struct cas_disk *dsk, const char *dev_name,
|
||||
|
||||
gd->fops = &_cas_exp_obj_ops;
|
||||
gd->private_data = dsk;
|
||||
strlcpy(gd->disk_name, exp_obj->dev_name, sizeof(gd->disk_name));
|
||||
strscpy(gd->disk_name, exp_obj->dev_name, sizeof(gd->disk_name));
|
||||
|
||||
cas_blk_queue_make_request(queue, _cas_exp_obj_make_rq_fn);
|
||||
|
||||
@ -489,7 +490,7 @@ int cas_exp_obj_create(struct cas_disk *dsk, const char *dev_name,
|
||||
if (cas_add_disk(gd))
|
||||
goto error_add_disk;
|
||||
|
||||
result = bd_claim_by_disk(dsk->bd, dsk, gd);
|
||||
result = bd_claim_by_disk(cas_disk_get_blkdev(dsk), dsk, gd);
|
||||
if (result)
|
||||
goto error_bd_claim;
|
||||
|
||||
@ -530,7 +531,7 @@ int cas_exp_obj_destroy(struct cas_disk *dsk)
|
||||
|
||||
exp_obj = dsk->exp_obj;
|
||||
|
||||
bd_release_from_disk(dsk->bd, exp_obj->gd);
|
||||
bd_release_from_disk(cas_disk_get_blkdev(dsk), exp_obj->gd);
|
||||
_cas_exp_obj_clear_dev_t(dsk);
|
||||
del_gendisk(exp_obj->gd);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2022 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
@ -1051,7 +1052,7 @@ struct get_paths_ctx {
|
||||
int position;
|
||||
};
|
||||
|
||||
int _cache_mngt_core_pool_get_paths_visitor(ocf_uuid_t uuid, void *ctx)
|
||||
static int _cache_mngt_core_pool_get_paths_visitor(ocf_uuid_t uuid, void *ctx)
|
||||
{
|
||||
struct get_paths_ctx *visitor_ctx = ctx;
|
||||
|
||||
@ -1137,18 +1138,20 @@ static void cache_mngt_metadata_probe_end(void *priv, int error,
|
||||
int cache_mngt_cache_check_device(struct kcas_cache_check_device *cmd_info)
|
||||
{
|
||||
struct cache_mngt_metadata_probe_context context;
|
||||
cas_bdev_handle_t bdev_handle;
|
||||
struct block_device *bdev;
|
||||
ocf_volume_t volume;
|
||||
char holder[] = "CAS CHECK CACHE DEVICE\n";
|
||||
int result;
|
||||
|
||||
bdev = blkdev_get_by_path(cmd_info->path_name, (FMODE_EXCL|FMODE_READ),
|
||||
holder);
|
||||
if (IS_ERR(bdev)) {
|
||||
return (PTR_ERR(bdev) == -EBUSY) ?
|
||||
bdev_handle = cas_bdev_open_by_path(cmd_info->path_name,
|
||||
(CAS_BLK_MODE_EXCL | CAS_BLK_MODE_READ), holder);
|
||||
if (IS_ERR(bdev_handle)) {
|
||||
return (PTR_ERR(bdev_handle) == -EBUSY) ?
|
||||
-OCF_ERR_NOT_OPEN_EXC :
|
||||
-OCF_ERR_INVAL_VOLUME_TYPE;
|
||||
}
|
||||
bdev = cas_bdev_get_from_handle(bdev_handle);
|
||||
|
||||
result = cas_blk_open_volume_by_bdev(&volume, bdev);
|
||||
if (result)
|
||||
@ -1164,7 +1167,8 @@ int cache_mngt_cache_check_device(struct kcas_cache_check_device *cmd_info)
|
||||
|
||||
cas_blk_close_volume(volume);
|
||||
out_bdev:
|
||||
blkdev_put(bdev, (FMODE_EXCL|FMODE_READ));
|
||||
cas_bdev_release(bdev_handle,
|
||||
(CAS_BLK_MODE_EXCL | CAS_BLK_MODE_READ), holder);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2121,7 +2125,7 @@ static void cache_mngt_probe_metadata_end(void *priv, int error,
|
||||
goto err;
|
||||
}
|
||||
|
||||
strlcpy(context->cache_name_meta, status->cache_name,
|
||||
strscpy(context->cache_name_meta, status->cache_name,
|
||||
OCF_CACHE_NAME_SIZE);
|
||||
*(context->cache_mode_meta) = status->cache_mode;
|
||||
*(context->cache_line_size_meta) = status->cache_line_size;
|
||||
@ -2134,18 +2138,20 @@ static int _cache_mngt_probe_metadata(char *cache_path_name,
|
||||
ocf_cache_line_size_t *cache_line_size_meta)
|
||||
{
|
||||
struct cache_mngt_probe_metadata_context context;
|
||||
cas_bdev_handle_t bdev_handle;
|
||||
struct block_device *bdev;
|
||||
ocf_volume_t volume;
|
||||
char holder[] = "CAS CHECK METADATA\n";
|
||||
int result;
|
||||
|
||||
bdev = blkdev_get_by_path(cache_path_name, (FMODE_EXCL|FMODE_READ),
|
||||
holder);
|
||||
if (IS_ERR(bdev)) {
|
||||
return (PTR_ERR(bdev) == -EBUSY) ?
|
||||
bdev_handle = cas_bdev_open_by_path(cache_path_name,
|
||||
(CAS_BLK_MODE_EXCL | CAS_BLK_MODE_READ), holder);
|
||||
if (IS_ERR(bdev_handle)) {
|
||||
return (PTR_ERR(bdev_handle) == -EBUSY) ?
|
||||
-OCF_ERR_NOT_OPEN_EXC :
|
||||
-OCF_ERR_INVAL_VOLUME_TYPE;
|
||||
}
|
||||
bdev = cas_bdev_get_from_handle(bdev_handle);
|
||||
|
||||
result = cas_blk_open_volume_by_bdev(&volume, bdev);
|
||||
if (result)
|
||||
@ -2163,7 +2169,8 @@ static int _cache_mngt_probe_metadata(char *cache_path_name,
|
||||
|
||||
cas_blk_close_volume(volume);
|
||||
out_bdev:
|
||||
blkdev_put(bdev, (FMODE_EXCL|FMODE_READ));
|
||||
cas_bdev_release(bdev_handle,
|
||||
(CAS_BLK_MODE_EXCL | CAS_BLK_MODE_READ), holder);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2222,26 +2229,29 @@ static int _cache_start_finalize(ocf_cache_t cache, int init_mode,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cache_mngt_check_bdev(struct ocf_mngt_cache_device_config *device_cfg,
|
||||
static int cache_mngt_check_bdev(struct ocf_mngt_cache_device_config *cfg,
|
||||
bool force)
|
||||
{
|
||||
char holder[] = "CAS START\n";
|
||||
cas_bdev_handle_t bdev_handle;
|
||||
struct block_device *bdev;
|
||||
int part_count;
|
||||
bool is_part;
|
||||
const struct ocf_volume_uuid *uuid = ocf_volume_get_uuid(device_cfg->volume);
|
||||
const struct ocf_volume_uuid *uuid = ocf_volume_get_uuid(cfg->volume);
|
||||
|
||||
bdev = blkdev_get_by_path(uuid->data,
|
||||
(FMODE_EXCL|FMODE_READ), holder);
|
||||
if (IS_ERR(bdev)) {
|
||||
return (PTR_ERR(bdev) == -EBUSY) ?
|
||||
bdev_handle = cas_bdev_open_by_path(uuid->data,
|
||||
(CAS_BLK_MODE_EXCL | CAS_BLK_MODE_READ), holder);
|
||||
if (IS_ERR(bdev_handle)) {
|
||||
return (PTR_ERR(bdev_handle) == -EBUSY) ?
|
||||
-OCF_ERR_NOT_OPEN_EXC :
|
||||
-OCF_ERR_INVAL_VOLUME_TYPE;
|
||||
}
|
||||
bdev = cas_bdev_get_from_handle(bdev_handle);
|
||||
|
||||
is_part = (cas_bdev_whole(bdev) != bdev);
|
||||
part_count = cas_blk_get_part_count(bdev);
|
||||
blkdev_put(bdev, (FMODE_EXCL|FMODE_READ));
|
||||
cas_bdev_release(bdev_handle,
|
||||
(CAS_BLK_MODE_EXCL | CAS_BLK_MODE_READ), holder);
|
||||
|
||||
if (!is_part && part_count > 1 && !force)
|
||||
return -KCAS_ERR_CONTAINS_PART;
|
||||
@ -2486,7 +2496,7 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
|
||||
}
|
||||
|
||||
result = 0;
|
||||
strlcpy(cfg->name, cache_name_meta, OCF_CACHE_NAME_SIZE);
|
||||
strscpy(cfg->name, cache_name_meta, OCF_CACHE_NAME_SIZE);
|
||||
cfg->cache_mode = cache_mode_meta;
|
||||
cfg->cache_line_size = cache_line_size_meta;
|
||||
default:
|
||||
@ -2675,7 +2685,7 @@ out:
|
||||
* nonzero exit code means failure
|
||||
*/
|
||||
|
||||
int cache_mngt_set_seq_cutoff_promotion_count(ocf_cache_t cache,
|
||||
static int cache_mngt_set_seq_cutoff_promotion_count(ocf_cache_t cache,
|
||||
ocf_core_t core, uint32_t count)
|
||||
{
|
||||
int result;
|
||||
@ -2757,7 +2767,7 @@ int cache_mngt_get_seq_cutoff_policy(ocf_core_t core,
|
||||
* nonzero exit code means failure
|
||||
*/
|
||||
|
||||
int cache_mngt_get_seq_cutoff_promotion_count(ocf_core_t core,
|
||||
static int cache_mngt_get_seq_cutoff_promotion_count(ocf_core_t core,
|
||||
uint32_t *count)
|
||||
{
|
||||
ocf_cache_t cache = ocf_core_get_cache(core);
|
||||
@ -3095,7 +3105,7 @@ int cache_mngt_get_info(struct kcas_cache_info *info)
|
||||
if (info->info.attached && !info->info.standby_detached) {
|
||||
uuid = ocf_cache_get_uuid(cache);
|
||||
BUG_ON(!uuid);
|
||||
strlcpy(info->cache_path_name, uuid->data,
|
||||
strscpy(info->cache_path_name, uuid->data,
|
||||
min(sizeof(info->cache_path_name), uuid->size));
|
||||
} else {
|
||||
memset(info->cache_path_name, 0, sizeof(info->cache_path_name));
|
||||
@ -3175,7 +3185,7 @@ int cache_mngt_get_core_info(struct kcas_core_info *info)
|
||||
uuid = ocf_core_get_uuid(core);
|
||||
|
||||
if (uuid->data) {
|
||||
strlcpy(info->core_path_name, uuid->data,
|
||||
strscpy(info->core_path_name, uuid->data,
|
||||
min(sizeof(info->core_path_name), uuid->size));
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2022 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
@ -597,7 +598,7 @@ static inline int env_bit_test(int nr, const void *addr)
|
||||
#define env_strncmp(s1, slen1, s2, slen2) strncmp(s1, s2, \
|
||||
min_t(size_t, slen1, slen2))
|
||||
#define env_strncpy(dest, dmax, src, slen) ({ \
|
||||
strlcpy(dest, src, min_t(int, dmax, slen)); \
|
||||
strscpy(dest, src, min_t(int, dmax, slen)); \
|
||||
0; \
|
||||
})
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2021 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include "cas_cache.h"
|
||||
#include "utils_data.h"
|
||||
|
||||
/**
|
||||
* This function locates index of IO vec from given vecs array where byte at
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2022 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
@ -62,7 +63,7 @@ struct _cas_rpool_pre_alloc_info {
|
||||
(struct list_head *)((unsigned long)entry + rpool->entry_size \
|
||||
- sizeof(struct list_head))
|
||||
|
||||
void _cas_rpool_pre_alloc_do(struct work_struct *ws)
|
||||
static void _cas_rpool_pre_alloc_do(struct work_struct *ws)
|
||||
{
|
||||
struct _cas_rpool_pre_alloc_info *info =
|
||||
container_of(ws, struct _cas_rpool_pre_alloc_info, ws);
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2021 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
@ -256,7 +257,7 @@ void cas_blk_close_volume(ocf_volume_t vol)
|
||||
env_free(vol);
|
||||
}
|
||||
|
||||
int _cas_blk_identify_type(const char *path, uint8_t *type)
|
||||
static int _cas_blk_identify_type(const char *path, uint8_t *type)
|
||||
{
|
||||
struct file *file;
|
||||
int result = 0;
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2022 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
@ -23,7 +24,7 @@
|
||||
#define CAS_DEBUG_PARAM(format, ...)
|
||||
#endif
|
||||
|
||||
int block_dev_open_object(ocf_volume_t vol, void *volume_params)
|
||||
static int block_dev_open_object(ocf_volume_t vol, void *volume_params)
|
||||
{
|
||||
struct bd_object *bdobj = bd_object(vol);
|
||||
const struct ocf_volume_uuid *uuid = ocf_volume_get_uuid(vol);
|
||||
@ -50,7 +51,7 @@ int block_dev_open_object(ocf_volume_t vol, void *volume_params)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void block_dev_close_object(ocf_volume_t vol)
|
||||
static void block_dev_close_object(ocf_volume_t vol)
|
||||
{
|
||||
struct bd_object *bdobj = bd_object(vol);
|
||||
|
||||
@ -60,7 +61,7 @@ void block_dev_close_object(ocf_volume_t vol)
|
||||
cas_disk_close(bdobj->dsk);
|
||||
}
|
||||
|
||||
unsigned int block_dev_get_max_io_size(ocf_volume_t vol)
|
||||
static unsigned int block_dev_get_max_io_size(ocf_volume_t vol)
|
||||
{
|
||||
struct bd_object *bdobj = bd_object(vol);
|
||||
struct block_device *bd = bdobj->btm_bd;
|
||||
@ -68,7 +69,7 @@ unsigned int block_dev_get_max_io_size(ocf_volume_t vol)
|
||||
return queue_max_sectors(bd->bd_disk->queue) << SECTOR_SHIFT;
|
||||
}
|
||||
|
||||
uint64_t block_dev_get_byte_length(ocf_volume_t vol)
|
||||
static uint64_t block_dev_get_byte_length(ocf_volume_t vol)
|
||||
{
|
||||
struct bd_object *bdobj = bd_object(vol);
|
||||
struct block_device *bd = bdobj->btm_bd;
|
||||
@ -197,7 +198,7 @@ out:
|
||||
cas_bd_io_end(io, blkio->error);
|
||||
}
|
||||
|
||||
void block_dev_submit_discard(struct ocf_io *io)
|
||||
static void block_dev_submit_discard(struct ocf_io *io)
|
||||
{
|
||||
struct blkio *blkio = cas_io_to_blkio(io);
|
||||
struct bd_object *bdobj = bd_object(ocf_io_get_volume(io));
|
||||
@ -457,15 +458,3 @@ int block_dev_init(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int block_dev_try_get_io_class(struct bio *bio, int *io_class)
|
||||
{
|
||||
struct ocf_io *io;
|
||||
|
||||
if (bio->bi_end_io != CAS_REFER_BLOCK_CALLBACK(cas_bd_io_end))
|
||||
return -1;
|
||||
|
||||
io = bio->bi_private;
|
||||
*io_class = io->io_class;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,19 +1,12 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2022 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef __VOL_BLOCK_DEV_BOTTOM_H__
|
||||
#define __VOL_BLOCK_DEV_BOTTOM_H__
|
||||
|
||||
#include "../cas_cache.h"
|
||||
|
||||
int block_dev_open_object(ocf_volume_t vol, void *volume_params);
|
||||
|
||||
void block_dev_close_object(ocf_volume_t vol);
|
||||
|
||||
int block_dev_try_get_io_class(struct bio *bio, int *io_class);
|
||||
|
||||
int block_dev_init(void);
|
||||
|
||||
#endif /* __VOL_BLOCK_DEV_BOTTOM_H__ */
|
||||
|
@ -31,7 +31,7 @@ static void blkdev_set_bio_data(struct blk_data *data, struct bio *bio)
|
||||
#endif
|
||||
}
|
||||
|
||||
void blkdev_set_exported_object_flush_fua(ocf_core_t core)
|
||||
static void blkdev_set_exported_object_flush_fua(ocf_core_t core)
|
||||
{
|
||||
ocf_cache_t cache = ocf_core_get_cache(core);
|
||||
ocf_volume_t core_vol = ocf_core_get_volume(core);
|
||||
|
@ -1,11 +1,13 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2022 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef __VOL_BLOCK_DEV_TOP_H__
|
||||
#define __VOL_BLOCK_DEV_TOP_H__
|
||||
|
||||
#include "../cas_cache.h"
|
||||
|
||||
int kcas_core_create_exported_object(ocf_core_t core);
|
||||
int kcas_core_destroy_exported_object(ocf_core_t core);
|
||||
|
2
ocf
2
ocf
@ -1 +1 @@
|
||||
Subproject commit f39a57a974f8cf157a1230590821aeb19f16298f
|
||||
Subproject commit 7c8ac29ab982eb33abd42c9049fe42ddc491a7b2
|
Loading…
Reference in New Issue
Block a user