Skip to content

Commit a17474e

Browse files
Robert BaldygaRafal Stefanowski
authored andcommitted
Support kernel 6.13
Signed-off-by: Robert Baldyga <[email protected]> Signed-off-by: Rafal Stefanowski <[email protected]>
1 parent aafc6b4 commit a17474e

File tree

12 files changed

+314
-56
lines changed

12 files changed

+314
-56
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: 68 additions & 22 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,20 +12,25 @@ 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"
15+
if compile_module $cur_name "struct queue_limits q; q.max_write_zeroes_sectors;" "linux/blkdev.h"
1616
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"
19-
then
20-
if compile_module $cur_name "struct queue_limits q; q.max_write_same_sectors;" "linux/blkdev.h"
17+
if compile_module $cur_name "struct queue_limits q; q.misaligned;" "linux/blkdev.h"
2118
then
22-
echo $cur_name "2" >> $config_file_path
19+
if compile_module $cur_name "struct queue_limits q; q.max_write_same_sectors;" "linux/blkdev.h"
20+
then
21+
echo $cur_name "1" >> $config_file_path
22+
else
23+
echo $cur_name "2" >> $config_file_path
24+
fi
2325
else
2426
echo $cur_name "3" >> $config_file_path
2527
fi
2628
elif compile_module $cur_name "struct queue_limits q; q.max_write_same_sectors;" "linux/blkdev.h"
2729
then
2830
echo $cur_name "4" >> $config_file_path
31+
elif compile_module $cur_name "struct queue_limits q; q.limits_aux;" "linux/blkdev.h"
32+
then
33+
echo $cur_name "5" >> $config_file_path
2934
else
3035
echo $cur_name "X" >> $config_file_path
3136
fi
@@ -38,30 +43,22 @@ apply() {
3843
static inline void cas_copy_queue_limits(struct request_queue *exp_q,
3944
struct queue_limits *cache_q_limits, struct request_queue *core_q)
4045
{
41-
struct queue_limits_aux *l_aux = exp_q->limits.limits_aux;
4246
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;
4647
exp_q->limits.max_sectors = core_q->limits.max_sectors;
4748
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
4849
exp_q->limits.max_segments = core_q->limits.max_segments;
4950
exp_q->limits.max_write_same_sectors = 0;
51+
exp_q->limits.max_write_zeroes_sectors = 0;
5052
}"
5153

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).
6054
add_function "
6155
static inline void cas_cache_set_no_merges_flag(struct request_queue *cache_q)
6256
{
63-
if (queue_virt_boundary(cache_q))
64-
queue_flag_set(QUEUE_FLAG_NOMERGES, cache_q);
57+
}
58+
static inline bool cas_queue_limits_is_misaligned(
59+
struct queue_limits *lim)
60+
{
61+
return lim->misaligned;
6562
}" ;;
6663
"2")
6764
add_function "
@@ -72,13 +69,17 @@ apply() {
7269
exp_q->limits.max_sectors = core_q->limits.max_sectors;
7370
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
7471
exp_q->limits.max_segments = core_q->limits.max_segments;
75-
exp_q->limits.max_write_same_sectors = 0;
7672
exp_q->limits.max_write_zeroes_sectors = 0;
7773
}"
7874

7975
add_function "
8076
static inline void cas_cache_set_no_merges_flag(struct request_queue *cache_q)
8177
{
78+
}
79+
static inline bool cas_queue_limits_is_misaligned(
80+
struct queue_limits *lim)
81+
{
82+
return lim->misaligned;
8283
}" ;;
8384
"3")
8485
add_function "
@@ -95,6 +96,11 @@ apply() {
9596
add_function "
9697
static inline void cas_cache_set_no_merges_flag(struct request_queue *cache_q)
9798
{
99+
}
100+
static inline bool cas_queue_limits_is_misaligned(
101+
struct queue_limits *lim)
102+
{
103+
return lim->features & BLK_FLAG_MISALIGNED;
98104
}" ;;
99105
"4")
100106
add_function "
@@ -111,6 +117,46 @@ apply() {
111117
add_function "
112118
static inline void cas_cache_set_no_merges_flag(struct request_queue *cache_q)
113119
{
120+
}
121+
static inline bool cas_queue_limits_is_misaligned(
122+
struct queue_limits *lim)
123+
{
124+
return lim->misaligned;
125+
}" ;;
126+
"5")
127+
add_function "
128+
static inline void cas_copy_queue_limits(struct request_queue *exp_q,
129+
struct queue_limits *cache_q_limits, struct request_queue *core_q)
130+
{
131+
struct queue_limits_aux *l_aux = exp_q->limits.limits_aux;
132+
exp_q->limits = *cache_q_limits;
133+
exp_q->limits.limits_aux = l_aux;
134+
if (exp_q->limits.limits_aux && cache_q_limits->limits_aux)
135+
*exp_q->limits.limits_aux = *cache_q_limits->limits_aux;
136+
exp_q->limits.max_sectors = core_q->limits.max_sectors;
137+
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
138+
exp_q->limits.max_segments = core_q->limits.max_segments;
139+
exp_q->limits.max_write_same_sectors = 0;
140+
}"
141+
142+
# A workaround for RHEL/CentOS 7.3 bug in kernel.
143+
# Merging implementation on blk-mq does not respect virt boundary
144+
# restriction and front merges bios with non-zero offsets.
145+
# This leads to request with gaps between bios and in consequence
146+
# triggers BUG_ON() in nvme driver or silently corrupts data.
147+
# To prevent this, disable merging on cache queue if there are
148+
# requirements regarding virt boundary (marking bios with REQ_NOMERGE
149+
# does not solve this problem).
150+
add_function "
151+
static inline void cas_cache_set_no_merges_flag(struct request_queue *cache_q)
152+
{
153+
if (queue_virt_boundary(cache_q))
154+
queue_flag_set(QUEUE_FLAG_NOMERGES, cache_q);
155+
}
156+
static inline bool cas_queue_limits_is_misaligned(
157+
struct queue_limits *lim)
158+
{
159+
return lim->misaligned;
114160
}" ;;
115161

116162

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)