]>
Commit | Line | Data |
---|---|---|
0f2c1c8c JR |
1 | From ae0b1f66c707cff09bfde54aade784a016559a34 Mon Sep 17 00:00:00 2001 |
2 | From: Rich Ercolani <214141+rincebrain@users.noreply.github.com> | |
3 | Date: Mon, 27 Mar 2023 14:29:19 -0400 | |
4 | Subject: [PATCH] linux 6.3 compat: add another bdev_io_acct case | |
5 | ||
6 | Linux 6.3+, and backports from it (6.2.8+), changed the | |
7 | signatures on bdev_io_{start,end}_acct. Add a case for it. | |
8 | ||
9 | Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> | |
10 | Signed-off-by: Rich Ercolani <rincebrain@gmail.com> | |
11 | Closes #14658 | |
12 | Closes #14668 | |
13 | --- | |
14 | config/kernel-generic_io_acct.m4 | 98 ++++++++++++------- | |
15 | include/os/linux/kernel/linux/blkdev_compat.h | 10 +- | |
16 | 2 files changed, 69 insertions(+), 39 deletions(-) | |
17 | ||
18 | diff --git a/config/kernel-generic_io_acct.m4 b/config/kernel-generic_io_acct.m4 | |
19 | index a8a448c6fe9..a6a10900429 100644 | |
20 | --- a/config/kernel-generic_io_acct.m4 | |
21 | +++ b/config/kernel-generic_io_acct.m4 | |
22 | @@ -2,7 +2,20 @@ dnl # | |
23 | dnl # Check for generic io accounting interface. | |
24 | dnl # | |
25 | AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT], [ | |
26 | - ZFS_LINUX_TEST_SRC([bdev_io_acct], [ | |
27 | + ZFS_LINUX_TEST_SRC([bdev_io_acct_63], [ | |
28 | + #include <linux/blkdev.h> | |
29 | + ], [ | |
30 | + struct block_device *bdev = NULL; | |
31 | + struct bio *bio = NULL; | |
32 | + unsigned long passed_time = 0; | |
33 | + unsigned long start_time; | |
34 | + | |
35 | + start_time = bdev_start_io_acct(bdev, bio_op(bio), | |
36 | + passed_time); | |
37 | + bdev_end_io_acct(bdev, bio_op(bio), bio_sectors(bio), start_time); | |
38 | + ]) | |
39 | + | |
40 | + ZFS_LINUX_TEST_SRC([bdev_io_acct_old], [ | |
41 | #include <linux/blkdev.h> | |
42 | ], [ | |
43 | struct block_device *bdev = NULL; | |
44 | @@ -63,74 +76,85 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT], [ | |
45 | ||
46 | AC_DEFUN([ZFS_AC_KERNEL_GENERIC_IO_ACCT], [ | |
47 | dnl # | |
48 | - dnl # 5.19 API, | |
49 | + dnl # Linux 6.3, and then backports thereof, changed | |
50 | + dnl # the signatures on bdev_start_io_acct/bdev_end_io_acct | |
51 | dnl # | |
52 | - dnl # disk_start_io_acct() and disk_end_io_acct() have been replaced by | |
53 | - dnl # bdev_start_io_acct() and bdev_end_io_acct(). | |
54 | - dnl # | |
55 | - AC_MSG_CHECKING([whether generic bdev_*_io_acct() are available]) | |
56 | - ZFS_LINUX_TEST_RESULT([bdev_io_acct], [ | |
57 | + AC_MSG_CHECKING([whether 6.3+ bdev_*_io_acct() are available]) | |
58 | + ZFS_LINUX_TEST_RESULT([bdev_io_acct_63], [ | |
59 | AC_MSG_RESULT(yes) | |
60 | - AC_DEFINE(HAVE_BDEV_IO_ACCT, 1, [bdev_*_io_acct() available]) | |
61 | + AC_DEFINE(HAVE_BDEV_IO_ACCT_63, 1, [bdev_*_io_acct() available]) | |
62 | ], [ | |
63 | AC_MSG_RESULT(no) | |
64 | ||
65 | dnl # | |
66 | - dnl # 5.12 API, | |
67 | + dnl # 5.19 API, | |
68 | dnl # | |
69 | - dnl # bio_start_io_acct() and bio_end_io_acct() became GPL-exported | |
70 | - dnl # so use disk_start_io_acct() and disk_end_io_acct() instead | |
71 | + dnl # disk_start_io_acct() and disk_end_io_acct() have been replaced by | |
72 | + dnl # bdev_start_io_acct() and bdev_end_io_acct(). | |
73 | dnl # | |
74 | - AC_MSG_CHECKING([whether generic disk_*_io_acct() are available]) | |
75 | - ZFS_LINUX_TEST_RESULT([disk_io_acct], [ | |
76 | + AC_MSG_CHECKING([whether pre-6.3 bdev_*_io_acct() are available]) | |
77 | + ZFS_LINUX_TEST_RESULT([bdev_io_acct_old], [ | |
78 | AC_MSG_RESULT(yes) | |
79 | - AC_DEFINE(HAVE_DISK_IO_ACCT, 1, [disk_*_io_acct() available]) | |
80 | + AC_DEFINE(HAVE_BDEV_IO_ACCT_OLD, 1, [bdev_*_io_acct() available]) | |
81 | ], [ | |
82 | AC_MSG_RESULT(no) | |
83 | - | |
84 | dnl # | |
85 | - dnl # 5.7 API, | |
86 | + dnl # 5.12 API, | |
87 | dnl # | |
88 | - dnl # Added bio_start_io_acct() and bio_end_io_acct() helpers. | |
89 | + dnl # bio_start_io_acct() and bio_end_io_acct() became GPL-exported | |
90 | + dnl # so use disk_start_io_acct() and disk_end_io_acct() instead | |
91 | dnl # | |
92 | - AC_MSG_CHECKING([whether generic bio_*_io_acct() are available]) | |
93 | - ZFS_LINUX_TEST_RESULT([bio_io_acct], [ | |
94 | + AC_MSG_CHECKING([whether generic disk_*_io_acct() are available]) | |
95 | + ZFS_LINUX_TEST_RESULT([disk_io_acct], [ | |
96 | AC_MSG_RESULT(yes) | |
97 | - AC_DEFINE(HAVE_BIO_IO_ACCT, 1, [bio_*_io_acct() available]) | |
98 | + AC_DEFINE(HAVE_DISK_IO_ACCT, 1, [disk_*_io_acct() available]) | |
99 | ], [ | |
100 | AC_MSG_RESULT(no) | |
101 | ||
102 | dnl # | |
103 | - dnl # 4.14 API, | |
104 | + dnl # 5.7 API, | |
105 | dnl # | |
106 | - dnl # generic_start_io_acct/generic_end_io_acct now require | |
107 | - dnl # request_queue to be provided. No functional changes, | |
108 | - dnl # but preparation for inflight accounting. | |
109 | + dnl # Added bio_start_io_acct() and bio_end_io_acct() helpers. | |
110 | dnl # | |
111 | - AC_MSG_CHECKING([whether generic_*_io_acct wants 4 args]) | |
112 | - ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_4args], | |
113 | - [generic_start_io_acct], [block/bio.c], [ | |
114 | + AC_MSG_CHECKING([whether generic bio_*_io_acct() are available]) | |
115 | + ZFS_LINUX_TEST_RESULT([bio_io_acct], [ | |
116 | AC_MSG_RESULT(yes) | |
117 | - AC_DEFINE(HAVE_GENERIC_IO_ACCT_4ARG, 1, | |
118 | - [generic_*_io_acct() 4 arg available]) | |
119 | + AC_DEFINE(HAVE_BIO_IO_ACCT, 1, [bio_*_io_acct() available]) | |
120 | ], [ | |
121 | AC_MSG_RESULT(no) | |
122 | ||
123 | dnl # | |
124 | - dnl # 3.19 API addition | |
125 | + dnl # 4.14 API, | |
126 | dnl # | |
127 | - dnl # torvalds/linux@394ffa50 allows us to increment | |
128 | - dnl # iostat counters without generic_make_request(). | |
129 | + dnl # generic_start_io_acct/generic_end_io_acct now require | |
130 | + dnl # request_queue to be provided. No functional changes, | |
131 | + dnl # but preparation for inflight accounting. | |
132 | dnl # | |
133 | - AC_MSG_CHECKING( | |
134 | - [whether generic_*_io_acct wants 3 args]) | |
135 | - ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_3args], | |
136 | + AC_MSG_CHECKING([whether generic_*_io_acct wants 4 args]) | |
137 | + ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_4args], | |
138 | [generic_start_io_acct], [block/bio.c], [ | |
139 | AC_MSG_RESULT(yes) | |
140 | - AC_DEFINE(HAVE_GENERIC_IO_ACCT_3ARG, 1, | |
141 | - [generic_*_io_acct() 3 arg available]) | |
142 | + AC_DEFINE(HAVE_GENERIC_IO_ACCT_4ARG, 1, | |
143 | + [generic_*_io_acct() 4 arg available]) | |
144 | ], [ | |
145 | AC_MSG_RESULT(no) | |
146 | + | |
147 | + dnl # | |
148 | + dnl # 3.19 API addition | |
149 | + dnl # | |
150 | + dnl # torvalds/linux@394ffa50 allows us to increment | |
151 | + dnl # iostat counters without generic_make_request(). | |
152 | + dnl # | |
153 | + AC_MSG_CHECKING( | |
154 | + [whether generic_*_io_acct wants 3 args]) | |
155 | + ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_3args], | |
156 | + [generic_start_io_acct], [block/bio.c], [ | |
157 | + AC_MSG_RESULT(yes) | |
158 | + AC_DEFINE(HAVE_GENERIC_IO_ACCT_3ARG, 1, | |
159 | + [generic_*_io_acct() 3 arg available]) | |
160 | + ], [ | |
161 | + AC_MSG_RESULT(no) | |
162 | + ]) | |
163 | ]) | |
164 | ]) | |
165 | ]) | |
166 | diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h | |
167 | index f04eb5b2593..c7405ffab8b 100644 | |
168 | --- a/include/os/linux/kernel/linux/blkdev_compat.h | |
169 | +++ b/include/os/linux/kernel/linux/blkdev_compat.h | |
170 | @@ -592,7 +592,10 @@ blk_generic_start_io_acct(struct request_queue *q __attribute__((unused)), | |
171 | struct gendisk *disk __attribute__((unused)), | |
172 | int rw __attribute__((unused)), struct bio *bio) | |
173 | { | |
174 | -#if defined(HAVE_BDEV_IO_ACCT) | |
175 | +#if defined(HAVE_BDEV_IO_ACCT_63) | |
176 | + return (bdev_start_io_acct(bio->bi_bdev, bio_op(bio), | |
177 | + jiffies)); | |
178 | +#elif defined(HAVE_BDEV_IO_ACCT_OLD) | |
179 | return (bdev_start_io_acct(bio->bi_bdev, bio_sectors(bio), | |
180 | bio_op(bio), jiffies)); | |
181 | #elif defined(HAVE_DISK_IO_ACCT) | |
182 | @@ -618,7 +621,10 @@ blk_generic_end_io_acct(struct request_queue *q __attribute__((unused)), | |
183 | struct gendisk *disk __attribute__((unused)), | |
184 | int rw __attribute__((unused)), struct bio *bio, unsigned long start_time) | |
185 | { | |
186 | -#if defined(HAVE_BDEV_IO_ACCT) | |
187 | +#if defined(HAVE_BDEV_IO_ACCT_63) | |
188 | + bdev_end_io_acct(bio->bi_bdev, bio_op(bio), bio_sectors(bio), | |
189 | + start_time); | |
190 | +#elif defined(HAVE_BDEV_IO_ACCT_OLD) | |
191 | bdev_end_io_acct(bio->bi_bdev, bio_op(bio), start_time); | |
192 | #elif defined(HAVE_DISK_IO_ACCT) | |
193 | disk_end_io_acct(disk, bio_op(bio), start_time); | |
194 | From c5431f14655ce05d1ea99cb012806f0e5873d257 Mon Sep 17 00:00:00 2001 | |
195 | From: youzhongyang <youzhong@gmail.com> | |
196 | Date: Fri, 31 Mar 2023 12:46:22 -0400 | |
197 | Subject: [PATCH] linux 6.3 compat: needs REQ_PREFLUSH | REQ_OP_WRITE | |
198 | ||
199 | Modify bio_set_flush() so if kernel version is >= 4.10, flags | |
200 | REQ_PREFLUSH and REQ_OP_WRITE are set together. | |
201 | ||
202 | Reviewed-by: Tony Hutter <hutter2@llnl.gov> | |
203 | Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> | |
204 | Signed-off-by: Youzhong Yang <yyang@mathworks.com> | |
205 | Closes #14695 | |
206 | --- | |
207 | include/os/linux/kernel/linux/blkdev_compat.h | 2 +- | |
208 | 1 file changed, 1 insertion(+), 1 deletion(-) | |
209 | ||
210 | diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h | |
211 | index c7405ffab8b..c5c6385be6f 100644 | |
212 | --- a/include/os/linux/kernel/linux/blkdev_compat.h | |
213 | +++ b/include/os/linux/kernel/linux/blkdev_compat.h | |
214 | @@ -426,7 +426,7 @@ static inline void | |
215 | bio_set_flush(struct bio *bio) | |
216 | { | |
217 | #if defined(HAVE_REQ_PREFLUSH) /* >= 4.10 */ | |
218 | - bio_set_op_attrs(bio, 0, REQ_PREFLUSH); | |
219 | + bio_set_op_attrs(bio, 0, REQ_PREFLUSH | REQ_OP_WRITE); | |
220 | #elif defined(WRITE_FLUSH_FUA) /* >= 2.6.37 and <= 4.9 */ | |
221 | bio_set_op_attrs(bio, 0, WRITE_FLUSH_FUA); | |
222 | #else |