Skip to content

Commit 372a29d

Browse files
Merge pull request #1549 from robertbaldyga/kernel-6.11
Support kernel 6.13
2 parents 69fd4a3 + 7ee78ac commit 372a29d

13 files changed

+311
-57
lines changed

configure.d/1_bd_first_part.conf

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
#
33
# Copyright(c) 2012-2022 Intel Corporation
4-
# Copyright(c) 2024 Huawei Technologies
4+
# Copyright(c) 2024-2025 Huawei Technologies
55
# SPDX-License-Identifier: BSD-3-Clause
66
#
77

@@ -10,16 +10,19 @@
1010
check() {
1111
cur_name=$(basename $2)
1212
config_file_path=$1
13-
if compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl;" "linux/genhd.h" ||
14-
compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl;" "linux/blkdev.h"
13+
if compile_module $cur_name "struct block_device bd; bdev_partno;" "linux/blkdev.h"
1514
then
1615
echo $cur_name "1" >> $config_file_path
17-
elif compile_module $cur_name "struct block_device bd; bd = *disk_part_iter_next(NULL);" "linux/blk_types.h" "linux/genhd.h"
16+
elif compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl;" "linux/genhd.h" ||
17+
compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl;" "linux/blkdev.h"
1818
then
1919
echo $cur_name "2" >> $config_file_path
20-
elif compile_module $cur_name "struct hd_struct hd; hd = *disk_part_iter_next(NULL);" "linux/genhd.h"
20+
elif compile_module $cur_name "struct block_device bd; bd = *disk_part_iter_next(NULL);" "linux/blk_types.h" "linux/genhd.h"
2121
then
2222
echo $cur_name "3" >> $config_file_path
23+
elif compile_module $cur_name "struct hd_struct hd; hd = *disk_part_iter_next(NULL);" "linux/genhd.h"
24+
then
25+
echo $cur_name "4" >> $config_file_path
2326
else
2427
echo $cur_name "X" >> $config_file_path
2528
fi
@@ -37,7 +40,7 @@ apply() {
3740
unsigned long idx;
3841
3942
xa_for_each(&disk->part_tbl, idx, part) {
40-
if ((part_no = part->bd_partno)) {
43+
if ((part_no = bdev_partno(part))) {
4144
break;
4245
}
4346
}
@@ -47,6 +50,23 @@ apply() {
4750
"2")
4851
add_function "
4952
static inline int cas_bd_get_next_part(struct block_device *bd)
53+
{
54+
int part_no = 0;
55+
struct gendisk *disk = bd->bd_disk;
56+
struct block_device *part;
57+
unsigned long idx;
58+
59+
xa_for_each(&disk->part_tbl, idx, part) {
60+
if ((part_no = part->bd_partno)) {
61+
break;
62+
}
63+
}
64+
65+
return part_no;
66+
}" ;;
67+
"3")
68+
add_function "
69+
static inline int cas_bd_get_next_part(struct block_device *bd)
5070
{
5171
int part_no = 0;
5272
struct gendisk *disk = bd->bd_disk;
@@ -66,7 +86,7 @@ apply() {
6686
6787
return part_no;
6888
}" ;;
69-
"3")
89+
"4")
7090
add_function "
7191
static inline int cas_bd_get_next_part(struct block_device *bd)
7292
{

configure.d/1_queue_discard.conf

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
#
3+
# Copyright(c) 2012-2022 Intel Corporation
4+
# Copyright(c) 2025 Huawei Technologies
5+
# SPDX-License-Identifier: BSD-3-Clause
6+
#
7+
8+
. $(dirname $3)/conf_framework.sh
9+
10+
check() {
11+
cur_name=$(basename $2)
12+
config_file_path=$1
13+
if compile_module $cur_name "blk_queue_max_discard_sectors(NULL, 0);" "linux/blkdev.h"
14+
then
15+
echo $cur_name "1" >> $config_file_path
16+
else
17+
echo $cur_name "2" >> $config_file_path
18+
fi
19+
}
20+
21+
apply() {
22+
case "$1" in
23+
"1")
24+
add_function "
25+
static inline void cas_queue_max_discard_sectors(
26+
struct request_queue *q,
27+
unsigned int max_discard_sectors)
28+
{
29+
blk_queue_max_discard_sectors(q, max_discard_sectors);
30+
}" ;;
31+
"2")
32+
add_function "
33+
static inline void cas_queue_max_discard_sectors(
34+
struct request_queue *q,
35+
unsigned int max_discard_sectors)
36+
{
37+
struct queue_limits *lim = &q->limits;
38+
39+
lim->max_hw_discard_sectors = max_discard_sectors;
40+
lim->max_discard_sectors =
41+
min(max_discard_sectors, lim->max_user_discard_sectors);
42+
}" ;;
43+
*)
44+
exit 1
45+
esac
46+
}
47+
48+
conf_run $@

configure.d/1_queue_limits.conf

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
#
33
# Copyright(c) 2012-2022 Intel Corporation
4-
# Copyright(c) 2024 Huawei Technologies
4+
# Copyright(c) 2024-2025 Huawei Technologies
55
# SPDX-License-Identifier: BSD-3-Clause
66
#
77

@@ -12,18 +12,18 @@ check() {
1212
cur_name=$(basename $2)
1313
config_file_path=$1
1414

15-
if compile_module $cur_name "struct queue_limits q; q.limits_aux;" "linux/blkdev.h"
16-
then
17-
echo $cur_name "1" >> $config_file_path
18-
elif compile_module $cur_name "struct queue_limits q; q.max_write_zeroes_sectors;" "linux/blkdev.h"
15+
if compile_module $cur_name "struct queue_limits q; q.max_write_zeroes_sectors;" "linux/blkdev.h"
1916
then
2017
if compile_module $cur_name "struct queue_limits q; q.max_write_same_sectors;" "linux/blkdev.h"
2118
then
22-
echo $cur_name "2" >> $config_file_path
19+
echo $cur_name "1" >> $config_file_path
2320
else
24-
echo $cur_name "3" >> $config_file_path
21+
echo $cur_name "2" >> $config_file_path
2522
fi
2623
elif compile_module $cur_name "struct queue_limits q; q.max_write_same_sectors;" "linux/blkdev.h"
24+
then
25+
echo $cur_name "3" >> $config_file_path
26+
elif compile_module $cur_name "struct queue_limits q; q.limits_aux;" "linux/blkdev.h"
2727
then
2828
echo $cur_name "4" >> $config_file_path
2929
else
@@ -38,30 +38,17 @@ apply() {
3838
static inline void cas_copy_queue_limits(struct request_queue *exp_q,
3939
struct queue_limits *cache_q_limits, struct request_queue *core_q)
4040
{
41-
struct queue_limits_aux *l_aux = exp_q->limits.limits_aux;
4241
exp_q->limits = *cache_q_limits;
43-
exp_q->limits.limits_aux = l_aux;
44-
if (exp_q->limits.limits_aux && cache_q_limits->limits_aux)
45-
*exp_q->limits.limits_aux = *cache_q_limits->limits_aux;
4642
exp_q->limits.max_sectors = core_q->limits.max_sectors;
4743
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
4844
exp_q->limits.max_segments = core_q->limits.max_segments;
4945
exp_q->limits.max_write_same_sectors = 0;
46+
exp_q->limits.max_write_zeroes_sectors = 0;
5047
}"
5148

52-
# A workaround for RHEL/CentOS 7.3 bug in kernel.
53-
# Merging implementation on blk-mq does not respect virt boundary
54-
# restriction and front merges bios with non-zero offsets.
55-
# This leads to request with gaps between bios and in consequence
56-
# triggers BUG_ON() in nvme driver or silently corrupts data.
57-
# To prevent this, disable merging on cache queue if there are
58-
# requirements regarding virt boundary (marking bios with REQ_NOMERGE
59-
# does not solve this problem).
6049
add_function "
6150
static inline void cas_cache_set_no_merges_flag(struct request_queue *cache_q)
6251
{
63-
if (queue_virt_boundary(cache_q))
64-
queue_flag_set(QUEUE_FLAG_NOMERGES, cache_q);
6552
}" ;;
6653
"2")
6754
add_function "
@@ -72,7 +59,6 @@ apply() {
7259
exp_q->limits.max_sectors = core_q->limits.max_sectors;
7360
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
7461
exp_q->limits.max_segments = core_q->limits.max_segments;
75-
exp_q->limits.max_write_same_sectors = 0;
7662
exp_q->limits.max_write_zeroes_sectors = 0;
7763
}"
7864

@@ -89,7 +75,7 @@ apply() {
8975
exp_q->limits.max_sectors = core_q->limits.max_sectors;
9076
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
9177
exp_q->limits.max_segments = core_q->limits.max_segments;
92-
exp_q->limits.max_write_zeroes_sectors = 0;
78+
exp_q->limits.max_write_same_sectors = 0;
9379
}"
9480

9581
add_function "
@@ -101,16 +87,30 @@ apply() {
10187
static inline void cas_copy_queue_limits(struct request_queue *exp_q,
10288
struct queue_limits *cache_q_limits, struct request_queue *core_q)
10389
{
90+
struct queue_limits_aux *l_aux = exp_q->limits.limits_aux;
10491
exp_q->limits = *cache_q_limits;
92+
exp_q->limits.limits_aux = l_aux;
93+
if (exp_q->limits.limits_aux && cache_q_limits->limits_aux)
94+
*exp_q->limits.limits_aux = *cache_q_limits->limits_aux;
10595
exp_q->limits.max_sectors = core_q->limits.max_sectors;
10696
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
10797
exp_q->limits.max_segments = core_q->limits.max_segments;
10898
exp_q->limits.max_write_same_sectors = 0;
10999
}"
110100

101+
# A workaround for RHEL/CentOS 7.3 bug in kernel.
102+
# Merging implementation on blk-mq does not respect virt boundary
103+
# restriction and front merges bios with non-zero offsets.
104+
# This leads to request with gaps between bios and in consequence
105+
# triggers BUG_ON() in nvme driver or silently corrupts data.
106+
# To prevent this, disable merging on cache queue if there are
107+
# requirements regarding virt boundary (marking bios with REQ_NOMERGE
108+
# does not solve this problem).
111109
add_function "
112110
static inline void cas_cache_set_no_merges_flag(struct request_queue *cache_q)
113111
{
112+
if (queue_virt_boundary(cache_q))
113+
queue_flag_set(QUEUE_FLAG_NOMERGES, cache_q);
114114
}" ;;
115115

116116

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
#
3+
# Copyright(c) 2025 Huawei Technologies
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
7+
. $(dirname $3)/conf_framework.sh
8+
9+
check() {
10+
cur_name=$(basename $2)
11+
config_file_path=$1
12+
13+
if compile_module $cur_name "struct queue_limits q; q.misaligned;" "linux/blkdev.h"
14+
then
15+
echo $cur_name 1 >> $config_file_path
16+
else
17+
echo $cur_name 2 >> $config_file_path
18+
fi
19+
}
20+
21+
apply() {
22+
case "$1" in
23+
"1")
24+
add_function "
25+
static inline bool cas_queue_limits_is_misaligned(
26+
struct queue_limits *lim)
27+
{
28+
return lim->misaligned;
29+
}" ;;
30+
"2")
31+
add_function "
32+
static inline bool cas_queue_limits_is_misaligned(
33+
struct queue_limits *lim)
34+
{
35+
return lim->features & BLK_FLAG_MISALIGNED;
36+
}" ;;
37+
*)
38+
exit 1
39+
esac
40+
}
41+
42+
conf_run $@

configure.d/1_queue_nonrot.conf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
#
3+
# Copyright(c) 2012-2022 Intel Corporation
4+
# Copyright(c) 2025 Huawei Technologies
5+
# SPDX-License-Identifier: BSD-3-Clause
6+
#
7+
8+
. $(dirname $3)/conf_framework.sh
9+
10+
check() {
11+
cur_name=$(basename $2)
12+
config_file_path=$1
13+
if compile_module $cur_name "(int)QUEUE_FLAG_NONROT;" "linux/blkdev.h"
14+
then
15+
echo $cur_name "1" >> $config_file_path
16+
else
17+
echo $cur_name "2" >> $config_file_path
18+
fi
19+
}
20+
21+
apply() {
22+
case "$1" in
23+
"1")
24+
add_function "
25+
static inline void cas_queue_set_nonrot(struct request_queue *q)
26+
{
27+
q->queue_flags |= (1 << QUEUE_FLAG_NONROT);
28+
}" ;;
29+
"2")
30+
add_function "
31+
static inline void cas_queue_set_nonrot(struct request_queue *q)
32+
{
33+
}" ;;
34+
*)
35+
exit 1
36+
esac
37+
}
38+
39+
conf_run $@

configure.d/2_alloc_disk.conf

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
#
33
# Copyright(c) 2012-2022 Intel Corporation
4-
# Copyright(c) 2024 Huawei Technologies
4+
# Copyright(c) 2024-2025 Huawei Technologies
55
# SPDX-License-Identifier: BSD-3-Clause
66
#
77

@@ -28,13 +28,14 @@ check() {
2828
apply() {
2929
case "$1" in
3030
"1")
31+
add_typedef "struct queue_limits cas_queue_limits_t;"
3132
add_function "
3233
static inline int cas_alloc_mq_disk(struct gendisk **gd, struct request_queue **queue,
33-
struct blk_mq_tag_set *tag_set)
34+
struct blk_mq_tag_set *tag_set, cas_queue_limits_t *lim)
3435
{
35-
*gd = blk_mq_alloc_disk(tag_set, NULL, NULL);
36-
if (!(*gd))
37-
return -ENOMEM;
36+
*gd = blk_mq_alloc_disk(tag_set, lim, NULL);
37+
if (IS_ERR(*gd))
38+
return PTR_ERR(*gd);
3839
3940
*queue = (*gd)->queue;
4041
@@ -48,13 +49,14 @@ apply() {
4849
;;
4950

5051
"2")
52+
add_typedef "void* cas_queue_limits_t;"
5153
add_function "
5254
static inline int cas_alloc_mq_disk(struct gendisk **gd, struct request_queue **queue,
53-
struct blk_mq_tag_set *tag_set)
55+
struct blk_mq_tag_set *tag_set, cas_queue_limits_t *lim)
5456
{
5557
*gd = blk_mq_alloc_disk(tag_set, NULL);
56-
if (!(*gd))
57-
return -ENOMEM;
58+
if (IS_ERR(*gd))
59+
return PTR_ERR(*gd);
5860
5961
*queue = (*gd)->queue;
6062
@@ -68,10 +70,10 @@ apply() {
6870
;;
6971

7072
"3")
71-
73+
add_typedef "void* cas_queue_limits_t;"
7274
add_function "
7375
static inline int cas_alloc_mq_disk(struct gendisk **gd, struct request_queue **queue,
74-
struct blk_mq_tag_set *tag_set)
76+
struct blk_mq_tag_set *tag_set, cas_queue_limits_t *lim)
7577
{
7678
*gd = alloc_disk(1);
7779
if (!(*gd))

0 commit comments

Comments
 (0)