Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions configure.d/1_ida_alloc.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
#
# Copyright(c) 2026 Unvertical
# SPDX-License-Identifier: BSD-3-Clause
#

. $(dirname $3)/conf_framework.sh

# ida_alloc_max()/ida_free() were introduced in v4.19; older kernels only
# have ida_simple_get()/ida_simple_remove(), which were removed in v6.9.
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "ida_alloc_max(NULL, 0, GFP_KERNEL);" "linux/idr.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "ida_simple_get(NULL, 0, 0, GFP_KERNEL);" "linux/idr.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 int cas_ida_alloc_max(struct ida *ida, unsigned int max,
gfp_t gfp)
{
return ida_alloc_max(ida, max, gfp);
}"
add_function "
static inline void cas_ida_free(struct ida *ida, unsigned int id)
{
ida_free(ida, id);
}" ;;
"2")
add_function "
static inline int cas_ida_alloc_max(struct ida *ida, unsigned int max,
gfp_t gfp)
{
return ida_simple_get(ida, 0, max + 1, gfp);
}"
add_function "
static inline void cas_ida_free(struct ida *ida, unsigned int id)
{
ida_simple_remove(ida, id);
}" ;;
*)
exit 1
esac
}

conf_run $@
34 changes: 34 additions & 0 deletions configure.d/1_sysfs_emit.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
#
# Copyright(c) 2026 Unvertical
# SPDX-License-Identifier: BSD-3-Clause
#

. $(dirname $3)/conf_framework.sh

# sysfs_emit() was introduced in v5.10.
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "sysfs_emit(NULL, \"\");" "linux/sysfs.h"
then
echo $cur_name "1" >> $config_file_path
else
echo $cur_name "2" >> $config_file_path
fi
}

apply() {
case "$1" in
"1")
add_define "cas_sysfs_emit(buf, fmt, ...) \\
sysfs_emit(buf, fmt, ##__VA_ARGS__)" ;;
"2")
add_define "cas_sysfs_emit(buf, fmt, ...) \\
scnprintf(buf, PAGE_SIZE, fmt, ##__VA_ARGS__)" ;;
*)
exit 1
esac
}

conf_run $@
6 changes: 3 additions & 3 deletions modules/cas_bd/exp_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ static CAS_MAKE_REQ_RET_TYPE _cas_exp_obj_make_rq_fn(struct request_queue *q,

static int _cas_exp_obj_allocate_minor_slot(void)
{
return ida_alloc_max(&exp_obj_global.minor_ida,
return cas_ida_alloc_max(&exp_obj_global.minor_ida,
CAS_MINOR_SLOT_MAX, GFP_KERNEL);
}

static void _cas_exp_obj_free_minor_slot(int slot)
{
ida_free(&exp_obj_global.minor_ida, slot);
cas_ida_free(&exp_obj_global.minor_ida, slot);
}

static int _cas_exp_obj_set_dev_t(struct cas_exp_obj *exp_obj,
Expand Down Expand Up @@ -301,7 +301,7 @@ static ssize_t device_attr_serial_show(struct device *dev,
struct gendisk *gd = dev_to_disk(dev);
struct cas_exp_obj *exp_obj = gd->private_data;

return sysfs_emit(buf, "opencas-%s", exp_obj->dev_name);
return cas_sysfs_emit(buf, "opencas-%s", exp_obj->dev_name);
}

static struct device_attribute device_attr_serial =
Expand Down
Loading