configure framework: detect make_req_fn type
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
parent
f44b3d8867
commit
8fbbf31734
87
configure.d/1_make_req_type.conf
Normal file
87
configure.d/1_make_req_type.conf
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
# The commit c62b37d96b6eb3ec5 in the kernel repo introduces `submit_bio`
|
||||||
|
# and removes make_request_fn
|
||||||
|
if compile_module $cur_name "struct block_device_operations x; x.submit_bio;" "linux/blkdev.h";
|
||||||
|
then
|
||||||
|
# If it's impossible to cast the return value of submit_bio()
|
||||||
|
# to an int we're assuming the function is of type void.
|
||||||
|
# It's not a generic solution because the check would pass if
|
||||||
|
# the return type would be a struct, but it can't happend in this
|
||||||
|
# specific scenario
|
||||||
|
# Mind the negation in the condition
|
||||||
|
if ! compile_module $cur_name \
|
||||||
|
"struct block_device_operations x; int y = (int)x.submit_bio(NULL);" "linux/blkdev.h";
|
||||||
|
then
|
||||||
|
# submit_bio is of type void
|
||||||
|
echo $cur_name "1" >> $config_file_path
|
||||||
|
elif compile_module $cur_name \
|
||||||
|
"struct block_device_operations x; blk_qc_t y = x.submit_bio(NULL);" "linux/blkdev.h" ;
|
||||||
|
then
|
||||||
|
# submit_bio is of type blk_qc_t
|
||||||
|
echo $cur_name "2" >> $config_file_path
|
||||||
|
else
|
||||||
|
echo $cur_name "X" >> $config_file_path
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# If it's impossible to cast the return value of make_request_fn()
|
||||||
|
# to an int we're assuming the function is of type void.
|
||||||
|
# It's not a generic solution because the check would pass if
|
||||||
|
# the return type would be a struct, but it can't happend in this
|
||||||
|
# specific scenario
|
||||||
|
# Mind the negation in the condition
|
||||||
|
if ! compile_module $cur_name \
|
||||||
|
"struct request_queue *q; int y = (int)q->make_request_fn(NULL);" "linux/blkdev.h";
|
||||||
|
then
|
||||||
|
# make_request_fn is of type void
|
||||||
|
echo $cur_name "3" >> $config_file_path
|
||||||
|
elif ! compile_module $cur_name \
|
||||||
|
"struct request_queue *q; blk_qc_t y = q->make_request_fn(NULL);" "linux/blkdev.h";
|
||||||
|
then
|
||||||
|
# make_request_fn is of type blk_qc_t
|
||||||
|
echo $cur_name "4" >> $config_file_path
|
||||||
|
elif ! compile_module $cur_name \
|
||||||
|
"struct request_queue *q; int y = q->make_request_fn(NULL);" "linux/blkdev.h";
|
||||||
|
then
|
||||||
|
# make_request_fn is of type int
|
||||||
|
echo $cur_name "5" >> $config_file_path
|
||||||
|
else
|
||||||
|
echo $cur_name "X" >> $config_file_path
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
apply() {
|
||||||
|
case "$1" in
|
||||||
|
"1")
|
||||||
|
add_define "CAS_KRETURN(_x) return "
|
||||||
|
add_define "CAS_MAKE_REQ_RET_TYPE void " ;;
|
||||||
|
"2")
|
||||||
|
add_define "CAS_KRETURN(_x) ({ return (_x); }) "
|
||||||
|
add_define "CAS_MAKE_REQ_RET_TYPE blk_qc_t " ;;
|
||||||
|
"3")
|
||||||
|
add_define "CAS_KRETURN(_x) return "
|
||||||
|
add_define "CAS_MAKE_REQ_RET_TYPE void " ;;
|
||||||
|
"4")
|
||||||
|
add_define "CAS_KRETURN(_x) ({ return (_x); }) "
|
||||||
|
add_define "CAS_MAKE_REQ_RET_TYPE blk_qc_t " ;;
|
||||||
|
"5")
|
||||||
|
add_define "CAS_KRETURN(_x) ({ return (_x); }) "
|
||||||
|
add_define "CAS_MAKE_REQ_RET_TYPE int " ;;
|
||||||
|
*)
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
conf_run $@
|
@ -31,27 +31,6 @@ static inline void bd_release_from_disk(struct block_device *bdev,
|
|||||||
return bd_unlink_disk_holder(bdev, disk);
|
return bd_unlink_disk_holder(bdev, disk);
|
||||||
}
|
}
|
||||||
|
|
||||||
#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
|
|
||||||
#else
|
|
||||||
#define KRETURN(x) return
|
|
||||||
#define MAKE_RQ_RET_TYPE void
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* For RHEL 9.x we assume backport from kernel 5.18+ */
|
|
||||||
#ifdef RHEL_MAJOR
|
|
||||||
#if RHEL_MAJOR >= 9
|
|
||||||
#undef KRETURN
|
|
||||||
#undef MAKE_RQ_RET_TYPE
|
|
||||||
#define KRETURN(x) return
|
|
||||||
#define MAKE_RQ_RET_TYPE void
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int __init cas_init_exp_objs(void)
|
int __init cas_init_exp_objs(void)
|
||||||
{
|
{
|
||||||
CAS_DEBUG_TRACE();
|
CAS_DEBUG_TRACE();
|
||||||
@ -82,7 +61,7 @@ void cas_deinit_exp_objs(void)
|
|||||||
unregister_blkdev(cas_module.disk_major, "cas");
|
unregister_blkdev(cas_module.disk_major, "cas");
|
||||||
}
|
}
|
||||||
|
|
||||||
static MAKE_RQ_RET_TYPE _cas_exp_obj_submit_bio(struct bio *bio)
|
static CAS_MAKE_REQ_RET_TYPE _cas_exp_obj_submit_bio(struct bio *bio)
|
||||||
{
|
{
|
||||||
struct cas_disk *dsk;
|
struct cas_disk *dsk;
|
||||||
struct cas_exp_obj *exp_obj;
|
struct cas_exp_obj *exp_obj;
|
||||||
@ -93,15 +72,15 @@ static MAKE_RQ_RET_TYPE _cas_exp_obj_submit_bio(struct bio *bio)
|
|||||||
|
|
||||||
exp_obj->ops->submit_bio(dsk, bio, exp_obj->private);
|
exp_obj->ops->submit_bio(dsk, bio, exp_obj->private);
|
||||||
|
|
||||||
KRETURN(0);
|
CAS_KRETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static MAKE_RQ_RET_TYPE _cas_exp_obj_make_rq_fn(struct request_queue *q,
|
static CAS_MAKE_REQ_RET_TYPE _cas_exp_obj_make_rq_fn(struct request_queue *q,
|
||||||
struct bio *bio)
|
struct bio *bio)
|
||||||
{
|
{
|
||||||
_cas_exp_obj_submit_bio(bio);
|
_cas_exp_obj_submit_bio(bio);
|
||||||
cas_blk_queue_exit(q);
|
cas_blk_queue_exit(q);
|
||||||
KRETURN(0);
|
CAS_KRETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _cas_del_partitions(struct cas_disk *dsk)
|
static int _cas_del_partitions(struct cas_disk *dsk)
|
||||||
|
Loading…
Reference in New Issue
Block a user