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