OpenCAS Linux kernel 5.15 adaptation

This patch adapts OpenCAS Linux to compile and work with kernel v5.15

Commit id's from the kernel affecting OpenCAS:

commit 0e0ccdecb3cff95a350b4364e7ebbaa754d0e47d
    block: remove bdget_disk

commit 9c2b9dbafc067e173db30c4fd0636392d27944e8
    block: remove alloc_disk and alloc_disk_node

commit a8698707a1835be3abd12a3b28079a80999f8dee
    block: move bd_mutex to struct gendisk

commit 2cece3778475abc855084d897a3cf61249798ad9
    scsi: scsi_ioctl: Remove scsi_req_init()

commit 2f4731dcd0bb73379fbb9e3eb07ae7324125caef
    block: remove bdput

commit 14cf1dbb55bb07427babee425fd2a8a9300737cc
    block: remove bdgrab

Signed-off-by: Krzysztof Majzerowicz-Jaszcz <krzysztof.majzerowicz-jaszcz@intel.com>
This commit is contained in:
Krzysztof Majzerowicz-Jaszcz
2022-04-27 19:12:33 +02:00
parent 685b68516a
commit 12ddca1cf3
10 changed files with 169 additions and 111 deletions

View File

@@ -0,0 +1,75 @@
#!/bin/bash
#
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
. $(dirname $3)/conf_framework
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "blk_mq_alloc_disk(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 int cas_alloc_mq_disk(struct gendisk **gd, struct request_queue **queue,
struct blk_mq_tag_set *tag_set)
{
*gd = blk_mq_alloc_disk(tag_set, NULL);
if (!(*gd))
return -ENOMEM;
*queue = (*gd)->queue;
return 0;
}"
add_function "
static inline void cas_cleanup_mq_disk(struct casdsk_exp_obj *exp_obj)
{
blk_cleanup_disk(exp_obj->gd);
}"
;;
"2")
add_function "
static inline int cas_alloc_mq_disk(struct gendisk **gd, struct request_queue **queue,
struct blk_mq_tag_set *tag_set)
{
*gd = alloc_disk(1);
if (!(*gd))
return -ENOMEM;
*queue = blk_mq_init_queue(tag_set);
if (IS_ERR_OR_NULL(*queue)) {
put_disk(*gd);
return -ENOMEM;
}
(*gd)->queue = *queue;
return 0;
}"
add_function "
static inline void cas_cleanup_mq_disk(struct casdsk_exp_obj *exp_obj){
blk_cleanup_queue(exp_obj->queue);
put_disk(exp_obj->gd);
}"
;;
*)
exit 1
esac
}
conf_run $@

View File

@@ -1,43 +0,0 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
. $(dirname $3)/conf_framework
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "bdget_disk(NULL, 0);" "linux/genhd.h"
then
echo $cur_name 1 >> $config_file_path
elif compile_module $cur_name "bdgrab(NULL);" "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_function "
static inline struct block_device *cas_bdget_disk(struct gendisk *gd)
{
return bdget_disk(gd, 0);
}" ;;
"2")
add_function "
static inline struct block_device *cas_bdget_disk(struct gendisk *gd)
{
return bdgrab(gd->part0);
}" ;;
*)
exit 1
esac
}
conf_run $@

View File

@@ -34,7 +34,12 @@ apply() {
{
struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq);
scsi_req_init(&cmd->req);
struct scsi_request *req = &cmd->req;
memset(req->__cmd, 0, sizeof(req->__cmd));
req->cmd = req->__cmd;
req->cmd_len = BLK_MAX_CDB;
req->sense_len = 0;
}" ;;
*)
exit 1

View File

@@ -23,7 +23,7 @@ apply() {
add_function "
static inline void cas_reread_partitions(struct block_device *bdev)
{
bdev_disk_changed(bdev, false);
bdev_disk_changed(bdev->bd_disk, false);
}" ;;
"2")
add_function "