open-cas-linux/configure.d/2_alloc_disk.conf
Robert Baldyga 72ae9b8161 Allocate bdev suitable for submit_bio()
Starting from kernel 6.14, submit_bio() is supported only for non-mq bdevs.

Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
2025-04-02 12:38:27 +02:00

131 lines
2.9 KiB
Bash

#!/bin/bash
#
# Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2024-2025 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 "blk_alloc_disk(NULL, 0);" "linux/blkdev.h"
then
echo $cur_name 1 >> $config_file_path
elif compile_module $cur_name "blk_mq_alloc_disk(NULL, NULL, NULL);" "linux/blk-mq.h"
then
echo $cur_name 2 >> $config_file_path
elif compile_module $cur_name "blk_mq_alloc_disk(NULL, NULL);" "linux/blk-mq.h"
then
echo $cur_name 3 >> $config_file_path
elif compile_module $cur_name "alloc_disk(0);" "linux/genhd.h"
then
echo $cur_name 4 >> $config_file_path
else
echo $cur_name X >> $config_file_path
fi
}
apply() {
case "$1" in
"1")
add_typedef "struct queue_limits cas_queue_limits_t;"
add_function "
static inline int cas_alloc_disk(struct gendisk **gd, struct request_queue **queue,
struct blk_mq_tag_set *tag_set, cas_queue_limits_t *lim)
{
*gd = blk_alloc_disk(lim, NUMA_NO_NODE);
if (IS_ERR(*gd))
return PTR_ERR(*gd);
*queue = (*gd)->queue;
return 0;
}"
add_function "
static inline void cas_cleanup_disk(struct gendisk *gd)
{
_cas_cleanup_disk(gd);
}"
;;
"2")
add_typedef "struct queue_limits cas_queue_limits_t;"
add_function "
static inline int cas_alloc_disk(struct gendisk **gd, struct request_queue **queue,
struct blk_mq_tag_set *tag_set, cas_queue_limits_t *lim)
{
*gd = blk_mq_alloc_disk(tag_set, lim, NULL);
if (IS_ERR(*gd))
return PTR_ERR(*gd);
*queue = (*gd)->queue;
return 0;
}"
add_function "
static inline void cas_cleanup_disk(struct gendisk *gd)
{
_cas_cleanup_disk(gd);
}"
;;
"3")
add_typedef "void* cas_queue_limits_t;"
add_function "
static inline int cas_alloc_disk(struct gendisk **gd, struct request_queue **queue,
struct blk_mq_tag_set *tag_set, cas_queue_limits_t *lim)
{
*gd = blk_mq_alloc_disk(tag_set, NULL);
if (IS_ERR(*gd))
return PTR_ERR(*gd);
*queue = (*gd)->queue;
return 0;
}"
add_function "
static inline void cas_cleanup_disk(struct gendisk *gd)
{
_cas_cleanup_disk(gd);
}"
;;
"4")
add_typedef "void* cas_queue_limits_t;"
add_function "
static inline int cas_alloc_disk(struct gendisk **gd, struct request_queue **queue,
struct blk_mq_tag_set *tag_set, cas_queue_limits_t *lim)
{
*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_disk(struct gendisk *gd)
{
blk_cleanup_queue(gd->queue);
gd->queue = NULL;
put_disk(gd);
}"
;;
*)
exit 1
esac
}
conf_run $@