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
0 commit comments