1 |
commit: 3ec134904b0cebc13533ac81b0841332b1dd2af1 |
2 |
Author: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Sep 5 12:03:09 2022 +0000 |
4 |
Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Sep 5 12:03:09 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=3ec13490 |
7 |
|
8 |
Linux patch 5.15.65 |
9 |
|
10 |
Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org> |
11 |
|
12 |
0000_README | 4 + |
13 |
1064_linux-5.15.65.patch | 4302 ++++++++++++++++++++++++++++++++++++++++++++++ |
14 |
2 files changed, 4306 insertions(+) |
15 |
|
16 |
diff --git a/0000_README b/0000_README |
17 |
index 4b74f06a..079ad2a6 100644 |
18 |
--- a/0000_README |
19 |
+++ b/0000_README |
20 |
@@ -299,6 +299,10 @@ Patch: 1063_linux-5.15.64.patch |
21 |
From: http://www.kernel.org |
22 |
Desc: Linux 5.15.64 |
23 |
|
24 |
+Patch: 1064_linux-5.15.65.patch |
25 |
+From: http://www.kernel.org |
26 |
+Desc: Linux 5.15.65 |
27 |
+ |
28 |
Patch: 1500_XATTR_USER_PREFIX.patch |
29 |
From: https://bugs.gentoo.org/show_bug.cgi?id=470644 |
30 |
Desc: Support for namespace user.pax.* on tmpfs. |
31 |
|
32 |
diff --git a/1064_linux-5.15.65.patch b/1064_linux-5.15.65.patch |
33 |
new file mode 100644 |
34 |
index 00000000..c209655f |
35 |
--- /dev/null |
36 |
+++ b/1064_linux-5.15.65.patch |
37 |
@@ -0,0 +1,4302 @@ |
38 |
+diff --git a/Documentation/arm64/silicon-errata.rst b/Documentation/arm64/silicon-errata.rst |
39 |
+index 7c1750bcc5bd8..46644736e5835 100644 |
40 |
+--- a/Documentation/arm64/silicon-errata.rst |
41 |
++++ b/Documentation/arm64/silicon-errata.rst |
42 |
+@@ -92,6 +92,8 @@ stable kernels. |
43 |
+ +----------------+-----------------+-----------------+-----------------------------+ |
44 |
+ | ARM | Cortex-A77 | #1508412 | ARM64_ERRATUM_1508412 | |
45 |
+ +----------------+-----------------+-----------------+-----------------------------+ |
46 |
++| ARM | Cortex-A510 | #2441009 | ARM64_ERRATUM_2441009 | |
47 |
+++----------------+-----------------+-----------------+-----------------------------+ |
48 |
+ | ARM | Neoverse-N1 | #1188873,1418040| ARM64_ERRATUM_1418040 | |
49 |
+ +----------------+-----------------+-----------------+-----------------------------+ |
50 |
+ | ARM | Neoverse-N1 | #1349291 | N/A | |
51 |
+diff --git a/Makefile b/Makefile |
52 |
+index b2b65f7c168c5..9142dbf41f0d8 100644 |
53 |
+--- a/Makefile |
54 |
++++ b/Makefile |
55 |
+@@ -1,7 +1,7 @@ |
56 |
+ # SPDX-License-Identifier: GPL-2.0 |
57 |
+ VERSION = 5 |
58 |
+ PATCHLEVEL = 15 |
59 |
+-SUBLEVEL = 64 |
60 |
++SUBLEVEL = 65 |
61 |
+ EXTRAVERSION = |
62 |
+ NAME = Trick or Treat |
63 |
+ |
64 |
+diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig |
65 |
+index 69e7e293f72e4..9d80c783142f9 100644 |
66 |
+--- a/arch/arm64/Kconfig |
67 |
++++ b/arch/arm64/Kconfig |
68 |
+@@ -666,6 +666,23 @@ config ARM64_ERRATUM_1508412 |
69 |
+ |
70 |
+ If unsure, say Y. |
71 |
+ |
72 |
++config ARM64_ERRATUM_2441009 |
73 |
++ bool "Cortex-A510: Completion of affected memory accesses might not be guaranteed by completion of a TLBI" |
74 |
++ default y |
75 |
++ select ARM64_WORKAROUND_REPEAT_TLBI |
76 |
++ help |
77 |
++ This option adds a workaround for ARM Cortex-A510 erratum #2441009. |
78 |
++ |
79 |
++ Under very rare circumstances, affected Cortex-A510 CPUs |
80 |
++ may not handle a race between a break-before-make sequence on one |
81 |
++ CPU, and another CPU accessing the same page. This could allow a |
82 |
++ store to a page that has been unmapped. |
83 |
++ |
84 |
++ Work around this by adding the affected CPUs to the list that needs |
85 |
++ TLB sequences to be done twice. |
86 |
++ |
87 |
++ If unsure, say Y. |
88 |
++ |
89 |
+ config CAVIUM_ERRATUM_22375 |
90 |
+ bool "Cavium erratum 22375, 24313" |
91 |
+ default y |
92 |
+diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c |
93 |
+index 292a3091b5dee..23c57e0a7fd14 100644 |
94 |
+--- a/arch/arm64/kernel/cpu_errata.c |
95 |
++++ b/arch/arm64/kernel/cpu_errata.c |
96 |
+@@ -213,6 +213,12 @@ static const struct arm64_cpu_capabilities arm64_repeat_tlbi_list[] = { |
97 |
+ /* Kryo4xx Gold (rcpe to rfpe) => (r0p0 to r3p0) */ |
98 |
+ ERRATA_MIDR_RANGE(MIDR_QCOM_KRYO_4XX_GOLD, 0xc, 0xe, 0xf, 0xe), |
99 |
+ }, |
100 |
++#endif |
101 |
++#ifdef CONFIG_ARM64_ERRATUM_2441009 |
102 |
++ { |
103 |
++ /* Cortex-A510 r0p0 -> r1p1. Fixed in r1p2 */ |
104 |
++ ERRATA_MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1), |
105 |
++ }, |
106 |
+ #endif |
107 |
+ {}, |
108 |
+ }; |
109 |
+@@ -429,7 +435,7 @@ const struct arm64_cpu_capabilities arm64_errata[] = { |
110 |
+ #endif |
111 |
+ #ifdef CONFIG_ARM64_WORKAROUND_REPEAT_TLBI |
112 |
+ { |
113 |
+- .desc = "Qualcomm erratum 1009, or ARM erratum 1286807", |
114 |
++ .desc = "Qualcomm erratum 1009, or ARM erratum 1286807, 2441009", |
115 |
+ .capability = ARM64_WORKAROUND_REPEAT_TLBI, |
116 |
+ .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, |
117 |
+ .matches = cpucap_multi_entry_cap_matches, |
118 |
+diff --git a/arch/s390/hypfs/hypfs_diag.c b/arch/s390/hypfs/hypfs_diag.c |
119 |
+index f0bc4dc3e9bf0..6511d15ace45e 100644 |
120 |
+--- a/arch/s390/hypfs/hypfs_diag.c |
121 |
++++ b/arch/s390/hypfs/hypfs_diag.c |
122 |
+@@ -437,7 +437,7 @@ __init int hypfs_diag_init(void) |
123 |
+ int rc; |
124 |
+ |
125 |
+ if (diag204_probe()) { |
126 |
+- pr_err("The hardware system does not support hypfs\n"); |
127 |
++ pr_info("The hardware system does not support hypfs\n"); |
128 |
+ return -ENODATA; |
129 |
+ } |
130 |
+ |
131 |
+diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c |
132 |
+index 5c97f48cea91d..ee919bfc81867 100644 |
133 |
+--- a/arch/s390/hypfs/inode.c |
134 |
++++ b/arch/s390/hypfs/inode.c |
135 |
+@@ -496,9 +496,9 @@ fail_hypfs_sprp_exit: |
136 |
+ hypfs_vm_exit(); |
137 |
+ fail_hypfs_diag_exit: |
138 |
+ hypfs_diag_exit(); |
139 |
++ pr_err("Initialization of hypfs failed with rc=%i\n", rc); |
140 |
+ fail_dbfs_exit: |
141 |
+ hypfs_dbfs_exit(); |
142 |
+- pr_err("Initialization of hypfs failed with rc=%i\n", rc); |
143 |
+ return rc; |
144 |
+ } |
145 |
+ device_initcall(hypfs_init) |
146 |
+diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c |
147 |
+index 95105db642b98..155bbabcc6f5d 100644 |
148 |
+--- a/drivers/acpi/thermal.c |
149 |
++++ b/drivers/acpi/thermal.c |
150 |
+@@ -1098,8 +1098,6 @@ static int acpi_thermal_resume(struct device *dev) |
151 |
+ return -EINVAL; |
152 |
+ |
153 |
+ for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { |
154 |
+- if (!(&tz->trips.active[i])) |
155 |
+- break; |
156 |
+ if (!tz->trips.active[i].flags.valid) |
157 |
+ break; |
158 |
+ tz->trips.active[i].flags.enabled = 1; |
159 |
+diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c |
160 |
+index bd827533e7e83..f2d9587833d4b 100644 |
161 |
+--- a/drivers/android/binder_alloc.c |
162 |
++++ b/drivers/android/binder_alloc.c |
163 |
+@@ -315,12 +315,19 @@ static inline void binder_alloc_set_vma(struct binder_alloc *alloc, |
164 |
+ { |
165 |
+ unsigned long vm_start = 0; |
166 |
+ |
167 |
++ /* |
168 |
++ * Allow clearing the vma with holding just the read lock to allow |
169 |
++ * munmapping downgrade of the write lock before freeing and closing the |
170 |
++ * file using binder_alloc_vma_close(). |
171 |
++ */ |
172 |
+ if (vma) { |
173 |
+ vm_start = vma->vm_start; |
174 |
+ alloc->vma_vm_mm = vma->vm_mm; |
175 |
++ mmap_assert_write_locked(alloc->vma_vm_mm); |
176 |
++ } else { |
177 |
++ mmap_assert_locked(alloc->vma_vm_mm); |
178 |
+ } |
179 |
+ |
180 |
+- mmap_assert_write_locked(alloc->vma_vm_mm); |
181 |
+ alloc->vma_addr = vm_start; |
182 |
+ } |
183 |
+ |
184 |
+diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c |
185 |
+index 9631f2fd2faf7..38e8767ec3715 100644 |
186 |
+--- a/drivers/dma-buf/udmabuf.c |
187 |
++++ b/drivers/dma-buf/udmabuf.c |
188 |
+@@ -368,7 +368,23 @@ static struct miscdevice udmabuf_misc = { |
189 |
+ |
190 |
+ static int __init udmabuf_dev_init(void) |
191 |
+ { |
192 |
+- return misc_register(&udmabuf_misc); |
193 |
++ int ret; |
194 |
++ |
195 |
++ ret = misc_register(&udmabuf_misc); |
196 |
++ if (ret < 0) { |
197 |
++ pr_err("Could not initialize udmabuf device\n"); |
198 |
++ return ret; |
199 |
++ } |
200 |
++ |
201 |
++ ret = dma_coerce_mask_and_coherent(udmabuf_misc.this_device, |
202 |
++ DMA_BIT_MASK(64)); |
203 |
++ if (ret < 0) { |
204 |
++ pr_err("Could not setup DMA mask for udmabuf device\n"); |
205 |
++ misc_deregister(&udmabuf_misc); |
206 |
++ return ret; |
207 |
++ } |
208 |
++ |
209 |
++ return 0; |
210 |
+ } |
211 |
+ |
212 |
+ static void __exit udmabuf_dev_exit(void) |
213 |
+diff --git a/drivers/firmware/tegra/bpmp.c b/drivers/firmware/tegra/bpmp.c |
214 |
+index 5654c5e9862b1..037db21de510c 100644 |
215 |
+--- a/drivers/firmware/tegra/bpmp.c |
216 |
++++ b/drivers/firmware/tegra/bpmp.c |
217 |
+@@ -201,7 +201,7 @@ static ssize_t __tegra_bpmp_channel_read(struct tegra_bpmp_channel *channel, |
218 |
+ int err; |
219 |
+ |
220 |
+ if (data && size > 0) |
221 |
+- memcpy(data, channel->ib->data, size); |
222 |
++ memcpy_fromio(data, channel->ib->data, size); |
223 |
+ |
224 |
+ err = tegra_bpmp_ack_response(channel); |
225 |
+ if (err < 0) |
226 |
+@@ -245,7 +245,7 @@ static ssize_t __tegra_bpmp_channel_write(struct tegra_bpmp_channel *channel, |
227 |
+ channel->ob->flags = flags; |
228 |
+ |
229 |
+ if (data && size > 0) |
230 |
+- memcpy(channel->ob->data, data, size); |
231 |
++ memcpy_toio(channel->ob->data, data, size); |
232 |
+ |
233 |
+ return tegra_bpmp_post_request(channel); |
234 |
+ } |
235 |
+@@ -420,7 +420,7 @@ void tegra_bpmp_mrq_return(struct tegra_bpmp_channel *channel, int code, |
236 |
+ channel->ob->code = code; |
237 |
+ |
238 |
+ if (data && size > 0) |
239 |
+- memcpy(channel->ob->data, data, size); |
240 |
++ memcpy_toio(channel->ob->data, data, size); |
241 |
+ |
242 |
+ err = tegra_bpmp_post_response(channel); |
243 |
+ if (WARN_ON(err < 0)) |
244 |
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h |
245 |
+index 5f95d03fd46a0..4f62f422bcb78 100644 |
246 |
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h |
247 |
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h |
248 |
+@@ -312,7 +312,7 @@ enum amdgpu_kiq_irq { |
249 |
+ AMDGPU_CP_KIQ_IRQ_DRIVER0 = 0, |
250 |
+ AMDGPU_CP_KIQ_IRQ_LAST |
251 |
+ }; |
252 |
+- |
253 |
++#define SRIOV_USEC_TIMEOUT 1200000 /* wait 12 * 100ms for SRIOV */ |
254 |
+ #define MAX_KIQ_REG_WAIT 5000 /* in usecs, 5ms */ |
255 |
+ #define MAX_KIQ_REG_BAILOUT_INTERVAL 5 /* in msecs, 5ms */ |
256 |
+ #define MAX_KIQ_REG_TRY 1000 |
257 |
+diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c |
258 |
+index 93a4da4284ede..9c07ec8b97327 100644 |
259 |
+--- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c |
260 |
++++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c |
261 |
+@@ -414,6 +414,7 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, |
262 |
+ uint32_t seq; |
263 |
+ uint16_t queried_pasid; |
264 |
+ bool ret; |
265 |
++ u32 usec_timeout = amdgpu_sriov_vf(adev) ? SRIOV_USEC_TIMEOUT : adev->usec_timeout; |
266 |
+ struct amdgpu_ring *ring = &adev->gfx.kiq.ring; |
267 |
+ struct amdgpu_kiq *kiq = &adev->gfx.kiq; |
268 |
+ |
269 |
+@@ -432,7 +433,7 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, |
270 |
+ |
271 |
+ amdgpu_ring_commit(ring); |
272 |
+ spin_unlock(&adev->gfx.kiq.ring_lock); |
273 |
+- r = amdgpu_fence_wait_polling(ring, seq, adev->usec_timeout); |
274 |
++ r = amdgpu_fence_wait_polling(ring, seq, usec_timeout); |
275 |
+ if (r < 1) { |
276 |
+ dev_err(adev->dev, "wait for kiq fence error: %ld.\n", r); |
277 |
+ return -ETIME; |
278 |
+diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c |
279 |
+index 0e731016921be..70d24b522df8d 100644 |
280 |
+--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c |
281 |
++++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c |
282 |
+@@ -863,6 +863,7 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, |
283 |
+ uint32_t seq; |
284 |
+ uint16_t queried_pasid; |
285 |
+ bool ret; |
286 |
++ u32 usec_timeout = amdgpu_sriov_vf(adev) ? SRIOV_USEC_TIMEOUT : adev->usec_timeout; |
287 |
+ struct amdgpu_ring *ring = &adev->gfx.kiq.ring; |
288 |
+ struct amdgpu_kiq *kiq = &adev->gfx.kiq; |
289 |
+ |
290 |
+@@ -902,7 +903,7 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, |
291 |
+ |
292 |
+ amdgpu_ring_commit(ring); |
293 |
+ spin_unlock(&adev->gfx.kiq.ring_lock); |
294 |
+- r = amdgpu_fence_wait_polling(ring, seq, adev->usec_timeout); |
295 |
++ r = amdgpu_fence_wait_polling(ring, seq, usec_timeout); |
296 |
+ if (r < 1) { |
297 |
+ dev_err(adev->dev, "wait for kiq fence error: %ld.\n", r); |
298 |
+ up_read(&adev->reset_sem); |
299 |
+diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c |
300 |
+index 054823d12403d..5f1b735da5063 100644 |
301 |
+--- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c |
302 |
++++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c |
303 |
+@@ -545,9 +545,11 @@ static void dce112_get_pix_clk_dividers_helper ( |
304 |
+ switch (pix_clk_params->color_depth) { |
305 |
+ case COLOR_DEPTH_101010: |
306 |
+ actual_pixel_clock_100hz = (actual_pixel_clock_100hz * 5) >> 2; |
307 |
++ actual_pixel_clock_100hz -= actual_pixel_clock_100hz % 10; |
308 |
+ break; |
309 |
+ case COLOR_DEPTH_121212: |
310 |
+ actual_pixel_clock_100hz = (actual_pixel_clock_100hz * 6) >> 2; |
311 |
++ actual_pixel_clock_100hz -= actual_pixel_clock_100hz % 10; |
312 |
+ break; |
313 |
+ case COLOR_DEPTH_161616: |
314 |
+ actual_pixel_clock_100hz = actual_pixel_clock_100hz * 2; |
315 |
+diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c |
316 |
+index 11019c2c62ccb..8192f1967e924 100644 |
317 |
+--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c |
318 |
++++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c |
319 |
+@@ -126,6 +126,12 @@ struct mpcc *mpc1_get_mpcc_for_dpp(struct mpc_tree *tree, int dpp_id) |
320 |
+ while (tmp_mpcc != NULL) { |
321 |
+ if (tmp_mpcc->dpp_id == dpp_id) |
322 |
+ return tmp_mpcc; |
323 |
++ |
324 |
++ /* avoid circular linked list */ |
325 |
++ ASSERT(tmp_mpcc != tmp_mpcc->mpcc_bot); |
326 |
++ if (tmp_mpcc == tmp_mpcc->mpcc_bot) |
327 |
++ break; |
328 |
++ |
329 |
+ tmp_mpcc = tmp_mpcc->mpcc_bot; |
330 |
+ } |
331 |
+ return NULL; |
332 |
+diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c |
333 |
+index 37848f4577b18..92fee47278e5a 100644 |
334 |
+--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c |
335 |
++++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c |
336 |
+@@ -480,6 +480,11 @@ void optc1_enable_optc_clock(struct timing_generator *optc, bool enable) |
337 |
+ OTG_CLOCK_ON, 1, |
338 |
+ 1, 1000); |
339 |
+ } else { |
340 |
++ |
341 |
++ //last chance to clear underflow, otherwise, it will always there due to clock is off. |
342 |
++ if (optc->funcs->is_optc_underflow_occurred(optc) == true) |
343 |
++ optc->funcs->clear_optc_underflow(optc); |
344 |
++ |
345 |
+ REG_UPDATE_2(OTG_CLOCK_CONTROL, |
346 |
+ OTG_CLOCK_GATE_DIS, 0, |
347 |
+ OTG_CLOCK_EN, 0); |
348 |
+diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mpc.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mpc.c |
349 |
+index 947eb0df3f125..142fc0a3a536c 100644 |
350 |
+--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mpc.c |
351 |
++++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mpc.c |
352 |
+@@ -532,6 +532,12 @@ struct mpcc *mpc2_get_mpcc_for_dpp(struct mpc_tree *tree, int dpp_id) |
353 |
+ while (tmp_mpcc != NULL) { |
354 |
+ if (tmp_mpcc->dpp_id == 0xf || tmp_mpcc->dpp_id == dpp_id) |
355 |
+ return tmp_mpcc; |
356 |
++ |
357 |
++ /* avoid circular linked list */ |
358 |
++ ASSERT(tmp_mpcc != tmp_mpcc->mpcc_bot); |
359 |
++ if (tmp_mpcc == tmp_mpcc->mpcc_bot) |
360 |
++ break; |
361 |
++ |
362 |
+ tmp_mpcc = tmp_mpcc->mpcc_bot; |
363 |
+ } |
364 |
+ return NULL; |
365 |
+diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c |
366 |
+index 36044cb8ec834..1c0f56d8ba8bb 100644 |
367 |
+--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c |
368 |
++++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c |
369 |
+@@ -67,9 +67,15 @@ static uint32_t convert_and_clamp( |
370 |
+ void dcn21_dchvm_init(struct hubbub *hubbub) |
371 |
+ { |
372 |
+ struct dcn20_hubbub *hubbub1 = TO_DCN20_HUBBUB(hubbub); |
373 |
+- uint32_t riommu_active; |
374 |
++ uint32_t riommu_active, prefetch_done; |
375 |
+ int i; |
376 |
+ |
377 |
++ REG_GET(DCHVM_RIOMMU_STAT0, HOSTVM_PREFETCH_DONE, &prefetch_done); |
378 |
++ |
379 |
++ if (prefetch_done) { |
380 |
++ hubbub->riommu_active = true; |
381 |
++ return; |
382 |
++ } |
383 |
+ //Init DCHVM block |
384 |
+ REG_UPDATE(DCHVM_CTRL0, HOSTVM_INIT_REQ, 1); |
385 |
+ |
386 |
+diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hubp.c b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hubp.c |
387 |
+index f246125232482..33c2337c4edf3 100644 |
388 |
+--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hubp.c |
389 |
++++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hubp.c |
390 |
+@@ -86,7 +86,7 @@ bool hubp3_program_surface_flip_and_addr( |
391 |
+ VMID, address->vmid); |
392 |
+ |
393 |
+ if (address->type == PLN_ADDR_TYPE_GRPH_STEREO) { |
394 |
+- REG_UPDATE(DCSURF_FLIP_CONTROL, SURFACE_FLIP_MODE_FOR_STEREOSYNC, 0x1); |
395 |
++ REG_UPDATE(DCSURF_FLIP_CONTROL, SURFACE_FLIP_MODE_FOR_STEREOSYNC, 0); |
396 |
+ REG_UPDATE(DCSURF_FLIP_CONTROL, SURFACE_FLIP_IN_STEREOSYNC, 0x1); |
397 |
+ |
398 |
+ } else { |
399 |
+diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c |
400 |
+index b99aa232bd8b1..4bee6d018bfa9 100644 |
401 |
+--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c |
402 |
++++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c |
403 |
+@@ -567,10 +567,6 @@ static void build_vrr_infopacket_data_v1(const struct mod_vrr_params *vrr, |
404 |
+ * Note: We should never go above the field rate of the mode timing set. |
405 |
+ */ |
406 |
+ infopacket->sb[8] = (unsigned char)((vrr->max_refresh_in_uhz + 500000) / 1000000); |
407 |
+- |
408 |
+- /* FreeSync HDR */ |
409 |
+- infopacket->sb[9] = 0; |
410 |
+- infopacket->sb[10] = 0; |
411 |
+ } |
412 |
+ |
413 |
+ static void build_vrr_infopacket_data_v3(const struct mod_vrr_params *vrr, |
414 |
+@@ -638,10 +634,6 @@ static void build_vrr_infopacket_data_v3(const struct mod_vrr_params *vrr, |
415 |
+ |
416 |
+ /* PB16 : Reserved bits 7:1, FixedRate bit 0 */ |
417 |
+ infopacket->sb[16] = (vrr->state == VRR_STATE_ACTIVE_FIXED) ? 1 : 0; |
418 |
+- |
419 |
+- //FreeSync HDR |
420 |
+- infopacket->sb[9] = 0; |
421 |
+- infopacket->sb[10] = 0; |
422 |
+ } |
423 |
+ |
424 |
+ static void build_vrr_infopacket_fs2_data(enum color_transfer_func app_tf, |
425 |
+@@ -726,8 +718,7 @@ static void build_vrr_infopacket_header_v2(enum signal_type signal, |
426 |
+ /* HB2 = [Bits 7:5 = 0] [Bits 4:0 = Length = 0x09] */ |
427 |
+ infopacket->hb2 = 0x09; |
428 |
+ |
429 |
+- *payload_size = 0x0A; |
430 |
+- |
431 |
++ *payload_size = 0x09; |
432 |
+ } else if (dc_is_dp_signal(signal)) { |
433 |
+ |
434 |
+ /* HEADER */ |
435 |
+@@ -776,9 +767,9 @@ static void build_vrr_infopacket_header_v3(enum signal_type signal, |
436 |
+ infopacket->hb1 = version; |
437 |
+ |
438 |
+ /* HB2 = [Bits 7:5 = 0] [Bits 4:0 = Length] */ |
439 |
+- *payload_size = 0x10; |
440 |
+- infopacket->hb2 = *payload_size - 1; //-1 for checksum |
441 |
++ infopacket->hb2 = 0x10; |
442 |
+ |
443 |
++ *payload_size = 0x10; |
444 |
+ } else if (dc_is_dp_signal(signal)) { |
445 |
+ |
446 |
+ /* HEADER */ |
447 |
+diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c |
448 |
+index 918d5c7c2328b..79976921dc46f 100644 |
449 |
+--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c |
450 |
++++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c |
451 |
+@@ -3915,6 +3915,7 @@ static const struct pptable_funcs sienna_cichlid_ppt_funcs = { |
452 |
+ .dump_pptable = sienna_cichlid_dump_pptable, |
453 |
+ .init_microcode = smu_v11_0_init_microcode, |
454 |
+ .load_microcode = smu_v11_0_load_microcode, |
455 |
++ .fini_microcode = smu_v11_0_fini_microcode, |
456 |
+ .init_smc_tables = sienna_cichlid_init_smc_tables, |
457 |
+ .fini_smc_tables = smu_v11_0_fini_smc_tables, |
458 |
+ .init_power = smu_v11_0_init_power, |
459 |
+diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c b/drivers/gpu/drm/i915/gt/intel_gt.c |
460 |
+index 3a76000d15bfd..ed8ad3b263959 100644 |
461 |
+--- a/drivers/gpu/drm/i915/gt/intel_gt.c |
462 |
++++ b/drivers/gpu/drm/i915/gt/intel_gt.c |
463 |
+@@ -949,6 +949,9 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt) |
464 |
+ if (I915_SELFTEST_ONLY(gt->awake == -ENODEV)) |
465 |
+ return; |
466 |
+ |
467 |
++ if (intel_gt_is_wedged(gt)) |
468 |
++ return; |
469 |
++ |
470 |
+ if (GRAPHICS_VER(i915) == 12) { |
471 |
+ regs = gen12_regs; |
472 |
+ num = ARRAY_SIZE(gen12_regs); |
473 |
+diff --git a/drivers/gpu/drm/vc4/Kconfig b/drivers/gpu/drm/vc4/Kconfig |
474 |
+index 345a5570a3da7..e2c147d4015ef 100644 |
475 |
+--- a/drivers/gpu/drm/vc4/Kconfig |
476 |
++++ b/drivers/gpu/drm/vc4/Kconfig |
477 |
+@@ -5,6 +5,7 @@ config DRM_VC4 |
478 |
+ depends on DRM |
479 |
+ depends on SND && SND_SOC |
480 |
+ depends on COMMON_CLK |
481 |
++ depends on PM |
482 |
+ select DRM_KMS_HELPER |
483 |
+ select DRM_KMS_CMA_HELPER |
484 |
+ select DRM_GEM_CMA_HELPER |
485 |
+diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c |
486 |
+index 10cf623d28303..9b3e642a08e1a 100644 |
487 |
+--- a/drivers/gpu/drm/vc4/vc4_hdmi.c |
488 |
++++ b/drivers/gpu/drm/vc4/vc4_hdmi.c |
489 |
+@@ -2122,7 +2122,7 @@ static int vc5_hdmi_init_resources(struct vc4_hdmi *vc4_hdmi) |
490 |
+ return 0; |
491 |
+ } |
492 |
+ |
493 |
+-static int __maybe_unused vc4_hdmi_runtime_suspend(struct device *dev) |
494 |
++static int vc4_hdmi_runtime_suspend(struct device *dev) |
495 |
+ { |
496 |
+ struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); |
497 |
+ |
498 |
+@@ -2219,17 +2219,15 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) |
499 |
+ if (ret) |
500 |
+ goto err_put_ddc; |
501 |
+ |
502 |
++ pm_runtime_enable(dev); |
503 |
++ |
504 |
+ /* |
505 |
+- * We need to have the device powered up at this point to call |
506 |
+- * our reset hook and for the CEC init. |
507 |
++ * We need to have the device powered up at this point to call |
508 |
++ * our reset hook and for the CEC init. |
509 |
+ */ |
510 |
+- ret = vc4_hdmi_runtime_resume(dev); |
511 |
++ ret = pm_runtime_resume_and_get(dev); |
512 |
+ if (ret) |
513 |
+- goto err_put_ddc; |
514 |
+- |
515 |
+- pm_runtime_get_noresume(dev); |
516 |
+- pm_runtime_set_active(dev); |
517 |
+- pm_runtime_enable(dev); |
518 |
++ goto err_disable_runtime_pm; |
519 |
+ |
520 |
+ if (vc4_hdmi->variant->reset) |
521 |
+ vc4_hdmi->variant->reset(vc4_hdmi); |
522 |
+@@ -2278,6 +2276,7 @@ err_destroy_conn: |
523 |
+ err_destroy_encoder: |
524 |
+ drm_encoder_cleanup(encoder); |
525 |
+ pm_runtime_put_sync(dev); |
526 |
++err_disable_runtime_pm: |
527 |
+ pm_runtime_disable(dev); |
528 |
+ err_put_ddc: |
529 |
+ put_device(&vc4_hdmi->ddc->dev); |
530 |
+diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c |
531 |
+index 13a4db42cd7a7..f17f061aeb792 100644 |
532 |
+--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c |
533 |
++++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c |
534 |
+@@ -281,11 +281,29 @@ static int amd_sfh_irq_init(struct amd_mp2_dev *privdata) |
535 |
+ return 0; |
536 |
+ } |
537 |
+ |
538 |
++static const struct dmi_system_id dmi_nodevs[] = { |
539 |
++ { |
540 |
++ /* |
541 |
++ * Google Chromebooks use Chrome OS Embedded Controller Sensor |
542 |
++ * Hub instead of Sensor Hub Fusion and leaves MP2 |
543 |
++ * uninitialized, which disables all functionalities, even |
544 |
++ * including the registers necessary for feature detections. |
545 |
++ */ |
546 |
++ .matches = { |
547 |
++ DMI_MATCH(DMI_SYS_VENDOR, "Google"), |
548 |
++ }, |
549 |
++ }, |
550 |
++ { } |
551 |
++}; |
552 |
++ |
553 |
+ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
554 |
+ { |
555 |
+ struct amd_mp2_dev *privdata; |
556 |
+ int rc; |
557 |
+ |
558 |
++ if (dmi_first_match(dmi_nodevs)) |
559 |
++ return -ENODEV; |
560 |
++ |
561 |
+ privdata = devm_kzalloc(&pdev->dev, sizeof(*privdata), GFP_KERNEL); |
562 |
+ if (!privdata) |
563 |
+ return -ENOMEM; |
564 |
+diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c |
565 |
+index 08c9a9a60ae47..b59c3dafa6a48 100644 |
566 |
+--- a/drivers/hid/hid-asus.c |
567 |
++++ b/drivers/hid/hid-asus.c |
568 |
+@@ -1212,6 +1212,13 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc, |
569 |
+ rdesc = new_rdesc; |
570 |
+ } |
571 |
+ |
572 |
++ if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD && |
573 |
++ *rsize == 331 && rdesc[190] == 0x85 && rdesc[191] == 0x5a && |
574 |
++ rdesc[204] == 0x95 && rdesc[205] == 0x05) { |
575 |
++ hid_info(hdev, "Fixing up Asus N-KEY keyb report descriptor\n"); |
576 |
++ rdesc[205] = 0x01; |
577 |
++ } |
578 |
++ |
579 |
+ return rdesc; |
580 |
+ } |
581 |
+ |
582 |
+diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h |
583 |
+index ceaa36fc429ef..cb2b48d6915ee 100644 |
584 |
+--- a/drivers/hid/hid-ids.h |
585 |
++++ b/drivers/hid/hid-ids.h |
586 |
+@@ -399,6 +399,7 @@ |
587 |
+ #define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN 0x2706 |
588 |
+ #define I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN 0x261A |
589 |
+ #define I2C_DEVICE_ID_SURFACE_GO2_TOUCHSCREEN 0x2A1C |
590 |
++#define I2C_DEVICE_ID_LENOVO_YOGA_C630_TOUCHSCREEN 0x279F |
591 |
+ |
592 |
+ #define USB_VENDOR_ID_ELECOM 0x056e |
593 |
+ #define USB_DEVICE_ID_ELECOM_BM084 0x0061 |
594 |
+diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c |
595 |
+index 125043a28a35c..f197aed6444a5 100644 |
596 |
+--- a/drivers/hid/hid-input.c |
597 |
++++ b/drivers/hid/hid-input.c |
598 |
+@@ -335,6 +335,8 @@ static const struct hid_device_id hid_battery_quirks[] = { |
599 |
+ HID_BATTERY_QUIRK_IGNORE }, |
600 |
+ { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO2_TOUCHSCREEN), |
601 |
+ HID_BATTERY_QUIRK_IGNORE }, |
602 |
++ { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_LENOVO_YOGA_C630_TOUCHSCREEN), |
603 |
++ HID_BATTERY_QUIRK_IGNORE }, |
604 |
+ {} |
605 |
+ }; |
606 |
+ |
607 |
+diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c |
608 |
+index a3b151b29bd71..fc616db4231bb 100644 |
609 |
+--- a/drivers/hid/hid-steam.c |
610 |
++++ b/drivers/hid/hid-steam.c |
611 |
+@@ -134,6 +134,11 @@ static int steam_recv_report(struct steam_device *steam, |
612 |
+ int ret; |
613 |
+ |
614 |
+ r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0]; |
615 |
++ if (!r) { |
616 |
++ hid_err(steam->hdev, "No HID_FEATURE_REPORT submitted - nothing to read\n"); |
617 |
++ return -EINVAL; |
618 |
++ } |
619 |
++ |
620 |
+ if (hid_report_len(r) < 64) |
621 |
+ return -EINVAL; |
622 |
+ |
623 |
+@@ -165,6 +170,11 @@ static int steam_send_report(struct steam_device *steam, |
624 |
+ int ret; |
625 |
+ |
626 |
+ r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0]; |
627 |
++ if (!r) { |
628 |
++ hid_err(steam->hdev, "No HID_FEATURE_REPORT submitted - nothing to read\n"); |
629 |
++ return -EINVAL; |
630 |
++ } |
631 |
++ |
632 |
+ if (hid_report_len(r) < 64) |
633 |
+ return -EINVAL; |
634 |
+ |
635 |
+diff --git a/drivers/hid/hid-thrustmaster.c b/drivers/hid/hid-thrustmaster.c |
636 |
+index a28c3e5756506..2221bc26e611a 100644 |
637 |
+--- a/drivers/hid/hid-thrustmaster.c |
638 |
++++ b/drivers/hid/hid-thrustmaster.c |
639 |
+@@ -67,12 +67,13 @@ static const struct tm_wheel_info tm_wheels_infos[] = { |
640 |
+ {0x0200, 0x0005, "Thrustmaster T300RS (Missing Attachment)"}, |
641 |
+ {0x0206, 0x0005, "Thrustmaster T300RS"}, |
642 |
+ {0x0209, 0x0005, "Thrustmaster T300RS (Open Wheel Attachment)"}, |
643 |
++ {0x020a, 0x0005, "Thrustmaster T300RS (Sparco R383 Mod)"}, |
644 |
+ {0x0204, 0x0005, "Thrustmaster T300 Ferrari Alcantara Edition"}, |
645 |
+ {0x0002, 0x0002, "Thrustmaster T500RS"} |
646 |
+ //{0x0407, 0x0001, "Thrustmaster TMX"} |
647 |
+ }; |
648 |
+ |
649 |
+-static const uint8_t tm_wheels_infos_length = 4; |
650 |
++static const uint8_t tm_wheels_infos_length = 7; |
651 |
+ |
652 |
+ /* |
653 |
+ * This structs contains (in little endian) the response data |
654 |
+diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c |
655 |
+index 79faac87a06ff..11b0ed4f3f8cc 100644 |
656 |
+--- a/drivers/hid/hidraw.c |
657 |
++++ b/drivers/hid/hidraw.c |
658 |
+@@ -346,10 +346,13 @@ static int hidraw_release(struct inode * inode, struct file * file) |
659 |
+ unsigned int minor = iminor(inode); |
660 |
+ struct hidraw_list *list = file->private_data; |
661 |
+ unsigned long flags; |
662 |
++ int i; |
663 |
+ |
664 |
+ mutex_lock(&minors_lock); |
665 |
+ |
666 |
+ spin_lock_irqsave(&hidraw_table[minor]->list_lock, flags); |
667 |
++ for (i = list->tail; i < list->head; i++) |
668 |
++ kfree(list->buffer[i].value); |
669 |
+ list_del(&list->node); |
670 |
+ spin_unlock_irqrestore(&hidraw_table[minor]->list_lock, flags); |
671 |
+ kfree(list); |
672 |
+diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c |
673 |
+index 3cf334c46c312..3248b48f37f61 100644 |
674 |
+--- a/drivers/hv/hv_balloon.c |
675 |
++++ b/drivers/hv/hv_balloon.c |
676 |
+@@ -17,6 +17,7 @@ |
677 |
+ #include <linux/slab.h> |
678 |
+ #include <linux/kthread.h> |
679 |
+ #include <linux/completion.h> |
680 |
++#include <linux/count_zeros.h> |
681 |
+ #include <linux/memory_hotplug.h> |
682 |
+ #include <linux/memory.h> |
683 |
+ #include <linux/notifier.h> |
684 |
+@@ -1130,6 +1131,7 @@ static void post_status(struct hv_dynmem_device *dm) |
685 |
+ struct dm_status status; |
686 |
+ unsigned long now = jiffies; |
687 |
+ unsigned long last_post = last_post_time; |
688 |
++ unsigned long num_pages_avail, num_pages_committed; |
689 |
+ |
690 |
+ if (pressure_report_delay > 0) { |
691 |
+ --pressure_report_delay; |
692 |
+@@ -1154,16 +1156,21 @@ static void post_status(struct hv_dynmem_device *dm) |
693 |
+ * num_pages_onlined) as committed to the host, otherwise it can try |
694 |
+ * asking us to balloon them out. |
695 |
+ */ |
696 |
+- status.num_avail = si_mem_available(); |
697 |
+- status.num_committed = vm_memory_committed() + |
698 |
++ num_pages_avail = si_mem_available(); |
699 |
++ num_pages_committed = vm_memory_committed() + |
700 |
+ dm->num_pages_ballooned + |
701 |
+ (dm->num_pages_added > dm->num_pages_onlined ? |
702 |
+ dm->num_pages_added - dm->num_pages_onlined : 0) + |
703 |
+ compute_balloon_floor(); |
704 |
+ |
705 |
+- trace_balloon_status(status.num_avail, status.num_committed, |
706 |
++ trace_balloon_status(num_pages_avail, num_pages_committed, |
707 |
+ vm_memory_committed(), dm->num_pages_ballooned, |
708 |
+ dm->num_pages_added, dm->num_pages_onlined); |
709 |
++ |
710 |
++ /* Convert numbers of pages into numbers of HV_HYP_PAGEs. */ |
711 |
++ status.num_avail = num_pages_avail * NR_HV_HYP_PAGES_IN_PAGE; |
712 |
++ status.num_committed = num_pages_committed * NR_HV_HYP_PAGES_IN_PAGE; |
713 |
++ |
714 |
+ /* |
715 |
+ * If our transaction ID is no longer current, just don't |
716 |
+ * send the status. This can happen if we were interrupted |
717 |
+diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c |
718 |
+index fccd1798445d5..d22ce328a2797 100644 |
719 |
+--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c |
720 |
++++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c |
721 |
+@@ -2610,6 +2610,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, |
722 |
+ del_timer_sync(&hdw->encoder_run_timer); |
723 |
+ del_timer_sync(&hdw->encoder_wait_timer); |
724 |
+ flush_work(&hdw->workpoll); |
725 |
++ v4l2_device_unregister(&hdw->v4l2_dev); |
726 |
+ usb_free_urb(hdw->ctl_read_urb); |
727 |
+ usb_free_urb(hdw->ctl_write_urb); |
728 |
+ kfree(hdw->ctl_read_buffer); |
729 |
+diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c |
730 |
+index f9b2897569bb4..99d8881a7d6c2 100644 |
731 |
+--- a/drivers/mmc/host/mtk-sd.c |
732 |
++++ b/drivers/mmc/host/mtk-sd.c |
733 |
+@@ -2345,6 +2345,9 @@ static void msdc_cqe_disable(struct mmc_host *mmc, bool recovery) |
734 |
+ /* disable busy check */ |
735 |
+ sdr_clr_bits(host->base + MSDC_PATCH_BIT1, MSDC_PB1_BUSY_CHECK_SEL); |
736 |
+ |
737 |
++ val = readl(host->base + MSDC_INT); |
738 |
++ writel(val, host->base + MSDC_INT); |
739 |
++ |
740 |
+ if (recovery) { |
741 |
+ sdr_set_field(host->base + MSDC_DMA_CTRL, |
742 |
+ MSDC_DMA_CTRL_STOP, 1); |
743 |
+@@ -2785,11 +2788,14 @@ static int __maybe_unused msdc_suspend(struct device *dev) |
744 |
+ { |
745 |
+ struct mmc_host *mmc = dev_get_drvdata(dev); |
746 |
+ int ret; |
747 |
++ u32 val; |
748 |
+ |
749 |
+ if (mmc->caps2 & MMC_CAP2_CQE) { |
750 |
+ ret = cqhci_suspend(mmc); |
751 |
+ if (ret) |
752 |
+ return ret; |
753 |
++ val = readl(((struct msdc_host *)mmc_priv(mmc))->base + MSDC_INT); |
754 |
++ writel(val, ((struct msdc_host *)mmc_priv(mmc))->base + MSDC_INT); |
755 |
+ } |
756 |
+ |
757 |
+ return pm_runtime_force_suspend(dev); |
758 |
+diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c |
759 |
+index bac874ab0b33a..335c88fd849c4 100644 |
760 |
+--- a/drivers/mmc/host/sdhci-of-dwcmshc.c |
761 |
++++ b/drivers/mmc/host/sdhci-of-dwcmshc.c |
762 |
+@@ -15,6 +15,7 @@ |
763 |
+ #include <linux/module.h> |
764 |
+ #include <linux/of.h> |
765 |
+ #include <linux/of_device.h> |
766 |
++#include <linux/reset.h> |
767 |
+ #include <linux/sizes.h> |
768 |
+ |
769 |
+ #include "sdhci-pltfm.h" |
770 |
+@@ -55,14 +56,15 @@ |
771 |
+ #define DLL_LOCK_WO_TMOUT(x) \ |
772 |
+ ((((x) & DWCMSHC_EMMC_DLL_LOCKED) == DWCMSHC_EMMC_DLL_LOCKED) && \ |
773 |
+ (((x) & DWCMSHC_EMMC_DLL_TIMEOUT) == 0)) |
774 |
+-#define RK3568_MAX_CLKS 3 |
775 |
++#define RK35xx_MAX_CLKS 3 |
776 |
+ |
777 |
+ #define BOUNDARY_OK(addr, len) \ |
778 |
+ ((addr | (SZ_128M - 1)) == ((addr + len - 1) | (SZ_128M - 1))) |
779 |
+ |
780 |
+-struct rk3568_priv { |
781 |
++struct rk35xx_priv { |
782 |
+ /* Rockchip specified optional clocks */ |
783 |
+- struct clk_bulk_data rockchip_clks[RK3568_MAX_CLKS]; |
784 |
++ struct clk_bulk_data rockchip_clks[RK35xx_MAX_CLKS]; |
785 |
++ struct reset_control *reset; |
786 |
+ u8 txclk_tapnum; |
787 |
+ }; |
788 |
+ |
789 |
+@@ -176,7 +178,7 @@ static void dwcmshc_rk3568_set_clock(struct sdhci_host *host, unsigned int clock |
790 |
+ { |
791 |
+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
792 |
+ struct dwcmshc_priv *dwc_priv = sdhci_pltfm_priv(pltfm_host); |
793 |
+- struct rk3568_priv *priv = dwc_priv->priv; |
794 |
++ struct rk35xx_priv *priv = dwc_priv->priv; |
795 |
+ u8 txclk_tapnum = DLL_TXCLK_TAPNUM_DEFAULT; |
796 |
+ u32 extra, reg; |
797 |
+ int err; |
798 |
+@@ -255,6 +257,21 @@ static void dwcmshc_rk3568_set_clock(struct sdhci_host *host, unsigned int clock |
799 |
+ sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_STRBIN); |
800 |
+ } |
801 |
+ |
802 |
++static void rk35xx_sdhci_reset(struct sdhci_host *host, u8 mask) |
803 |
++{ |
804 |
++ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
805 |
++ struct dwcmshc_priv *dwc_priv = sdhci_pltfm_priv(pltfm_host); |
806 |
++ struct rk35xx_priv *priv = dwc_priv->priv; |
807 |
++ |
808 |
++ if (mask & SDHCI_RESET_ALL && priv->reset) { |
809 |
++ reset_control_assert(priv->reset); |
810 |
++ udelay(1); |
811 |
++ reset_control_deassert(priv->reset); |
812 |
++ } |
813 |
++ |
814 |
++ sdhci_reset(host, mask); |
815 |
++} |
816 |
++ |
817 |
+ static const struct sdhci_ops sdhci_dwcmshc_ops = { |
818 |
+ .set_clock = sdhci_set_clock, |
819 |
+ .set_bus_width = sdhci_set_bus_width, |
820 |
+@@ -264,12 +281,12 @@ static const struct sdhci_ops sdhci_dwcmshc_ops = { |
821 |
+ .adma_write_desc = dwcmshc_adma_write_desc, |
822 |
+ }; |
823 |
+ |
824 |
+-static const struct sdhci_ops sdhci_dwcmshc_rk3568_ops = { |
825 |
++static const struct sdhci_ops sdhci_dwcmshc_rk35xx_ops = { |
826 |
+ .set_clock = dwcmshc_rk3568_set_clock, |
827 |
+ .set_bus_width = sdhci_set_bus_width, |
828 |
+ .set_uhs_signaling = dwcmshc_set_uhs_signaling, |
829 |
+ .get_max_clock = sdhci_pltfm_clk_get_max_clock, |
830 |
+- .reset = sdhci_reset, |
831 |
++ .reset = rk35xx_sdhci_reset, |
832 |
+ .adma_write_desc = dwcmshc_adma_write_desc, |
833 |
+ }; |
834 |
+ |
835 |
+@@ -279,30 +296,46 @@ static const struct sdhci_pltfm_data sdhci_dwcmshc_pdata = { |
836 |
+ .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, |
837 |
+ }; |
838 |
+ |
839 |
+-static const struct sdhci_pltfm_data sdhci_dwcmshc_rk3568_pdata = { |
840 |
+- .ops = &sdhci_dwcmshc_rk3568_ops, |
841 |
++#ifdef CONFIG_ACPI |
842 |
++static const struct sdhci_pltfm_data sdhci_dwcmshc_bf3_pdata = { |
843 |
++ .ops = &sdhci_dwcmshc_ops, |
844 |
++ .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, |
845 |
++ .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | |
846 |
++ SDHCI_QUIRK2_ACMD23_BROKEN, |
847 |
++}; |
848 |
++#endif |
849 |
++ |
850 |
++static const struct sdhci_pltfm_data sdhci_dwcmshc_rk35xx_pdata = { |
851 |
++ .ops = &sdhci_dwcmshc_rk35xx_ops, |
852 |
+ .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN | |
853 |
+ SDHCI_QUIRK_BROKEN_TIMEOUT_VAL, |
854 |
+ .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | |
855 |
+ SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN, |
856 |
+ }; |
857 |
+ |
858 |
+-static int dwcmshc_rk3568_init(struct sdhci_host *host, struct dwcmshc_priv *dwc_priv) |
859 |
++static int dwcmshc_rk35xx_init(struct sdhci_host *host, struct dwcmshc_priv *dwc_priv) |
860 |
+ { |
861 |
+ int err; |
862 |
+- struct rk3568_priv *priv = dwc_priv->priv; |
863 |
++ struct rk35xx_priv *priv = dwc_priv->priv; |
864 |
++ |
865 |
++ priv->reset = devm_reset_control_array_get_optional_exclusive(mmc_dev(host->mmc)); |
866 |
++ if (IS_ERR(priv->reset)) { |
867 |
++ err = PTR_ERR(priv->reset); |
868 |
++ dev_err(mmc_dev(host->mmc), "failed to get reset control %d\n", err); |
869 |
++ return err; |
870 |
++ } |
871 |
+ |
872 |
+ priv->rockchip_clks[0].id = "axi"; |
873 |
+ priv->rockchip_clks[1].id = "block"; |
874 |
+ priv->rockchip_clks[2].id = "timer"; |
875 |
+- err = devm_clk_bulk_get_optional(mmc_dev(host->mmc), RK3568_MAX_CLKS, |
876 |
++ err = devm_clk_bulk_get_optional(mmc_dev(host->mmc), RK35xx_MAX_CLKS, |
877 |
+ priv->rockchip_clks); |
878 |
+ if (err) { |
879 |
+ dev_err(mmc_dev(host->mmc), "failed to get clocks %d\n", err); |
880 |
+ return err; |
881 |
+ } |
882 |
+ |
883 |
+- err = clk_bulk_prepare_enable(RK3568_MAX_CLKS, priv->rockchip_clks); |
884 |
++ err = clk_bulk_prepare_enable(RK35xx_MAX_CLKS, priv->rockchip_clks); |
885 |
+ if (err) { |
886 |
+ dev_err(mmc_dev(host->mmc), "failed to enable clocks %d\n", err); |
887 |
+ return err; |
888 |
+@@ -324,7 +357,7 @@ static int dwcmshc_rk3568_init(struct sdhci_host *host, struct dwcmshc_priv *dwc |
889 |
+ static const struct of_device_id sdhci_dwcmshc_dt_ids[] = { |
890 |
+ { |
891 |
+ .compatible = "rockchip,rk3568-dwcmshc", |
892 |
+- .data = &sdhci_dwcmshc_rk3568_pdata, |
893 |
++ .data = &sdhci_dwcmshc_rk35xx_pdata, |
894 |
+ }, |
895 |
+ { |
896 |
+ .compatible = "snps,dwcmshc-sdhci", |
897 |
+@@ -336,7 +369,10 @@ MODULE_DEVICE_TABLE(of, sdhci_dwcmshc_dt_ids); |
898 |
+ |
899 |
+ #ifdef CONFIG_ACPI |
900 |
+ static const struct acpi_device_id sdhci_dwcmshc_acpi_ids[] = { |
901 |
+- { .id = "MLNXBF30" }, |
902 |
++ { |
903 |
++ .id = "MLNXBF30", |
904 |
++ .driver_data = (kernel_ulong_t)&sdhci_dwcmshc_bf3_pdata, |
905 |
++ }, |
906 |
+ {} |
907 |
+ }; |
908 |
+ #endif |
909 |
+@@ -347,12 +383,12 @@ static int dwcmshc_probe(struct platform_device *pdev) |
910 |
+ struct sdhci_pltfm_host *pltfm_host; |
911 |
+ struct sdhci_host *host; |
912 |
+ struct dwcmshc_priv *priv; |
913 |
+- struct rk3568_priv *rk_priv = NULL; |
914 |
++ struct rk35xx_priv *rk_priv = NULL; |
915 |
+ const struct sdhci_pltfm_data *pltfm_data; |
916 |
+ int err; |
917 |
+ u32 extra; |
918 |
+ |
919 |
+- pltfm_data = of_device_get_match_data(&pdev->dev); |
920 |
++ pltfm_data = device_get_match_data(&pdev->dev); |
921 |
+ if (!pltfm_data) { |
922 |
+ dev_err(&pdev->dev, "Error: No device match data found\n"); |
923 |
+ return -ENODEV; |
924 |
+@@ -402,8 +438,8 @@ static int dwcmshc_probe(struct platform_device *pdev) |
925 |
+ host->mmc_host_ops.request = dwcmshc_request; |
926 |
+ host->mmc_host_ops.hs400_enhanced_strobe = dwcmshc_hs400_enhanced_strobe; |
927 |
+ |
928 |
+- if (pltfm_data == &sdhci_dwcmshc_rk3568_pdata) { |
929 |
+- rk_priv = devm_kzalloc(&pdev->dev, sizeof(struct rk3568_priv), GFP_KERNEL); |
930 |
++ if (pltfm_data == &sdhci_dwcmshc_rk35xx_pdata) { |
931 |
++ rk_priv = devm_kzalloc(&pdev->dev, sizeof(struct rk35xx_priv), GFP_KERNEL); |
932 |
+ if (!rk_priv) { |
933 |
+ err = -ENOMEM; |
934 |
+ goto err_clk; |
935 |
+@@ -411,7 +447,7 @@ static int dwcmshc_probe(struct platform_device *pdev) |
936 |
+ |
937 |
+ priv->priv = rk_priv; |
938 |
+ |
939 |
+- err = dwcmshc_rk3568_init(host, priv); |
940 |
++ err = dwcmshc_rk35xx_init(host, priv); |
941 |
+ if (err) |
942 |
+ goto err_clk; |
943 |
+ } |
944 |
+@@ -428,7 +464,7 @@ err_clk: |
945 |
+ clk_disable_unprepare(pltfm_host->clk); |
946 |
+ clk_disable_unprepare(priv->bus_clk); |
947 |
+ if (rk_priv) |
948 |
+- clk_bulk_disable_unprepare(RK3568_MAX_CLKS, |
949 |
++ clk_bulk_disable_unprepare(RK35xx_MAX_CLKS, |
950 |
+ rk_priv->rockchip_clks); |
951 |
+ free_pltfm: |
952 |
+ sdhci_pltfm_free(pdev); |
953 |
+@@ -440,14 +476,14 @@ static int dwcmshc_remove(struct platform_device *pdev) |
954 |
+ struct sdhci_host *host = platform_get_drvdata(pdev); |
955 |
+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
956 |
+ struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); |
957 |
+- struct rk3568_priv *rk_priv = priv->priv; |
958 |
++ struct rk35xx_priv *rk_priv = priv->priv; |
959 |
+ |
960 |
+ sdhci_remove_host(host, 0); |
961 |
+ |
962 |
+ clk_disable_unprepare(pltfm_host->clk); |
963 |
+ clk_disable_unprepare(priv->bus_clk); |
964 |
+ if (rk_priv) |
965 |
+- clk_bulk_disable_unprepare(RK3568_MAX_CLKS, |
966 |
++ clk_bulk_disable_unprepare(RK35xx_MAX_CLKS, |
967 |
+ rk_priv->rockchip_clks); |
968 |
+ sdhci_pltfm_free(pdev); |
969 |
+ |
970 |
+@@ -460,7 +496,7 @@ static int dwcmshc_suspend(struct device *dev) |
971 |
+ struct sdhci_host *host = dev_get_drvdata(dev); |
972 |
+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
973 |
+ struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); |
974 |
+- struct rk3568_priv *rk_priv = priv->priv; |
975 |
++ struct rk35xx_priv *rk_priv = priv->priv; |
976 |
+ int ret; |
977 |
+ |
978 |
+ ret = sdhci_suspend_host(host); |
979 |
+@@ -472,7 +508,7 @@ static int dwcmshc_suspend(struct device *dev) |
980 |
+ clk_disable_unprepare(priv->bus_clk); |
981 |
+ |
982 |
+ if (rk_priv) |
983 |
+- clk_bulk_disable_unprepare(RK3568_MAX_CLKS, |
984 |
++ clk_bulk_disable_unprepare(RK35xx_MAX_CLKS, |
985 |
+ rk_priv->rockchip_clks); |
986 |
+ |
987 |
+ return ret; |
988 |
+@@ -483,7 +519,7 @@ static int dwcmshc_resume(struct device *dev) |
989 |
+ struct sdhci_host *host = dev_get_drvdata(dev); |
990 |
+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
991 |
+ struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); |
992 |
+- struct rk3568_priv *rk_priv = priv->priv; |
993 |
++ struct rk35xx_priv *rk_priv = priv->priv; |
994 |
+ int ret; |
995 |
+ |
996 |
+ ret = clk_prepare_enable(pltfm_host->clk); |
997 |
+@@ -497,7 +533,7 @@ static int dwcmshc_resume(struct device *dev) |
998 |
+ } |
999 |
+ |
1000 |
+ if (rk_priv) { |
1001 |
+- ret = clk_bulk_prepare_enable(RK3568_MAX_CLKS, |
1002 |
++ ret = clk_bulk_prepare_enable(RK35xx_MAX_CLKS, |
1003 |
+ rk_priv->rockchip_clks); |
1004 |
+ if (ret) |
1005 |
+ return ret; |
1006 |
+diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c |
1007 |
+index 1ac7fec47d6fb..604feeb84ee40 100644 |
1008 |
+--- a/drivers/pci/pcie/portdrv_core.c |
1009 |
++++ b/drivers/pci/pcie/portdrv_core.c |
1010 |
+@@ -222,8 +222,15 @@ static int get_port_device_capability(struct pci_dev *dev) |
1011 |
+ |
1012 |
+ #ifdef CONFIG_PCIEAER |
1013 |
+ if (dev->aer_cap && pci_aer_available() && |
1014 |
+- (pcie_ports_native || host->native_aer)) |
1015 |
++ (pcie_ports_native || host->native_aer)) { |
1016 |
+ services |= PCIE_PORT_SERVICE_AER; |
1017 |
++ |
1018 |
++ /* |
1019 |
++ * Disable AER on this port in case it's been enabled by the |
1020 |
++ * BIOS (the AER service driver will enable it when necessary). |
1021 |
++ */ |
1022 |
++ pci_disable_pcie_error_reporting(dev); |
1023 |
++ } |
1024 |
+ #endif |
1025 |
+ |
1026 |
+ /* Root Ports and Root Complex Event Collectors may generate PMEs */ |
1027 |
+diff --git a/drivers/video/fbdev/pm2fb.c b/drivers/video/fbdev/pm2fb.c |
1028 |
+index c68725eebee3b..cbcf112c88d30 100644 |
1029 |
+--- a/drivers/video/fbdev/pm2fb.c |
1030 |
++++ b/drivers/video/fbdev/pm2fb.c |
1031 |
+@@ -617,6 +617,11 @@ static int pm2fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) |
1032 |
+ return -EINVAL; |
1033 |
+ } |
1034 |
+ |
1035 |
++ if (!var->pixclock) { |
1036 |
++ DPRINTK("pixclock is zero\n"); |
1037 |
++ return -EINVAL; |
1038 |
++ } |
1039 |
++ |
1040 |
+ if (PICOS2KHZ(var->pixclock) > PM2_MAX_PIXCLOCK) { |
1041 |
+ DPRINTK("pixclock too high (%ldKHz)\n", |
1042 |
+ PICOS2KHZ(var->pixclock)); |
1043 |
+diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c |
1044 |
+index 909cc00ef5ce3..474dcc0540a84 100644 |
1045 |
+--- a/fs/btrfs/block-group.c |
1046 |
++++ b/fs/btrfs/block-group.c |
1047 |
+@@ -418,39 +418,26 @@ void btrfs_wait_block_group_cache_progress(struct btrfs_block_group *cache, |
1048 |
+ btrfs_put_caching_control(caching_ctl); |
1049 |
+ } |
1050 |
+ |
1051 |
+-int btrfs_wait_block_group_cache_done(struct btrfs_block_group *cache) |
1052 |
++static int btrfs_caching_ctl_wait_done(struct btrfs_block_group *cache, |
1053 |
++ struct btrfs_caching_control *caching_ctl) |
1054 |
++{ |
1055 |
++ wait_event(caching_ctl->wait, btrfs_block_group_done(cache)); |
1056 |
++ return cache->cached == BTRFS_CACHE_ERROR ? -EIO : 0; |
1057 |
++} |
1058 |
++ |
1059 |
++static int btrfs_wait_block_group_cache_done(struct btrfs_block_group *cache) |
1060 |
+ { |
1061 |
+ struct btrfs_caching_control *caching_ctl; |
1062 |
+- int ret = 0; |
1063 |
++ int ret; |
1064 |
+ |
1065 |
+ caching_ctl = btrfs_get_caching_control(cache); |
1066 |
+ if (!caching_ctl) |
1067 |
+ return (cache->cached == BTRFS_CACHE_ERROR) ? -EIO : 0; |
1068 |
+- |
1069 |
+- wait_event(caching_ctl->wait, btrfs_block_group_done(cache)); |
1070 |
+- if (cache->cached == BTRFS_CACHE_ERROR) |
1071 |
+- ret = -EIO; |
1072 |
++ ret = btrfs_caching_ctl_wait_done(cache, caching_ctl); |
1073 |
+ btrfs_put_caching_control(caching_ctl); |
1074 |
+ return ret; |
1075 |
+ } |
1076 |
+ |
1077 |
+-static bool space_cache_v1_done(struct btrfs_block_group *cache) |
1078 |
+-{ |
1079 |
+- bool ret; |
1080 |
+- |
1081 |
+- spin_lock(&cache->lock); |
1082 |
+- ret = cache->cached != BTRFS_CACHE_FAST; |
1083 |
+- spin_unlock(&cache->lock); |
1084 |
+- |
1085 |
+- return ret; |
1086 |
+-} |
1087 |
+- |
1088 |
+-void btrfs_wait_space_cache_v1_finished(struct btrfs_block_group *cache, |
1089 |
+- struct btrfs_caching_control *caching_ctl) |
1090 |
+-{ |
1091 |
+- wait_event(caching_ctl->wait, space_cache_v1_done(cache)); |
1092 |
+-} |
1093 |
+- |
1094 |
+ #ifdef CONFIG_BTRFS_DEBUG |
1095 |
+ static void fragment_free_space(struct btrfs_block_group *block_group) |
1096 |
+ { |
1097 |
+@@ -727,9 +714,8 @@ done: |
1098 |
+ btrfs_put_block_group(block_group); |
1099 |
+ } |
1100 |
+ |
1101 |
+-int btrfs_cache_block_group(struct btrfs_block_group *cache, int load_cache_only) |
1102 |
++int btrfs_cache_block_group(struct btrfs_block_group *cache, bool wait) |
1103 |
+ { |
1104 |
+- DEFINE_WAIT(wait); |
1105 |
+ struct btrfs_fs_info *fs_info = cache->fs_info; |
1106 |
+ struct btrfs_caching_control *caching_ctl = NULL; |
1107 |
+ int ret = 0; |
1108 |
+@@ -762,10 +748,7 @@ int btrfs_cache_block_group(struct btrfs_block_group *cache, int load_cache_only |
1109 |
+ } |
1110 |
+ WARN_ON(cache->caching_ctl); |
1111 |
+ cache->caching_ctl = caching_ctl; |
1112 |
+- if (btrfs_test_opt(fs_info, SPACE_CACHE)) |
1113 |
+- cache->cached = BTRFS_CACHE_FAST; |
1114 |
+- else |
1115 |
+- cache->cached = BTRFS_CACHE_STARTED; |
1116 |
++ cache->cached = BTRFS_CACHE_STARTED; |
1117 |
+ cache->has_caching_ctl = 1; |
1118 |
+ spin_unlock(&cache->lock); |
1119 |
+ |
1120 |
+@@ -778,8 +761,8 @@ int btrfs_cache_block_group(struct btrfs_block_group *cache, int load_cache_only |
1121 |
+ |
1122 |
+ btrfs_queue_work(fs_info->caching_workers, &caching_ctl->work); |
1123 |
+ out: |
1124 |
+- if (load_cache_only && caching_ctl) |
1125 |
+- btrfs_wait_space_cache_v1_finished(cache, caching_ctl); |
1126 |
++ if (wait && caching_ctl) |
1127 |
++ ret = btrfs_caching_ctl_wait_done(cache, caching_ctl); |
1128 |
+ if (caching_ctl) |
1129 |
+ btrfs_put_caching_control(caching_ctl); |
1130 |
+ |
1131 |
+@@ -3200,7 +3183,7 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans, |
1132 |
+ * space back to the block group, otherwise we will leak space. |
1133 |
+ */ |
1134 |
+ if (!alloc && !btrfs_block_group_done(cache)) |
1135 |
+- btrfs_cache_block_group(cache, 1); |
1136 |
++ btrfs_cache_block_group(cache, true); |
1137 |
+ |
1138 |
+ byte_in_group = bytenr - cache->start; |
1139 |
+ WARN_ON(byte_in_group > cache->length); |
1140 |
+diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h |
1141 |
+index d73db0dfacb26..a15868d607a92 100644 |
1142 |
+--- a/fs/btrfs/block-group.h |
1143 |
++++ b/fs/btrfs/block-group.h |
1144 |
+@@ -251,9 +251,7 @@ void btrfs_dec_nocow_writers(struct btrfs_fs_info *fs_info, u64 bytenr); |
1145 |
+ void btrfs_wait_nocow_writers(struct btrfs_block_group *bg); |
1146 |
+ void btrfs_wait_block_group_cache_progress(struct btrfs_block_group *cache, |
1147 |
+ u64 num_bytes); |
1148 |
+-int btrfs_wait_block_group_cache_done(struct btrfs_block_group *cache); |
1149 |
+-int btrfs_cache_block_group(struct btrfs_block_group *cache, |
1150 |
+- int load_cache_only); |
1151 |
++int btrfs_cache_block_group(struct btrfs_block_group *cache, bool wait); |
1152 |
+ void btrfs_put_caching_control(struct btrfs_caching_control *ctl); |
1153 |
+ struct btrfs_caching_control *btrfs_get_caching_control( |
1154 |
+ struct btrfs_block_group *cache); |
1155 |
+diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c |
1156 |
+index 341ce90d24b15..fb7e331b69756 100644 |
1157 |
+--- a/fs/btrfs/ctree.c |
1158 |
++++ b/fs/btrfs/ctree.c |
1159 |
+@@ -1938,6 +1938,9 @@ cow_done: |
1160 |
+ |
1161 |
+ if (!p->skip_locking) { |
1162 |
+ level = btrfs_header_level(b); |
1163 |
++ |
1164 |
++ btrfs_maybe_reset_lockdep_class(root, b); |
1165 |
++ |
1166 |
+ if (level <= write_lock_level) { |
1167 |
+ btrfs_tree_lock(b); |
1168 |
+ p->locks[level] = BTRFS_WRITE_LOCK; |
1169 |
+diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h |
1170 |
+index 1831135fef1ab..02d3ee6c7d9b0 100644 |
1171 |
+--- a/fs/btrfs/ctree.h |
1172 |
++++ b/fs/btrfs/ctree.h |
1173 |
+@@ -454,7 +454,6 @@ struct btrfs_free_cluster { |
1174 |
+ enum btrfs_caching_type { |
1175 |
+ BTRFS_CACHE_NO, |
1176 |
+ BTRFS_CACHE_STARTED, |
1177 |
+- BTRFS_CACHE_FAST, |
1178 |
+ BTRFS_CACHE_FINISHED, |
1179 |
+ BTRFS_CACHE_ERROR, |
1180 |
+ }; |
1181 |
+@@ -1105,6 +1104,8 @@ enum { |
1182 |
+ BTRFS_ROOT_QGROUP_FLUSHING, |
1183 |
+ /* This root has a drop operation that was started previously. */ |
1184 |
+ BTRFS_ROOT_UNFINISHED_DROP, |
1185 |
++ /* This reloc root needs to have its buffers lockdep class reset. */ |
1186 |
++ BTRFS_ROOT_RESET_LOCKDEP_CLASS, |
1187 |
+ }; |
1188 |
+ |
1189 |
+ static inline void btrfs_wake_unfinished_drop(struct btrfs_fs_info *fs_info) |
1190 |
+@@ -3166,7 +3167,6 @@ void __btrfs_del_delalloc_inode(struct btrfs_root *root, |
1191 |
+ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry); |
1192 |
+ int btrfs_set_inode_index(struct btrfs_inode *dir, u64 *index); |
1193 |
+ int btrfs_unlink_inode(struct btrfs_trans_handle *trans, |
1194 |
+- struct btrfs_root *root, |
1195 |
+ struct btrfs_inode *dir, struct btrfs_inode *inode, |
1196 |
+ const char *name, int name_len); |
1197 |
+ int btrfs_add_link(struct btrfs_trans_handle *trans, |
1198 |
+diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c |
1199 |
+index 247d7f9ced3b0..c76c360bece59 100644 |
1200 |
+--- a/fs/btrfs/disk-io.c |
1201 |
++++ b/fs/btrfs/disk-io.c |
1202 |
+@@ -121,88 +121,6 @@ struct async_submit_bio { |
1203 |
+ blk_status_t status; |
1204 |
+ }; |
1205 |
+ |
1206 |
+-/* |
1207 |
+- * Lockdep class keys for extent_buffer->lock's in this root. For a given |
1208 |
+- * eb, the lockdep key is determined by the btrfs_root it belongs to and |
1209 |
+- * the level the eb occupies in the tree. |
1210 |
+- * |
1211 |
+- * Different roots are used for different purposes and may nest inside each |
1212 |
+- * other and they require separate keysets. As lockdep keys should be |
1213 |
+- * static, assign keysets according to the purpose of the root as indicated |
1214 |
+- * by btrfs_root->root_key.objectid. This ensures that all special purpose |
1215 |
+- * roots have separate keysets. |
1216 |
+- * |
1217 |
+- * Lock-nesting across peer nodes is always done with the immediate parent |
1218 |
+- * node locked thus preventing deadlock. As lockdep doesn't know this, use |
1219 |
+- * subclass to avoid triggering lockdep warning in such cases. |
1220 |
+- * |
1221 |
+- * The key is set by the readpage_end_io_hook after the buffer has passed |
1222 |
+- * csum validation but before the pages are unlocked. It is also set by |
1223 |
+- * btrfs_init_new_buffer on freshly allocated blocks. |
1224 |
+- * |
1225 |
+- * We also add a check to make sure the highest level of the tree is the |
1226 |
+- * same as our lockdep setup here. If BTRFS_MAX_LEVEL changes, this code |
1227 |
+- * needs update as well. |
1228 |
+- */ |
1229 |
+-#ifdef CONFIG_DEBUG_LOCK_ALLOC |
1230 |
+-# if BTRFS_MAX_LEVEL != 8 |
1231 |
+-# error |
1232 |
+-# endif |
1233 |
+- |
1234 |
+-#define DEFINE_LEVEL(stem, level) \ |
1235 |
+- .names[level] = "btrfs-" stem "-0" #level, |
1236 |
+- |
1237 |
+-#define DEFINE_NAME(stem) \ |
1238 |
+- DEFINE_LEVEL(stem, 0) \ |
1239 |
+- DEFINE_LEVEL(stem, 1) \ |
1240 |
+- DEFINE_LEVEL(stem, 2) \ |
1241 |
+- DEFINE_LEVEL(stem, 3) \ |
1242 |
+- DEFINE_LEVEL(stem, 4) \ |
1243 |
+- DEFINE_LEVEL(stem, 5) \ |
1244 |
+- DEFINE_LEVEL(stem, 6) \ |
1245 |
+- DEFINE_LEVEL(stem, 7) |
1246 |
+- |
1247 |
+-static struct btrfs_lockdep_keyset { |
1248 |
+- u64 id; /* root objectid */ |
1249 |
+- /* Longest entry: btrfs-free-space-00 */ |
1250 |
+- char names[BTRFS_MAX_LEVEL][20]; |
1251 |
+- struct lock_class_key keys[BTRFS_MAX_LEVEL]; |
1252 |
+-} btrfs_lockdep_keysets[] = { |
1253 |
+- { .id = BTRFS_ROOT_TREE_OBJECTID, DEFINE_NAME("root") }, |
1254 |
+- { .id = BTRFS_EXTENT_TREE_OBJECTID, DEFINE_NAME("extent") }, |
1255 |
+- { .id = BTRFS_CHUNK_TREE_OBJECTID, DEFINE_NAME("chunk") }, |
1256 |
+- { .id = BTRFS_DEV_TREE_OBJECTID, DEFINE_NAME("dev") }, |
1257 |
+- { .id = BTRFS_CSUM_TREE_OBJECTID, DEFINE_NAME("csum") }, |
1258 |
+- { .id = BTRFS_QUOTA_TREE_OBJECTID, DEFINE_NAME("quota") }, |
1259 |
+- { .id = BTRFS_TREE_LOG_OBJECTID, DEFINE_NAME("log") }, |
1260 |
+- { .id = BTRFS_TREE_RELOC_OBJECTID, DEFINE_NAME("treloc") }, |
1261 |
+- { .id = BTRFS_DATA_RELOC_TREE_OBJECTID, DEFINE_NAME("dreloc") }, |
1262 |
+- { .id = BTRFS_UUID_TREE_OBJECTID, DEFINE_NAME("uuid") }, |
1263 |
+- { .id = BTRFS_FREE_SPACE_TREE_OBJECTID, DEFINE_NAME("free-space") }, |
1264 |
+- { .id = 0, DEFINE_NAME("tree") }, |
1265 |
+-}; |
1266 |
+- |
1267 |
+-#undef DEFINE_LEVEL |
1268 |
+-#undef DEFINE_NAME |
1269 |
+- |
1270 |
+-void btrfs_set_buffer_lockdep_class(u64 objectid, struct extent_buffer *eb, |
1271 |
+- int level) |
1272 |
+-{ |
1273 |
+- struct btrfs_lockdep_keyset *ks; |
1274 |
+- |
1275 |
+- BUG_ON(level >= ARRAY_SIZE(ks->keys)); |
1276 |
+- |
1277 |
+- /* find the matching keyset, id 0 is the default entry */ |
1278 |
+- for (ks = btrfs_lockdep_keysets; ks->id; ks++) |
1279 |
+- if (ks->id == objectid) |
1280 |
+- break; |
1281 |
+- |
1282 |
+- lockdep_set_class_and_name(&eb->lock, |
1283 |
+- &ks->keys[level], ks->names[level]); |
1284 |
+-} |
1285 |
+- |
1286 |
+-#endif |
1287 |
+- |
1288 |
+ /* |
1289 |
+ * Compute the csum of a btree block and store the result to provided buffer. |
1290 |
+ */ |
1291 |
+diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h |
1292 |
+index 0e7e9526b6a83..1b8fd3deafc92 100644 |
1293 |
+--- a/fs/btrfs/disk-io.h |
1294 |
++++ b/fs/btrfs/disk-io.h |
1295 |
+@@ -140,14 +140,4 @@ int btrfs_init_root_free_objectid(struct btrfs_root *root); |
1296 |
+ int __init btrfs_end_io_wq_init(void); |
1297 |
+ void __cold btrfs_end_io_wq_exit(void); |
1298 |
+ |
1299 |
+-#ifdef CONFIG_DEBUG_LOCK_ALLOC |
1300 |
+-void btrfs_set_buffer_lockdep_class(u64 objectid, |
1301 |
+- struct extent_buffer *eb, int level); |
1302 |
+-#else |
1303 |
+-static inline void btrfs_set_buffer_lockdep_class(u64 objectid, |
1304 |
+- struct extent_buffer *eb, int level) |
1305 |
+-{ |
1306 |
+-} |
1307 |
+-#endif |
1308 |
+- |
1309 |
+ #endif |
1310 |
+diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c |
1311 |
+index 248ea15c97346..401a425a587c4 100644 |
1312 |
+--- a/fs/btrfs/extent-tree.c |
1313 |
++++ b/fs/btrfs/extent-tree.c |
1314 |
+@@ -2572,17 +2572,10 @@ int btrfs_pin_extent_for_log_replay(struct btrfs_trans_handle *trans, |
1315 |
+ return -EINVAL; |
1316 |
+ |
1317 |
+ /* |
1318 |
+- * pull in the free space cache (if any) so that our pin |
1319 |
+- * removes the free space from the cache. We have load_only set |
1320 |
+- * to one because the slow code to read in the free extents does check |
1321 |
+- * the pinned extents. |
1322 |
++ * Fully cache the free space first so that our pin removes the free space |
1323 |
++ * from the cache. |
1324 |
+ */ |
1325 |
+- btrfs_cache_block_group(cache, 1); |
1326 |
+- /* |
1327 |
+- * Make sure we wait until the cache is completely built in case it is |
1328 |
+- * missing or is invalid and therefore needs to be rebuilt. |
1329 |
+- */ |
1330 |
+- ret = btrfs_wait_block_group_cache_done(cache); |
1331 |
++ ret = btrfs_cache_block_group(cache, true); |
1332 |
+ if (ret) |
1333 |
+ goto out; |
1334 |
+ |
1335 |
+@@ -2605,12 +2598,7 @@ static int __exclude_logged_extent(struct btrfs_fs_info *fs_info, |
1336 |
+ if (!block_group) |
1337 |
+ return -EINVAL; |
1338 |
+ |
1339 |
+- btrfs_cache_block_group(block_group, 1); |
1340 |
+- /* |
1341 |
+- * Make sure we wait until the cache is completely built in case it is |
1342 |
+- * missing or is invalid and therefore needs to be rebuilt. |
1343 |
+- */ |
1344 |
+- ret = btrfs_wait_block_group_cache_done(block_group); |
1345 |
++ ret = btrfs_cache_block_group(block_group, true); |
1346 |
+ if (ret) |
1347 |
+ goto out; |
1348 |
+ |
1349 |
+@@ -4324,7 +4312,7 @@ have_block_group: |
1350 |
+ ffe_ctl.cached = btrfs_block_group_done(block_group); |
1351 |
+ if (unlikely(!ffe_ctl.cached)) { |
1352 |
+ ffe_ctl.have_caching_bg = true; |
1353 |
+- ret = btrfs_cache_block_group(block_group, 0); |
1354 |
++ ret = btrfs_cache_block_group(block_group, false); |
1355 |
+ |
1356 |
+ /* |
1357 |
+ * If we get ENOMEM here or something else we want to |
1358 |
+@@ -4781,6 +4769,7 @@ btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
1359 |
+ { |
1360 |
+ struct btrfs_fs_info *fs_info = root->fs_info; |
1361 |
+ struct extent_buffer *buf; |
1362 |
++ u64 lockdep_owner = owner; |
1363 |
+ |
1364 |
+ buf = btrfs_find_create_tree_block(fs_info, bytenr, owner, level); |
1365 |
+ if (IS_ERR(buf)) |
1366 |
+@@ -4799,12 +4788,27 @@ btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
1367 |
+ return ERR_PTR(-EUCLEAN); |
1368 |
+ } |
1369 |
+ |
1370 |
++ /* |
1371 |
++ * The reloc trees are just snapshots, so we need them to appear to be |
1372 |
++ * just like any other fs tree WRT lockdep. |
1373 |
++ * |
1374 |
++ * The exception however is in replace_path() in relocation, where we |
1375 |
++ * hold the lock on the original fs root and then search for the reloc |
1376 |
++ * root. At that point we need to make sure any reloc root buffers are |
1377 |
++ * set to the BTRFS_TREE_RELOC_OBJECTID lockdep class in order to make |
1378 |
++ * lockdep happy. |
1379 |
++ */ |
1380 |
++ if (lockdep_owner == BTRFS_TREE_RELOC_OBJECTID && |
1381 |
++ !test_bit(BTRFS_ROOT_RESET_LOCKDEP_CLASS, &root->state)) |
1382 |
++ lockdep_owner = BTRFS_FS_TREE_OBJECTID; |
1383 |
++ |
1384 |
+ /* |
1385 |
+ * This needs to stay, because we could allocate a freed block from an |
1386 |
+ * old tree into a new tree, so we need to make sure this new block is |
1387 |
+ * set to the appropriate level and owner. |
1388 |
+ */ |
1389 |
+- btrfs_set_buffer_lockdep_class(owner, buf, level); |
1390 |
++ btrfs_set_buffer_lockdep_class(lockdep_owner, buf, level); |
1391 |
++ |
1392 |
+ __btrfs_tree_lock(buf, nest); |
1393 |
+ btrfs_clean_tree_block(buf); |
1394 |
+ clear_bit(EXTENT_BUFFER_STALE, &buf->bflags); |
1395 |
+@@ -6066,13 +6070,7 @@ int btrfs_trim_fs(struct btrfs_fs_info *fs_info, struct fstrim_range *range) |
1396 |
+ |
1397 |
+ if (end - start >= range->minlen) { |
1398 |
+ if (!btrfs_block_group_done(cache)) { |
1399 |
+- ret = btrfs_cache_block_group(cache, 0); |
1400 |
+- if (ret) { |
1401 |
+- bg_failed++; |
1402 |
+- bg_ret = ret; |
1403 |
+- continue; |
1404 |
+- } |
1405 |
+- ret = btrfs_wait_block_group_cache_done(cache); |
1406 |
++ ret = btrfs_cache_block_group(cache, true); |
1407 |
+ if (ret) { |
1408 |
+ bg_failed++; |
1409 |
+ bg_ret = ret; |
1410 |
+diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c |
1411 |
+index a72a8d4d4a72e..7bd704779a99b 100644 |
1412 |
+--- a/fs/btrfs/extent_io.c |
1413 |
++++ b/fs/btrfs/extent_io.c |
1414 |
+@@ -6109,6 +6109,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, |
1415 |
+ struct extent_buffer *exists = NULL; |
1416 |
+ struct page *p; |
1417 |
+ struct address_space *mapping = fs_info->btree_inode->i_mapping; |
1418 |
++ u64 lockdep_owner = owner_root; |
1419 |
+ int uptodate = 1; |
1420 |
+ int ret; |
1421 |
+ |
1422 |
+@@ -6143,7 +6144,15 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, |
1423 |
+ eb = __alloc_extent_buffer(fs_info, start, len); |
1424 |
+ if (!eb) |
1425 |
+ return ERR_PTR(-ENOMEM); |
1426 |
+- btrfs_set_buffer_lockdep_class(owner_root, eb, level); |
1427 |
++ |
1428 |
++ /* |
1429 |
++ * The reloc trees are just snapshots, so we need them to appear to be |
1430 |
++ * just like any other fs tree WRT lockdep. |
1431 |
++ */ |
1432 |
++ if (lockdep_owner == BTRFS_TREE_RELOC_OBJECTID) |
1433 |
++ lockdep_owner = BTRFS_FS_TREE_OBJECTID; |
1434 |
++ |
1435 |
++ btrfs_set_buffer_lockdep_class(lockdep_owner, eb, level); |
1436 |
+ |
1437 |
+ num_pages = num_extent_pages(eb); |
1438 |
+ for (i = 0; i < num_pages; i++, index++) { |
1439 |
+diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c |
1440 |
+index 428a56f248bba..f8a01964a2169 100644 |
1441 |
+--- a/fs/btrfs/inode.c |
1442 |
++++ b/fs/btrfs/inode.c |
1443 |
+@@ -4097,11 +4097,11 @@ int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans, |
1444 |
+ * also drops the back refs in the inode to the directory |
1445 |
+ */ |
1446 |
+ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, |
1447 |
+- struct btrfs_root *root, |
1448 |
+ struct btrfs_inode *dir, |
1449 |
+ struct btrfs_inode *inode, |
1450 |
+ const char *name, int name_len) |
1451 |
+ { |
1452 |
++ struct btrfs_root *root = dir->root; |
1453 |
+ struct btrfs_fs_info *fs_info = root->fs_info; |
1454 |
+ struct btrfs_path *path; |
1455 |
+ int ret = 0; |
1456 |
+@@ -4201,15 +4201,14 @@ out: |
1457 |
+ } |
1458 |
+ |
1459 |
+ int btrfs_unlink_inode(struct btrfs_trans_handle *trans, |
1460 |
+- struct btrfs_root *root, |
1461 |
+ struct btrfs_inode *dir, struct btrfs_inode *inode, |
1462 |
+ const char *name, int name_len) |
1463 |
+ { |
1464 |
+ int ret; |
1465 |
+- ret = __btrfs_unlink_inode(trans, root, dir, inode, name, name_len); |
1466 |
++ ret = __btrfs_unlink_inode(trans, dir, inode, name, name_len); |
1467 |
+ if (!ret) { |
1468 |
+ drop_nlink(&inode->vfs_inode); |
1469 |
+- ret = btrfs_update_inode(trans, root, inode); |
1470 |
++ ret = btrfs_update_inode(trans, inode->root, inode); |
1471 |
+ } |
1472 |
+ return ret; |
1473 |
+ } |
1474 |
+@@ -4238,7 +4237,6 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir) |
1475 |
+ |
1476 |
+ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) |
1477 |
+ { |
1478 |
+- struct btrfs_root *root = BTRFS_I(dir)->root; |
1479 |
+ struct btrfs_trans_handle *trans; |
1480 |
+ struct inode *inode = d_inode(dentry); |
1481 |
+ int ret; |
1482 |
+@@ -4250,7 +4248,7 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) |
1483 |
+ btrfs_record_unlink_dir(trans, BTRFS_I(dir), BTRFS_I(d_inode(dentry)), |
1484 |
+ 0); |
1485 |
+ |
1486 |
+- ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir), |
1487 |
++ ret = btrfs_unlink_inode(trans, BTRFS_I(dir), |
1488 |
+ BTRFS_I(d_inode(dentry)), dentry->d_name.name, |
1489 |
+ dentry->d_name.len); |
1490 |
+ if (ret) |
1491 |
+@@ -4264,7 +4262,7 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) |
1492 |
+ |
1493 |
+ out: |
1494 |
+ btrfs_end_transaction(trans); |
1495 |
+- btrfs_btree_balance_dirty(root->fs_info); |
1496 |
++ btrfs_btree_balance_dirty(BTRFS_I(dir)->root->fs_info); |
1497 |
+ return ret; |
1498 |
+ } |
1499 |
+ |
1500 |
+@@ -4622,7 +4620,6 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) |
1501 |
+ { |
1502 |
+ struct inode *inode = d_inode(dentry); |
1503 |
+ int err = 0; |
1504 |
+- struct btrfs_root *root = BTRFS_I(dir)->root; |
1505 |
+ struct btrfs_trans_handle *trans; |
1506 |
+ u64 last_unlink_trans; |
1507 |
+ |
1508 |
+@@ -4647,7 +4644,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) |
1509 |
+ last_unlink_trans = BTRFS_I(inode)->last_unlink_trans; |
1510 |
+ |
1511 |
+ /* now the directory is empty */ |
1512 |
+- err = btrfs_unlink_inode(trans, root, BTRFS_I(dir), |
1513 |
++ err = btrfs_unlink_inode(trans, BTRFS_I(dir), |
1514 |
+ BTRFS_I(d_inode(dentry)), dentry->d_name.name, |
1515 |
+ dentry->d_name.len); |
1516 |
+ if (!err) { |
1517 |
+@@ -4668,7 +4665,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) |
1518 |
+ } |
1519 |
+ out: |
1520 |
+ btrfs_end_transaction(trans); |
1521 |
+- btrfs_btree_balance_dirty(root->fs_info); |
1522 |
++ btrfs_btree_balance_dirty(BTRFS_I(dir)->root->fs_info); |
1523 |
+ |
1524 |
+ return err; |
1525 |
+ } |
1526 |
+@@ -9571,7 +9568,7 @@ static int btrfs_rename_exchange(struct inode *old_dir, |
1527 |
+ if (old_ino == BTRFS_FIRST_FREE_OBJECTID) { |
1528 |
+ ret = btrfs_unlink_subvol(trans, old_dir, old_dentry); |
1529 |
+ } else { /* src is an inode */ |
1530 |
+- ret = __btrfs_unlink_inode(trans, root, BTRFS_I(old_dir), |
1531 |
++ ret = __btrfs_unlink_inode(trans, BTRFS_I(old_dir), |
1532 |
+ BTRFS_I(old_dentry->d_inode), |
1533 |
+ old_dentry->d_name.name, |
1534 |
+ old_dentry->d_name.len); |
1535 |
+@@ -9587,7 +9584,7 @@ static int btrfs_rename_exchange(struct inode *old_dir, |
1536 |
+ if (new_ino == BTRFS_FIRST_FREE_OBJECTID) { |
1537 |
+ ret = btrfs_unlink_subvol(trans, new_dir, new_dentry); |
1538 |
+ } else { /* dest is an inode */ |
1539 |
+- ret = __btrfs_unlink_inode(trans, dest, BTRFS_I(new_dir), |
1540 |
++ ret = __btrfs_unlink_inode(trans, BTRFS_I(new_dir), |
1541 |
+ BTRFS_I(new_dentry->d_inode), |
1542 |
+ new_dentry->d_name.name, |
1543 |
+ new_dentry->d_name.len); |
1544 |
+@@ -9862,7 +9859,7 @@ static int btrfs_rename(struct user_namespace *mnt_userns, |
1545 |
+ */ |
1546 |
+ btrfs_pin_log_trans(root); |
1547 |
+ log_pinned = true; |
1548 |
+- ret = __btrfs_unlink_inode(trans, root, BTRFS_I(old_dir), |
1549 |
++ ret = __btrfs_unlink_inode(trans, BTRFS_I(old_dir), |
1550 |
+ BTRFS_I(d_inode(old_dentry)), |
1551 |
+ old_dentry->d_name.name, |
1552 |
+ old_dentry->d_name.len); |
1553 |
+@@ -9882,7 +9879,7 @@ static int btrfs_rename(struct user_namespace *mnt_userns, |
1554 |
+ ret = btrfs_unlink_subvol(trans, new_dir, new_dentry); |
1555 |
+ BUG_ON(new_inode->i_nlink == 0); |
1556 |
+ } else { |
1557 |
+- ret = btrfs_unlink_inode(trans, dest, BTRFS_I(new_dir), |
1558 |
++ ret = btrfs_unlink_inode(trans, BTRFS_I(new_dir), |
1559 |
+ BTRFS_I(d_inode(new_dentry)), |
1560 |
+ new_dentry->d_name.name, |
1561 |
+ new_dentry->d_name.len); |
1562 |
+diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c |
1563 |
+index 33461b4f9c8b5..9063072b399bd 100644 |
1564 |
+--- a/fs/btrfs/locking.c |
1565 |
++++ b/fs/btrfs/locking.c |
1566 |
+@@ -13,6 +13,93 @@ |
1567 |
+ #include "extent_io.h" |
1568 |
+ #include "locking.h" |
1569 |
+ |
1570 |
++/* |
1571 |
++ * Lockdep class keys for extent_buffer->lock's in this root. For a given |
1572 |
++ * eb, the lockdep key is determined by the btrfs_root it belongs to and |
1573 |
++ * the level the eb occupies in the tree. |
1574 |
++ * |
1575 |
++ * Different roots are used for different purposes and may nest inside each |
1576 |
++ * other and they require separate keysets. As lockdep keys should be |
1577 |
++ * static, assign keysets according to the purpose of the root as indicated |
1578 |
++ * by btrfs_root->root_key.objectid. This ensures that all special purpose |
1579 |
++ * roots have separate keysets. |
1580 |
++ * |
1581 |
++ * Lock-nesting across peer nodes is always done with the immediate parent |
1582 |
++ * node locked thus preventing deadlock. As lockdep doesn't know this, use |
1583 |
++ * subclass to avoid triggering lockdep warning in such cases. |
1584 |
++ * |
1585 |
++ * The key is set by the readpage_end_io_hook after the buffer has passed |
1586 |
++ * csum validation but before the pages are unlocked. It is also set by |
1587 |
++ * btrfs_init_new_buffer on freshly allocated blocks. |
1588 |
++ * |
1589 |
++ * We also add a check to make sure the highest level of the tree is the |
1590 |
++ * same as our lockdep setup here. If BTRFS_MAX_LEVEL changes, this code |
1591 |
++ * needs update as well. |
1592 |
++ */ |
1593 |
++#ifdef CONFIG_DEBUG_LOCK_ALLOC |
1594 |
++#if BTRFS_MAX_LEVEL != 8 |
1595 |
++#error |
1596 |
++#endif |
1597 |
++ |
1598 |
++#define DEFINE_LEVEL(stem, level) \ |
1599 |
++ .names[level] = "btrfs-" stem "-0" #level, |
1600 |
++ |
1601 |
++#define DEFINE_NAME(stem) \ |
1602 |
++ DEFINE_LEVEL(stem, 0) \ |
1603 |
++ DEFINE_LEVEL(stem, 1) \ |
1604 |
++ DEFINE_LEVEL(stem, 2) \ |
1605 |
++ DEFINE_LEVEL(stem, 3) \ |
1606 |
++ DEFINE_LEVEL(stem, 4) \ |
1607 |
++ DEFINE_LEVEL(stem, 5) \ |
1608 |
++ DEFINE_LEVEL(stem, 6) \ |
1609 |
++ DEFINE_LEVEL(stem, 7) |
1610 |
++ |
1611 |
++static struct btrfs_lockdep_keyset { |
1612 |
++ u64 id; /* root objectid */ |
1613 |
++ /* Longest entry: btrfs-free-space-00 */ |
1614 |
++ char names[BTRFS_MAX_LEVEL][20]; |
1615 |
++ struct lock_class_key keys[BTRFS_MAX_LEVEL]; |
1616 |
++} btrfs_lockdep_keysets[] = { |
1617 |
++ { .id = BTRFS_ROOT_TREE_OBJECTID, DEFINE_NAME("root") }, |
1618 |
++ { .id = BTRFS_EXTENT_TREE_OBJECTID, DEFINE_NAME("extent") }, |
1619 |
++ { .id = BTRFS_CHUNK_TREE_OBJECTID, DEFINE_NAME("chunk") }, |
1620 |
++ { .id = BTRFS_DEV_TREE_OBJECTID, DEFINE_NAME("dev") }, |
1621 |
++ { .id = BTRFS_CSUM_TREE_OBJECTID, DEFINE_NAME("csum") }, |
1622 |
++ { .id = BTRFS_QUOTA_TREE_OBJECTID, DEFINE_NAME("quota") }, |
1623 |
++ { .id = BTRFS_TREE_LOG_OBJECTID, DEFINE_NAME("log") }, |
1624 |
++ { .id = BTRFS_TREE_RELOC_OBJECTID, DEFINE_NAME("treloc") }, |
1625 |
++ { .id = BTRFS_DATA_RELOC_TREE_OBJECTID, DEFINE_NAME("dreloc") }, |
1626 |
++ { .id = BTRFS_UUID_TREE_OBJECTID, DEFINE_NAME("uuid") }, |
1627 |
++ { .id = BTRFS_FREE_SPACE_TREE_OBJECTID, DEFINE_NAME("free-space") }, |
1628 |
++ { .id = 0, DEFINE_NAME("tree") }, |
1629 |
++}; |
1630 |
++ |
1631 |
++#undef DEFINE_LEVEL |
1632 |
++#undef DEFINE_NAME |
1633 |
++ |
1634 |
++void btrfs_set_buffer_lockdep_class(u64 objectid, struct extent_buffer *eb, int level) |
1635 |
++{ |
1636 |
++ struct btrfs_lockdep_keyset *ks; |
1637 |
++ |
1638 |
++ BUG_ON(level >= ARRAY_SIZE(ks->keys)); |
1639 |
++ |
1640 |
++ /* Find the matching keyset, id 0 is the default entry */ |
1641 |
++ for (ks = btrfs_lockdep_keysets; ks->id; ks++) |
1642 |
++ if (ks->id == objectid) |
1643 |
++ break; |
1644 |
++ |
1645 |
++ lockdep_set_class_and_name(&eb->lock, &ks->keys[level], ks->names[level]); |
1646 |
++} |
1647 |
++ |
1648 |
++void btrfs_maybe_reset_lockdep_class(struct btrfs_root *root, struct extent_buffer *eb) |
1649 |
++{ |
1650 |
++ if (test_bit(BTRFS_ROOT_RESET_LOCKDEP_CLASS, &root->state)) |
1651 |
++ btrfs_set_buffer_lockdep_class(root->root_key.objectid, |
1652 |
++ eb, btrfs_header_level(eb)); |
1653 |
++} |
1654 |
++ |
1655 |
++#endif |
1656 |
++ |
1657 |
+ /* |
1658 |
+ * Extent buffer locking |
1659 |
+ * ===================== |
1660 |
+@@ -164,6 +251,8 @@ struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root) |
1661 |
+ |
1662 |
+ while (1) { |
1663 |
+ eb = btrfs_root_node(root); |
1664 |
++ |
1665 |
++ btrfs_maybe_reset_lockdep_class(root, eb); |
1666 |
+ btrfs_tree_lock(eb); |
1667 |
+ if (eb == root->node) |
1668 |
+ break; |
1669 |
+@@ -185,6 +274,8 @@ struct extent_buffer *btrfs_read_lock_root_node(struct btrfs_root *root) |
1670 |
+ |
1671 |
+ while (1) { |
1672 |
+ eb = btrfs_root_node(root); |
1673 |
++ |
1674 |
++ btrfs_maybe_reset_lockdep_class(root, eb); |
1675 |
+ btrfs_tree_read_lock(eb); |
1676 |
+ if (eb == root->node) |
1677 |
+ break; |
1678 |
+diff --git a/fs/btrfs/locking.h b/fs/btrfs/locking.h |
1679 |
+index a2e1f1f5c6e34..26a2f962c268e 100644 |
1680 |
+--- a/fs/btrfs/locking.h |
1681 |
++++ b/fs/btrfs/locking.h |
1682 |
+@@ -130,4 +130,18 @@ void btrfs_drew_write_unlock(struct btrfs_drew_lock *lock); |
1683 |
+ void btrfs_drew_read_lock(struct btrfs_drew_lock *lock); |
1684 |
+ void btrfs_drew_read_unlock(struct btrfs_drew_lock *lock); |
1685 |
+ |
1686 |
++#ifdef CONFIG_DEBUG_LOCK_ALLOC |
1687 |
++void btrfs_set_buffer_lockdep_class(u64 objectid, struct extent_buffer *eb, int level); |
1688 |
++void btrfs_maybe_reset_lockdep_class(struct btrfs_root *root, struct extent_buffer *eb); |
1689 |
++#else |
1690 |
++static inline void btrfs_set_buffer_lockdep_class(u64 objectid, |
1691 |
++ struct extent_buffer *eb, int level) |
1692 |
++{ |
1693 |
++} |
1694 |
++static inline void btrfs_maybe_reset_lockdep_class(struct btrfs_root *root, |
1695 |
++ struct extent_buffer *eb) |
1696 |
++{ |
1697 |
++} |
1698 |
++#endif |
1699 |
++ |
1700 |
+ #endif |
1701 |
+diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c |
1702 |
+index 673e11fcf3fc9..becf3396d533d 100644 |
1703 |
+--- a/fs/btrfs/relocation.c |
1704 |
++++ b/fs/btrfs/relocation.c |
1705 |
+@@ -1326,7 +1326,9 @@ again: |
1706 |
+ btrfs_release_path(path); |
1707 |
+ |
1708 |
+ path->lowest_level = level; |
1709 |
++ set_bit(BTRFS_ROOT_RESET_LOCKDEP_CLASS, &src->state); |
1710 |
+ ret = btrfs_search_slot(trans, src, &key, path, 0, 1); |
1711 |
++ clear_bit(BTRFS_ROOT_RESET_LOCKDEP_CLASS, &src->state); |
1712 |
+ path->lowest_level = 0; |
1713 |
+ if (ret) { |
1714 |
+ if (ret > 0) |
1715 |
+diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c |
1716 |
+index 51382d2be3d44..a84d2d4895104 100644 |
1717 |
+--- a/fs/btrfs/tree-checker.c |
1718 |
++++ b/fs/btrfs/tree-checker.c |
1719 |
+@@ -1216,7 +1216,8 @@ static void extent_err(const struct extent_buffer *eb, int slot, |
1720 |
+ } |
1721 |
+ |
1722 |
+ static int check_extent_item(struct extent_buffer *leaf, |
1723 |
+- struct btrfs_key *key, int slot) |
1724 |
++ struct btrfs_key *key, int slot, |
1725 |
++ struct btrfs_key *prev_key) |
1726 |
+ { |
1727 |
+ struct btrfs_fs_info *fs_info = leaf->fs_info; |
1728 |
+ struct btrfs_extent_item *ei; |
1729 |
+@@ -1436,6 +1437,26 @@ static int check_extent_item(struct extent_buffer *leaf, |
1730 |
+ total_refs, inline_refs); |
1731 |
+ return -EUCLEAN; |
1732 |
+ } |
1733 |
++ |
1734 |
++ if ((prev_key->type == BTRFS_EXTENT_ITEM_KEY) || |
1735 |
++ (prev_key->type == BTRFS_METADATA_ITEM_KEY)) { |
1736 |
++ u64 prev_end = prev_key->objectid; |
1737 |
++ |
1738 |
++ if (prev_key->type == BTRFS_METADATA_ITEM_KEY) |
1739 |
++ prev_end += fs_info->nodesize; |
1740 |
++ else |
1741 |
++ prev_end += prev_key->offset; |
1742 |
++ |
1743 |
++ if (unlikely(prev_end > key->objectid)) { |
1744 |
++ extent_err(leaf, slot, |
1745 |
++ "previous extent [%llu %u %llu] overlaps current extent [%llu %u %llu]", |
1746 |
++ prev_key->objectid, prev_key->type, |
1747 |
++ prev_key->offset, key->objectid, key->type, |
1748 |
++ key->offset); |
1749 |
++ return -EUCLEAN; |
1750 |
++ } |
1751 |
++ } |
1752 |
++ |
1753 |
+ return 0; |
1754 |
+ } |
1755 |
+ |
1756 |
+@@ -1604,7 +1625,7 @@ static int check_leaf_item(struct extent_buffer *leaf, |
1757 |
+ break; |
1758 |
+ case BTRFS_EXTENT_ITEM_KEY: |
1759 |
+ case BTRFS_METADATA_ITEM_KEY: |
1760 |
+- ret = check_extent_item(leaf, key, slot); |
1761 |
++ ret = check_extent_item(leaf, key, slot, prev_key); |
1762 |
+ break; |
1763 |
+ case BTRFS_TREE_BLOCK_REF_KEY: |
1764 |
+ case BTRFS_SHARED_DATA_REF_KEY: |
1765 |
+diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c |
1766 |
+index 1d7e9812f55e1..7272896587302 100644 |
1767 |
+--- a/fs/btrfs/tree-log.c |
1768 |
++++ b/fs/btrfs/tree-log.c |
1769 |
+@@ -884,6 +884,26 @@ out: |
1770 |
+ return ret; |
1771 |
+ } |
1772 |
+ |
1773 |
++static int unlink_inode_for_log_replay(struct btrfs_trans_handle *trans, |
1774 |
++ struct btrfs_inode *dir, |
1775 |
++ struct btrfs_inode *inode, |
1776 |
++ const char *name, |
1777 |
++ int name_len) |
1778 |
++{ |
1779 |
++ int ret; |
1780 |
++ |
1781 |
++ ret = btrfs_unlink_inode(trans, dir, inode, name, name_len); |
1782 |
++ if (ret) |
1783 |
++ return ret; |
1784 |
++ /* |
1785 |
++ * Whenever we need to check if a name exists or not, we check the |
1786 |
++ * fs/subvolume tree. So after an unlink we must run delayed items, so |
1787 |
++ * that future checks for a name during log replay see that the name |
1788 |
++ * does not exists anymore. |
1789 |
++ */ |
1790 |
++ return btrfs_run_delayed_items(trans); |
1791 |
++} |
1792 |
++ |
1793 |
+ /* |
1794 |
+ * when cleaning up conflicts between the directory names in the |
1795 |
+ * subvolume, directory names in the log and directory names in the |
1796 |
+@@ -926,12 +946,8 @@ static noinline int drop_one_dir_item(struct btrfs_trans_handle *trans, |
1797 |
+ if (ret) |
1798 |
+ goto out; |
1799 |
+ |
1800 |
+- ret = btrfs_unlink_inode(trans, root, dir, BTRFS_I(inode), name, |
1801 |
++ ret = unlink_inode_for_log_replay(trans, dir, BTRFS_I(inode), name, |
1802 |
+ name_len); |
1803 |
+- if (ret) |
1804 |
+- goto out; |
1805 |
+- else |
1806 |
+- ret = btrfs_run_delayed_items(trans); |
1807 |
+ out: |
1808 |
+ kfree(name); |
1809 |
+ iput(inode); |
1810 |
+@@ -1091,12 +1107,9 @@ again: |
1811 |
+ inc_nlink(&inode->vfs_inode); |
1812 |
+ btrfs_release_path(path); |
1813 |
+ |
1814 |
+- ret = btrfs_unlink_inode(trans, root, dir, inode, |
1815 |
++ ret = unlink_inode_for_log_replay(trans, dir, inode, |
1816 |
+ victim_name, victim_name_len); |
1817 |
+ kfree(victim_name); |
1818 |
+- if (ret) |
1819 |
+- return ret; |
1820 |
+- ret = btrfs_run_delayed_items(trans); |
1821 |
+ if (ret) |
1822 |
+ return ret; |
1823 |
+ *search_done = 1; |
1824 |
+@@ -1165,14 +1178,11 @@ again: |
1825 |
+ inc_nlink(&inode->vfs_inode); |
1826 |
+ btrfs_release_path(path); |
1827 |
+ |
1828 |
+- ret = btrfs_unlink_inode(trans, root, |
1829 |
++ ret = unlink_inode_for_log_replay(trans, |
1830 |
+ BTRFS_I(victim_parent), |
1831 |
+ inode, |
1832 |
+ victim_name, |
1833 |
+ victim_name_len); |
1834 |
+- if (!ret) |
1835 |
+- ret = btrfs_run_delayed_items( |
1836 |
+- trans); |
1837 |
+ } |
1838 |
+ iput(victim_parent); |
1839 |
+ kfree(victim_name); |
1840 |
+@@ -1327,19 +1337,10 @@ again: |
1841 |
+ kfree(name); |
1842 |
+ goto out; |
1843 |
+ } |
1844 |
+- ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir), |
1845 |
++ ret = unlink_inode_for_log_replay(trans, BTRFS_I(dir), |
1846 |
+ inode, name, namelen); |
1847 |
+ kfree(name); |
1848 |
+ iput(dir); |
1849 |
+- /* |
1850 |
+- * Whenever we need to check if a name exists or not, we |
1851 |
+- * check the subvolume tree. So after an unlink we must |
1852 |
+- * run delayed items, so that future checks for a name |
1853 |
+- * during log replay see that the name does not exists |
1854 |
+- * anymore. |
1855 |
+- */ |
1856 |
+- if (!ret) |
1857 |
+- ret = btrfs_run_delayed_items(trans); |
1858 |
+ if (ret) |
1859 |
+ goto out; |
1860 |
+ goto again; |
1861 |
+@@ -1434,8 +1435,8 @@ static int add_link(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
1862 |
+ ret = -ENOENT; |
1863 |
+ goto out; |
1864 |
+ } |
1865 |
+- ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir), BTRFS_I(other_inode), |
1866 |
+- name, namelen); |
1867 |
++ ret = unlink_inode_for_log_replay(trans, BTRFS_I(dir), BTRFS_I(other_inode), |
1868 |
++ name, namelen); |
1869 |
+ if (ret) |
1870 |
+ goto out; |
1871 |
+ /* |
1872 |
+@@ -1443,11 +1444,7 @@ static int add_link(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
1873 |
+ * on the inode will not free it. We will fixup the link count later. |
1874 |
+ */ |
1875 |
+ if (other_inode->i_nlink == 0) |
1876 |
+- inc_nlink(other_inode); |
1877 |
+- |
1878 |
+- ret = btrfs_run_delayed_items(trans); |
1879 |
+- if (ret) |
1880 |
+- goto out; |
1881 |
++ set_nlink(other_inode, 1); |
1882 |
+ add_link: |
1883 |
+ ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode), |
1884 |
+ name, namelen, 0, ref_index); |
1885 |
+@@ -1580,7 +1577,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans, |
1886 |
+ ret = btrfs_inode_ref_exists(inode, dir, key->type, |
1887 |
+ name, namelen); |
1888 |
+ if (ret > 0) { |
1889 |
+- ret = btrfs_unlink_inode(trans, root, |
1890 |
++ ret = unlink_inode_for_log_replay(trans, |
1891 |
+ BTRFS_I(dir), |
1892 |
+ BTRFS_I(inode), |
1893 |
+ name, namelen); |
1894 |
+@@ -1590,16 +1587,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans, |
1895 |
+ * free it. We will fixup the link count later. |
1896 |
+ */ |
1897 |
+ if (!ret && inode->i_nlink == 0) |
1898 |
+- inc_nlink(inode); |
1899 |
+- /* |
1900 |
+- * Whenever we need to check if a name exists or |
1901 |
+- * not, we check the subvolume tree. So after an |
1902 |
+- * unlink we must run delayed items, so that future |
1903 |
+- * checks for a name during log replay see that the |
1904 |
+- * name does not exists anymore. |
1905 |
+- */ |
1906 |
+- if (!ret) |
1907 |
+- ret = btrfs_run_delayed_items(trans); |
1908 |
++ set_nlink(inode, 1); |
1909 |
+ } |
1910 |
+ if (ret < 0) |
1911 |
+ goto out; |
1912 |
+@@ -2197,7 +2185,7 @@ static noinline int replay_one_dir_item(struct btrfs_trans_handle *trans, |
1913 |
+ */ |
1914 |
+ static noinline int find_dir_range(struct btrfs_root *root, |
1915 |
+ struct btrfs_path *path, |
1916 |
+- u64 dirid, int key_type, |
1917 |
++ u64 dirid, |
1918 |
+ u64 *start_ret, u64 *end_ret) |
1919 |
+ { |
1920 |
+ struct btrfs_key key; |
1921 |
+@@ -2210,7 +2198,7 @@ static noinline int find_dir_range(struct btrfs_root *root, |
1922 |
+ return 1; |
1923 |
+ |
1924 |
+ key.objectid = dirid; |
1925 |
+- key.type = key_type; |
1926 |
++ key.type = BTRFS_DIR_LOG_INDEX_KEY; |
1927 |
+ key.offset = *start_ret; |
1928 |
+ |
1929 |
+ ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); |
1930 |
+@@ -2224,7 +2212,7 @@ static noinline int find_dir_range(struct btrfs_root *root, |
1931 |
+ if (ret != 0) |
1932 |
+ btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); |
1933 |
+ |
1934 |
+- if (key.type != key_type || key.objectid != dirid) { |
1935 |
++ if (key.type != BTRFS_DIR_LOG_INDEX_KEY || key.objectid != dirid) { |
1936 |
+ ret = 1; |
1937 |
+ goto next; |
1938 |
+ } |
1939 |
+@@ -2251,7 +2239,7 @@ next: |
1940 |
+ |
1941 |
+ btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); |
1942 |
+ |
1943 |
+- if (key.type != key_type || key.objectid != dirid) { |
1944 |
++ if (key.type != BTRFS_DIR_LOG_INDEX_KEY || key.objectid != dirid) { |
1945 |
+ ret = 1; |
1946 |
+ goto out; |
1947 |
+ } |
1948 |
+@@ -2282,95 +2270,75 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans, |
1949 |
+ int ret; |
1950 |
+ struct extent_buffer *eb; |
1951 |
+ int slot; |
1952 |
+- u32 item_size; |
1953 |
+ struct btrfs_dir_item *di; |
1954 |
+- struct btrfs_dir_item *log_di; |
1955 |
+ int name_len; |
1956 |
+- unsigned long ptr; |
1957 |
+- unsigned long ptr_end; |
1958 |
+ char *name; |
1959 |
+- struct inode *inode; |
1960 |
++ struct inode *inode = NULL; |
1961 |
+ struct btrfs_key location; |
1962 |
+ |
1963 |
+-again: |
1964 |
++ /* |
1965 |
++ * Currenly we only log dir index keys. Even if we replay a log created |
1966 |
++ * by an older kernel that logged both dir index and dir item keys, all |
1967 |
++ * we need to do is process the dir index keys, we (and our caller) can |
1968 |
++ * safely ignore dir item keys (key type BTRFS_DIR_ITEM_KEY). |
1969 |
++ */ |
1970 |
++ ASSERT(dir_key->type == BTRFS_DIR_INDEX_KEY); |
1971 |
++ |
1972 |
+ eb = path->nodes[0]; |
1973 |
+ slot = path->slots[0]; |
1974 |
+- item_size = btrfs_item_size_nr(eb, slot); |
1975 |
+- ptr = btrfs_item_ptr_offset(eb, slot); |
1976 |
+- ptr_end = ptr + item_size; |
1977 |
+- while (ptr < ptr_end) { |
1978 |
+- di = (struct btrfs_dir_item *)ptr; |
1979 |
+- name_len = btrfs_dir_name_len(eb, di); |
1980 |
+- name = kmalloc(name_len, GFP_NOFS); |
1981 |
+- if (!name) { |
1982 |
+- ret = -ENOMEM; |
1983 |
+- goto out; |
1984 |
+- } |
1985 |
+- read_extent_buffer(eb, name, (unsigned long)(di + 1), |
1986 |
+- name_len); |
1987 |
+- log_di = NULL; |
1988 |
+- if (log && dir_key->type == BTRFS_DIR_ITEM_KEY) { |
1989 |
+- log_di = btrfs_lookup_dir_item(trans, log, log_path, |
1990 |
+- dir_key->objectid, |
1991 |
+- name, name_len, 0); |
1992 |
+- } else if (log && dir_key->type == BTRFS_DIR_INDEX_KEY) { |
1993 |
+- log_di = btrfs_lookup_dir_index_item(trans, log, |
1994 |
+- log_path, |
1995 |
+- dir_key->objectid, |
1996 |
+- dir_key->offset, |
1997 |
+- name, name_len, 0); |
1998 |
+- } |
1999 |
+- if (!log_di) { |
2000 |
+- btrfs_dir_item_key_to_cpu(eb, di, &location); |
2001 |
+- btrfs_release_path(path); |
2002 |
+- btrfs_release_path(log_path); |
2003 |
+- inode = read_one_inode(root, location.objectid); |
2004 |
+- if (!inode) { |
2005 |
+- kfree(name); |
2006 |
+- return -EIO; |
2007 |
+- } |
2008 |
++ di = btrfs_item_ptr(eb, slot, struct btrfs_dir_item); |
2009 |
++ name_len = btrfs_dir_name_len(eb, di); |
2010 |
++ name = kmalloc(name_len, GFP_NOFS); |
2011 |
++ if (!name) { |
2012 |
++ ret = -ENOMEM; |
2013 |
++ goto out; |
2014 |
++ } |
2015 |
+ |
2016 |
+- ret = link_to_fixup_dir(trans, root, |
2017 |
+- path, location.objectid); |
2018 |
+- if (ret) { |
2019 |
+- kfree(name); |
2020 |
+- iput(inode); |
2021 |
+- goto out; |
2022 |
+- } |
2023 |
++ read_extent_buffer(eb, name, (unsigned long)(di + 1), name_len); |
2024 |
+ |
2025 |
+- inc_nlink(inode); |
2026 |
+- ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir), |
2027 |
+- BTRFS_I(inode), name, name_len); |
2028 |
+- if (!ret) |
2029 |
+- ret = btrfs_run_delayed_items(trans); |
2030 |
+- kfree(name); |
2031 |
+- iput(inode); |
2032 |
+- if (ret) |
2033 |
+- goto out; |
2034 |
++ if (log) { |
2035 |
++ struct btrfs_dir_item *log_di; |
2036 |
+ |
2037 |
+- /* there might still be more names under this key |
2038 |
+- * check and repeat if required |
2039 |
+- */ |
2040 |
+- ret = btrfs_search_slot(NULL, root, dir_key, path, |
2041 |
+- 0, 0); |
2042 |
+- if (ret == 0) |
2043 |
+- goto again; |
2044 |
++ log_di = btrfs_lookup_dir_index_item(trans, log, log_path, |
2045 |
++ dir_key->objectid, |
2046 |
++ dir_key->offset, |
2047 |
++ name, name_len, 0); |
2048 |
++ if (IS_ERR(log_di)) { |
2049 |
++ ret = PTR_ERR(log_di); |
2050 |
++ goto out; |
2051 |
++ } else if (log_di) { |
2052 |
++ /* The dentry exists in the log, we have nothing to do. */ |
2053 |
+ ret = 0; |
2054 |
+ goto out; |
2055 |
+- } else if (IS_ERR(log_di)) { |
2056 |
+- kfree(name); |
2057 |
+- return PTR_ERR(log_di); |
2058 |
+ } |
2059 |
+- btrfs_release_path(log_path); |
2060 |
+- kfree(name); |
2061 |
++ } |
2062 |
+ |
2063 |
+- ptr = (unsigned long)(di + 1); |
2064 |
+- ptr += name_len; |
2065 |
++ btrfs_dir_item_key_to_cpu(eb, di, &location); |
2066 |
++ btrfs_release_path(path); |
2067 |
++ btrfs_release_path(log_path); |
2068 |
++ inode = read_one_inode(root, location.objectid); |
2069 |
++ if (!inode) { |
2070 |
++ ret = -EIO; |
2071 |
++ goto out; |
2072 |
+ } |
2073 |
+- ret = 0; |
2074 |
++ |
2075 |
++ ret = link_to_fixup_dir(trans, root, path, location.objectid); |
2076 |
++ if (ret) |
2077 |
++ goto out; |
2078 |
++ |
2079 |
++ inc_nlink(inode); |
2080 |
++ ret = unlink_inode_for_log_replay(trans, BTRFS_I(dir), BTRFS_I(inode), |
2081 |
++ name, name_len); |
2082 |
++ /* |
2083 |
++ * Unlike dir item keys, dir index keys can only have one name (entry) in |
2084 |
++ * them, as there are no key collisions since each key has a unique offset |
2085 |
++ * (an index number), so we're done. |
2086 |
++ */ |
2087 |
+ out: |
2088 |
+ btrfs_release_path(path); |
2089 |
+ btrfs_release_path(log_path); |
2090 |
++ kfree(name); |
2091 |
++ iput(inode); |
2092 |
+ return ret; |
2093 |
+ } |
2094 |
+ |
2095 |
+@@ -2490,7 +2458,6 @@ static noinline int replay_dir_deletes(struct btrfs_trans_handle *trans, |
2096 |
+ { |
2097 |
+ u64 range_start; |
2098 |
+ u64 range_end; |
2099 |
+- int key_type = BTRFS_DIR_LOG_ITEM_KEY; |
2100 |
+ int ret = 0; |
2101 |
+ struct btrfs_key dir_key; |
2102 |
+ struct btrfs_key found_key; |
2103 |
+@@ -2498,7 +2465,7 @@ static noinline int replay_dir_deletes(struct btrfs_trans_handle *trans, |
2104 |
+ struct inode *dir; |
2105 |
+ |
2106 |
+ dir_key.objectid = dirid; |
2107 |
+- dir_key.type = BTRFS_DIR_ITEM_KEY; |
2108 |
++ dir_key.type = BTRFS_DIR_INDEX_KEY; |
2109 |
+ log_path = btrfs_alloc_path(); |
2110 |
+ if (!log_path) |
2111 |
+ return -ENOMEM; |
2112 |
+@@ -2512,14 +2479,14 @@ static noinline int replay_dir_deletes(struct btrfs_trans_handle *trans, |
2113 |
+ btrfs_free_path(log_path); |
2114 |
+ return 0; |
2115 |
+ } |
2116 |
+-again: |
2117 |
++ |
2118 |
+ range_start = 0; |
2119 |
+ range_end = 0; |
2120 |
+ while (1) { |
2121 |
+ if (del_all) |
2122 |
+ range_end = (u64)-1; |
2123 |
+ else { |
2124 |
+- ret = find_dir_range(log, path, dirid, key_type, |
2125 |
++ ret = find_dir_range(log, path, dirid, |
2126 |
+ &range_start, &range_end); |
2127 |
+ if (ret < 0) |
2128 |
+ goto out; |
2129 |
+@@ -2546,8 +2513,10 @@ again: |
2130 |
+ btrfs_item_key_to_cpu(path->nodes[0], &found_key, |
2131 |
+ path->slots[0]); |
2132 |
+ if (found_key.objectid != dirid || |
2133 |
+- found_key.type != dir_key.type) |
2134 |
+- goto next_type; |
2135 |
++ found_key.type != dir_key.type) { |
2136 |
++ ret = 0; |
2137 |
++ goto out; |
2138 |
++ } |
2139 |
+ |
2140 |
+ if (found_key.offset > range_end) |
2141 |
+ break; |
2142 |
+@@ -2566,15 +2535,7 @@ again: |
2143 |
+ break; |
2144 |
+ range_start = range_end + 1; |
2145 |
+ } |
2146 |
+- |
2147 |
+-next_type: |
2148 |
+ ret = 0; |
2149 |
+- if (key_type == BTRFS_DIR_LOG_ITEM_KEY) { |
2150 |
+- key_type = BTRFS_DIR_LOG_INDEX_KEY; |
2151 |
+- dir_key.type = BTRFS_DIR_INDEX_KEY; |
2152 |
+- btrfs_release_path(path); |
2153 |
+- goto again; |
2154 |
+- } |
2155 |
+ out: |
2156 |
+ btrfs_release_path(path); |
2157 |
+ btrfs_free_path(log_path); |
2158 |
+diff --git a/fs/io_uring.c b/fs/io_uring.c |
2159 |
+index 2680e9756b1d4..ed6abd74f3865 100644 |
2160 |
+--- a/fs/io_uring.c |
2161 |
++++ b/fs/io_uring.c |
2162 |
+@@ -486,8 +486,6 @@ struct io_poll_iocb { |
2163 |
+ struct file *file; |
2164 |
+ struct wait_queue_head *head; |
2165 |
+ __poll_t events; |
2166 |
+- bool done; |
2167 |
+- bool canceled; |
2168 |
+ struct wait_queue_entry wait; |
2169 |
+ }; |
2170 |
+ |
2171 |
+@@ -885,6 +883,9 @@ struct io_kiocb { |
2172 |
+ |
2173 |
+ /* store used ubuf, so we can prevent reloading */ |
2174 |
+ struct io_mapped_ubuf *imu; |
2175 |
++ /* stores selected buf, valid IFF REQ_F_BUFFER_SELECTED is set */ |
2176 |
++ struct io_buffer *kbuf; |
2177 |
++ atomic_t poll_refs; |
2178 |
+ }; |
2179 |
+ |
2180 |
+ struct io_tctx_node { |
2181 |
+@@ -1079,8 +1080,8 @@ static void io_uring_try_cancel_requests(struct io_ring_ctx *ctx, |
2182 |
+ bool cancel_all); |
2183 |
+ static void io_uring_cancel_generic(bool cancel_all, struct io_sq_data *sqd); |
2184 |
+ |
2185 |
+-static bool io_cqring_fill_event(struct io_ring_ctx *ctx, u64 user_data, |
2186 |
+- long res, unsigned int cflags); |
2187 |
++static void io_fill_cqe_req(struct io_kiocb *req, s32 res, u32 cflags); |
2188 |
++ |
2189 |
+ static void io_put_req(struct io_kiocb *req); |
2190 |
+ static void io_put_req_deferred(struct io_kiocb *req); |
2191 |
+ static void io_dismantle_req(struct io_kiocb *req); |
2192 |
+@@ -1154,12 +1155,6 @@ static inline bool req_ref_put_and_test(struct io_kiocb *req) |
2193 |
+ return atomic_dec_and_test(&req->refs); |
2194 |
+ } |
2195 |
+ |
2196 |
+-static inline void req_ref_put(struct io_kiocb *req) |
2197 |
+-{ |
2198 |
+- WARN_ON_ONCE(!(req->flags & REQ_F_REFCOUNT)); |
2199 |
+- WARN_ON_ONCE(req_ref_put_and_test(req)); |
2200 |
+-} |
2201 |
+- |
2202 |
+ static inline void req_ref_get(struct io_kiocb *req) |
2203 |
+ { |
2204 |
+ WARN_ON_ONCE(!(req->flags & REQ_F_REFCOUNT)); |
2205 |
+@@ -1515,7 +1510,7 @@ static void io_kill_timeout(struct io_kiocb *req, int status) |
2206 |
+ atomic_set(&req->ctx->cq_timeouts, |
2207 |
+ atomic_read(&req->ctx->cq_timeouts) + 1); |
2208 |
+ list_del_init(&req->timeout.list); |
2209 |
+- io_cqring_fill_event(req->ctx, req->user_data, status, 0); |
2210 |
++ io_fill_cqe_req(req, status, 0); |
2211 |
+ io_put_req_deferred(req); |
2212 |
+ } |
2213 |
+ } |
2214 |
+@@ -1763,7 +1758,7 @@ static __cold void io_uring_drop_tctx_refs(struct task_struct *task) |
2215 |
+ } |
2216 |
+ |
2217 |
+ static bool io_cqring_event_overflow(struct io_ring_ctx *ctx, u64 user_data, |
2218 |
+- long res, unsigned int cflags) |
2219 |
++ s32 res, u32 cflags) |
2220 |
+ { |
2221 |
+ struct io_overflow_cqe *ocqe; |
2222 |
+ |
2223 |
+@@ -1790,8 +1785,8 @@ static bool io_cqring_event_overflow(struct io_ring_ctx *ctx, u64 user_data, |
2224 |
+ return true; |
2225 |
+ } |
2226 |
+ |
2227 |
+-static inline bool __io_cqring_fill_event(struct io_ring_ctx *ctx, u64 user_data, |
2228 |
+- long res, unsigned int cflags) |
2229 |
++static inline bool __io_fill_cqe(struct io_ring_ctx *ctx, u64 user_data, |
2230 |
++ s32 res, u32 cflags) |
2231 |
+ { |
2232 |
+ struct io_uring_cqe *cqe; |
2233 |
+ |
2234 |
+@@ -1812,20 +1807,25 @@ static inline bool __io_cqring_fill_event(struct io_ring_ctx *ctx, u64 user_data |
2235 |
+ return io_cqring_event_overflow(ctx, user_data, res, cflags); |
2236 |
+ } |
2237 |
+ |
2238 |
+-/* not as hot to bloat with inlining */ |
2239 |
+-static noinline bool io_cqring_fill_event(struct io_ring_ctx *ctx, u64 user_data, |
2240 |
+- long res, unsigned int cflags) |
2241 |
++static noinline void io_fill_cqe_req(struct io_kiocb *req, s32 res, u32 cflags) |
2242 |
+ { |
2243 |
+- return __io_cqring_fill_event(ctx, user_data, res, cflags); |
2244 |
++ __io_fill_cqe(req->ctx, req->user_data, res, cflags); |
2245 |
+ } |
2246 |
+ |
2247 |
+-static void io_req_complete_post(struct io_kiocb *req, long res, |
2248 |
+- unsigned int cflags) |
2249 |
++static noinline bool io_fill_cqe_aux(struct io_ring_ctx *ctx, u64 user_data, |
2250 |
++ s32 res, u32 cflags) |
2251 |
++{ |
2252 |
++ ctx->cq_extra++; |
2253 |
++ return __io_fill_cqe(ctx, user_data, res, cflags); |
2254 |
++} |
2255 |
++ |
2256 |
++static void io_req_complete_post(struct io_kiocb *req, s32 res, |
2257 |
++ u32 cflags) |
2258 |
+ { |
2259 |
+ struct io_ring_ctx *ctx = req->ctx; |
2260 |
+ |
2261 |
+ spin_lock(&ctx->completion_lock); |
2262 |
+- __io_cqring_fill_event(ctx, req->user_data, res, cflags); |
2263 |
++ __io_fill_cqe(ctx, req->user_data, res, cflags); |
2264 |
+ /* |
2265 |
+ * If we're the last reference to this request, add to our locked |
2266 |
+ * free_list cache. |
2267 |
+@@ -1861,8 +1861,8 @@ static inline bool io_req_needs_clean(struct io_kiocb *req) |
2268 |
+ return req->flags & IO_REQ_CLEAN_FLAGS; |
2269 |
+ } |
2270 |
+ |
2271 |
+-static void io_req_complete_state(struct io_kiocb *req, long res, |
2272 |
+- unsigned int cflags) |
2273 |
++static inline void io_req_complete_state(struct io_kiocb *req, s32 res, |
2274 |
++ u32 cflags) |
2275 |
+ { |
2276 |
+ if (io_req_needs_clean(req)) |
2277 |
+ io_clean_op(req); |
2278 |
+@@ -1872,7 +1872,7 @@ static void io_req_complete_state(struct io_kiocb *req, long res, |
2279 |
+ } |
2280 |
+ |
2281 |
+ static inline void __io_req_complete(struct io_kiocb *req, unsigned issue_flags, |
2282 |
+- long res, unsigned cflags) |
2283 |
++ s32 res, u32 cflags) |
2284 |
+ { |
2285 |
+ if (issue_flags & IO_URING_F_COMPLETE_DEFER) |
2286 |
+ io_req_complete_state(req, res, cflags); |
2287 |
+@@ -1880,12 +1880,12 @@ static inline void __io_req_complete(struct io_kiocb *req, unsigned issue_flags, |
2288 |
+ io_req_complete_post(req, res, cflags); |
2289 |
+ } |
2290 |
+ |
2291 |
+-static inline void io_req_complete(struct io_kiocb *req, long res) |
2292 |
++static inline void io_req_complete(struct io_kiocb *req, s32 res) |
2293 |
+ { |
2294 |
+ __io_req_complete(req, 0, res, 0); |
2295 |
+ } |
2296 |
+ |
2297 |
+-static void io_req_complete_failed(struct io_kiocb *req, long res) |
2298 |
++static void io_req_complete_failed(struct io_kiocb *req, s32 res) |
2299 |
+ { |
2300 |
+ req_set_fail(req); |
2301 |
+ io_req_complete_post(req, res, 0); |
2302 |
+@@ -2051,8 +2051,7 @@ static bool io_kill_linked_timeout(struct io_kiocb *req) |
2303 |
+ link->timeout.head = NULL; |
2304 |
+ if (hrtimer_try_to_cancel(&io->timer) != -1) { |
2305 |
+ list_del(&link->timeout.list); |
2306 |
+- io_cqring_fill_event(link->ctx, link->user_data, |
2307 |
+- -ECANCELED, 0); |
2308 |
++ io_fill_cqe_req(link, -ECANCELED, 0); |
2309 |
+ io_put_req_deferred(link); |
2310 |
+ return true; |
2311 |
+ } |
2312 |
+@@ -2076,7 +2075,7 @@ static void io_fail_links(struct io_kiocb *req) |
2313 |
+ link->link = NULL; |
2314 |
+ |
2315 |
+ trace_io_uring_fail_link(req, link); |
2316 |
+- io_cqring_fill_event(link->ctx, link->user_data, res, 0); |
2317 |
++ io_fill_cqe_req(link, res, 0); |
2318 |
+ io_put_req_deferred(link); |
2319 |
+ link = nxt; |
2320 |
+ } |
2321 |
+@@ -2093,8 +2092,7 @@ static bool io_disarm_next(struct io_kiocb *req) |
2322 |
+ req->flags &= ~REQ_F_ARM_LTIMEOUT; |
2323 |
+ if (link && link->opcode == IORING_OP_LINK_TIMEOUT) { |
2324 |
+ io_remove_next_linked(req); |
2325 |
+- io_cqring_fill_event(link->ctx, link->user_data, |
2326 |
+- -ECANCELED, 0); |
2327 |
++ io_fill_cqe_req(link, -ECANCELED, 0); |
2328 |
+ io_put_req_deferred(link); |
2329 |
+ posted = true; |
2330 |
+ } |
2331 |
+@@ -2370,8 +2368,8 @@ static void io_submit_flush_completions(struct io_ring_ctx *ctx) |
2332 |
+ for (i = 0; i < nr; i++) { |
2333 |
+ struct io_kiocb *req = state->compl_reqs[i]; |
2334 |
+ |
2335 |
+- __io_cqring_fill_event(ctx, req->user_data, req->result, |
2336 |
+- req->compl.cflags); |
2337 |
++ __io_fill_cqe(ctx, req->user_data, req->result, |
2338 |
++ req->compl.cflags); |
2339 |
+ } |
2340 |
+ io_commit_cqring(ctx); |
2341 |
+ spin_unlock(&ctx->completion_lock); |
2342 |
+@@ -2482,8 +2480,7 @@ static void io_iopoll_complete(struct io_ring_ctx *ctx, unsigned int *nr_events, |
2343 |
+ req = list_first_entry(done, struct io_kiocb, inflight_entry); |
2344 |
+ list_del(&req->inflight_entry); |
2345 |
+ |
2346 |
+- __io_cqring_fill_event(ctx, req->user_data, req->result, |
2347 |
+- io_put_rw_kbuf(req)); |
2348 |
++ io_fill_cqe_req(req, req->result, io_put_rw_kbuf(req)); |
2349 |
+ (*nr_events)++; |
2350 |
+ |
2351 |
+ if (req_ref_put_and_test(req)) |
2352 |
+@@ -2707,7 +2704,7 @@ static bool __io_complete_rw_common(struct io_kiocb *req, long res) |
2353 |
+ static void io_req_task_complete(struct io_kiocb *req, bool *locked) |
2354 |
+ { |
2355 |
+ unsigned int cflags = io_put_rw_kbuf(req); |
2356 |
+- long res = req->result; |
2357 |
++ int res = req->result; |
2358 |
+ |
2359 |
+ if (*locked) { |
2360 |
+ struct io_ring_ctx *ctx = req->ctx; |
2361 |
+@@ -5316,52 +5313,23 @@ struct io_poll_table { |
2362 |
+ int error; |
2363 |
+ }; |
2364 |
+ |
2365 |
+-static int __io_async_wake(struct io_kiocb *req, struct io_poll_iocb *poll, |
2366 |
+- __poll_t mask, io_req_tw_func_t func) |
2367 |
+-{ |
2368 |
+- /* for instances that support it check for an event match first: */ |
2369 |
+- if (mask && !(mask & poll->events)) |
2370 |
+- return 0; |
2371 |
+- |
2372 |
+- trace_io_uring_task_add(req->ctx, req->opcode, req->user_data, mask); |
2373 |
+- |
2374 |
+- list_del_init(&poll->wait.entry); |
2375 |
++#define IO_POLL_CANCEL_FLAG BIT(31) |
2376 |
++#define IO_POLL_REF_MASK GENMASK(30, 0) |
2377 |
+ |
2378 |
+- req->result = mask; |
2379 |
+- req->io_task_work.func = func; |
2380 |
+- |
2381 |
+- /* |
2382 |
+- * If this fails, then the task is exiting. When a task exits, the |
2383 |
+- * work gets canceled, so just cancel this request as well instead |
2384 |
+- * of executing it. We can't safely execute it anyway, as we may not |
2385 |
+- * have the needed state needed for it anyway. |
2386 |
+- */ |
2387 |
+- io_req_task_work_add(req); |
2388 |
+- return 1; |
2389 |
++/* |
2390 |
++ * If refs part of ->poll_refs (see IO_POLL_REF_MASK) is 0, it's free. We can |
2391 |
++ * bump it and acquire ownership. It's disallowed to modify requests while not |
2392 |
++ * owning it, that prevents from races for enqueueing task_work's and b/w |
2393 |
++ * arming poll and wakeups. |
2394 |
++ */ |
2395 |
++static inline bool io_poll_get_ownership(struct io_kiocb *req) |
2396 |
++{ |
2397 |
++ return !(atomic_fetch_inc(&req->poll_refs) & IO_POLL_REF_MASK); |
2398 |
+ } |
2399 |
+ |
2400 |
+-static bool io_poll_rewait(struct io_kiocb *req, struct io_poll_iocb *poll) |
2401 |
+- __acquires(&req->ctx->completion_lock) |
2402 |
++static void io_poll_mark_cancelled(struct io_kiocb *req) |
2403 |
+ { |
2404 |
+- struct io_ring_ctx *ctx = req->ctx; |
2405 |
+- |
2406 |
+- /* req->task == current here, checking PF_EXITING is safe */ |
2407 |
+- if (unlikely(req->task->flags & PF_EXITING)) |
2408 |
+- WRITE_ONCE(poll->canceled, true); |
2409 |
+- |
2410 |
+- if (!req->result && !READ_ONCE(poll->canceled)) { |
2411 |
+- struct poll_table_struct pt = { ._key = poll->events }; |
2412 |
+- |
2413 |
+- req->result = vfs_poll(req->file, &pt) & poll->events; |
2414 |
+- } |
2415 |
+- |
2416 |
+- spin_lock(&ctx->completion_lock); |
2417 |
+- if (!req->result && !READ_ONCE(poll->canceled)) { |
2418 |
+- add_wait_queue(poll->head, &poll->wait); |
2419 |
+- return true; |
2420 |
+- } |
2421 |
+- |
2422 |
+- return false; |
2423 |
++ atomic_or(IO_POLL_CANCEL_FLAG, &req->poll_refs); |
2424 |
+ } |
2425 |
+ |
2426 |
+ static struct io_poll_iocb *io_poll_get_double(struct io_kiocb *req) |
2427 |
+@@ -5379,141 +5347,231 @@ static struct io_poll_iocb *io_poll_get_single(struct io_kiocb *req) |
2428 |
+ return &req->apoll->poll; |
2429 |
+ } |
2430 |
+ |
2431 |
+-static void io_poll_remove_double(struct io_kiocb *req) |
2432 |
+- __must_hold(&req->ctx->completion_lock) |
2433 |
++static void io_poll_req_insert(struct io_kiocb *req) |
2434 |
+ { |
2435 |
+- struct io_poll_iocb *poll = io_poll_get_double(req); |
2436 |
++ struct io_ring_ctx *ctx = req->ctx; |
2437 |
++ struct hlist_head *list; |
2438 |
+ |
2439 |
+- lockdep_assert_held(&req->ctx->completion_lock); |
2440 |
++ list = &ctx->cancel_hash[hash_long(req->user_data, ctx->cancel_hash_bits)]; |
2441 |
++ hlist_add_head(&req->hash_node, list); |
2442 |
++} |
2443 |
+ |
2444 |
+- if (poll && poll->head) { |
2445 |
+- struct wait_queue_head *head = poll->head; |
2446 |
++static void io_init_poll_iocb(struct io_poll_iocb *poll, __poll_t events, |
2447 |
++ wait_queue_func_t wake_func) |
2448 |
++{ |
2449 |
++ poll->head = NULL; |
2450 |
++#define IO_POLL_UNMASK (EPOLLERR|EPOLLHUP|EPOLLNVAL|EPOLLRDHUP) |
2451 |
++ /* mask in events that we always want/need */ |
2452 |
++ poll->events = events | IO_POLL_UNMASK; |
2453 |
++ INIT_LIST_HEAD(&poll->wait.entry); |
2454 |
++ init_waitqueue_func_entry(&poll->wait, wake_func); |
2455 |
++} |
2456 |
+ |
2457 |
++static inline void io_poll_remove_entry(struct io_poll_iocb *poll) |
2458 |
++{ |
2459 |
++ struct wait_queue_head *head = smp_load_acquire(&poll->head); |
2460 |
++ |
2461 |
++ if (head) { |
2462 |
+ spin_lock_irq(&head->lock); |
2463 |
+ list_del_init(&poll->wait.entry); |
2464 |
+- if (poll->wait.private) |
2465 |
+- req_ref_put(req); |
2466 |
+ poll->head = NULL; |
2467 |
+ spin_unlock_irq(&head->lock); |
2468 |
+ } |
2469 |
+ } |
2470 |
+ |
2471 |
+-static bool __io_poll_complete(struct io_kiocb *req, __poll_t mask) |
2472 |
+- __must_hold(&req->ctx->completion_lock) |
2473 |
++static void io_poll_remove_entries(struct io_kiocb *req) |
2474 |
++{ |
2475 |
++ struct io_poll_iocb *poll = io_poll_get_single(req); |
2476 |
++ struct io_poll_iocb *poll_double = io_poll_get_double(req); |
2477 |
++ |
2478 |
++ /* |
2479 |
++ * While we hold the waitqueue lock and the waitqueue is nonempty, |
2480 |
++ * wake_up_pollfree() will wait for us. However, taking the waitqueue |
2481 |
++ * lock in the first place can race with the waitqueue being freed. |
2482 |
++ * |
2483 |
++ * We solve this as eventpoll does: by taking advantage of the fact that |
2484 |
++ * all users of wake_up_pollfree() will RCU-delay the actual free. If |
2485 |
++ * we enter rcu_read_lock() and see that the pointer to the queue is |
2486 |
++ * non-NULL, we can then lock it without the memory being freed out from |
2487 |
++ * under us. |
2488 |
++ * |
2489 |
++ * Keep holding rcu_read_lock() as long as we hold the queue lock, in |
2490 |
++ * case the caller deletes the entry from the queue, leaving it empty. |
2491 |
++ * In that case, only RCU prevents the queue memory from being freed. |
2492 |
++ */ |
2493 |
++ rcu_read_lock(); |
2494 |
++ io_poll_remove_entry(poll); |
2495 |
++ if (poll_double) |
2496 |
++ io_poll_remove_entry(poll_double); |
2497 |
++ rcu_read_unlock(); |
2498 |
++} |
2499 |
++ |
2500 |
++/* |
2501 |
++ * All poll tw should go through this. Checks for poll events, manages |
2502 |
++ * references, does rewait, etc. |
2503 |
++ * |
2504 |
++ * Returns a negative error on failure. >0 when no action require, which is |
2505 |
++ * either spurious wakeup or multishot CQE is served. 0 when it's done with |
2506 |
++ * the request, then the mask is stored in req->result. |
2507 |
++ */ |
2508 |
++static int io_poll_check_events(struct io_kiocb *req) |
2509 |
+ { |
2510 |
+ struct io_ring_ctx *ctx = req->ctx; |
2511 |
+- unsigned flags = IORING_CQE_F_MORE; |
2512 |
+- int error; |
2513 |
++ struct io_poll_iocb *poll = io_poll_get_single(req); |
2514 |
++ int v; |
2515 |
++ |
2516 |
++ /* req->task == current here, checking PF_EXITING is safe */ |
2517 |
++ if (unlikely(req->task->flags & PF_EXITING)) |
2518 |
++ io_poll_mark_cancelled(req); |
2519 |
++ |
2520 |
++ do { |
2521 |
++ v = atomic_read(&req->poll_refs); |
2522 |
++ |
2523 |
++ /* tw handler should be the owner, and so have some references */ |
2524 |
++ if (WARN_ON_ONCE(!(v & IO_POLL_REF_MASK))) |
2525 |
++ return 0; |
2526 |
++ if (v & IO_POLL_CANCEL_FLAG) |
2527 |
++ return -ECANCELED; |
2528 |
++ |
2529 |
++ if (!req->result) { |
2530 |
++ struct poll_table_struct pt = { ._key = poll->events }; |
2531 |
++ |
2532 |
++ req->result = vfs_poll(req->file, &pt) & poll->events; |
2533 |
++ } |
2534 |
++ |
2535 |
++ /* multishot, just fill an CQE and proceed */ |
2536 |
++ if (req->result && !(poll->events & EPOLLONESHOT)) { |
2537 |
++ __poll_t mask = mangle_poll(req->result & poll->events); |
2538 |
++ bool filled; |
2539 |
+ |
2540 |
+- if (READ_ONCE(req->poll.canceled)) { |
2541 |
+- error = -ECANCELED; |
2542 |
+- req->poll.events |= EPOLLONESHOT; |
2543 |
++ spin_lock(&ctx->completion_lock); |
2544 |
++ filled = io_fill_cqe_aux(ctx, req->user_data, mask, |
2545 |
++ IORING_CQE_F_MORE); |
2546 |
++ io_commit_cqring(ctx); |
2547 |
++ spin_unlock(&ctx->completion_lock); |
2548 |
++ if (unlikely(!filled)) |
2549 |
++ return -ECANCELED; |
2550 |
++ io_cqring_ev_posted(ctx); |
2551 |
++ } else if (req->result) { |
2552 |
++ return 0; |
2553 |
++ } |
2554 |
++ |
2555 |
++ /* |
2556 |
++ * Release all references, retry if someone tried to restart |
2557 |
++ * task_work while we were executing it. |
2558 |
++ */ |
2559 |
++ } while (atomic_sub_return(v & IO_POLL_REF_MASK, &req->poll_refs)); |
2560 |
++ |
2561 |
++ return 1; |
2562 |
++} |
2563 |
++ |
2564 |
++static void io_poll_task_func(struct io_kiocb *req, bool *locked) |
2565 |
++{ |
2566 |
++ struct io_ring_ctx *ctx = req->ctx; |
2567 |
++ int ret; |
2568 |
++ |
2569 |
++ ret = io_poll_check_events(req); |
2570 |
++ if (ret > 0) |
2571 |
++ return; |
2572 |
++ |
2573 |
++ if (!ret) { |
2574 |
++ req->result = mangle_poll(req->result & req->poll.events); |
2575 |
+ } else { |
2576 |
+- error = mangle_poll(mask); |
2577 |
+- } |
2578 |
+- if (req->poll.events & EPOLLONESHOT) |
2579 |
+- flags = 0; |
2580 |
+- if (!io_cqring_fill_event(ctx, req->user_data, error, flags)) { |
2581 |
+- req->poll.events |= EPOLLONESHOT; |
2582 |
+- flags = 0; |
2583 |
++ req->result = ret; |
2584 |
++ req_set_fail(req); |
2585 |
+ } |
2586 |
+- if (flags & IORING_CQE_F_MORE) |
2587 |
+- ctx->cq_extra++; |
2588 |
+ |
2589 |
+- return !(flags & IORING_CQE_F_MORE); |
2590 |
++ io_poll_remove_entries(req); |
2591 |
++ spin_lock(&ctx->completion_lock); |
2592 |
++ hash_del(&req->hash_node); |
2593 |
++ spin_unlock(&ctx->completion_lock); |
2594 |
++ io_req_complete_post(req, req->result, 0); |
2595 |
+ } |
2596 |
+ |
2597 |
+-static inline bool io_poll_complete(struct io_kiocb *req, __poll_t mask) |
2598 |
+- __must_hold(&req->ctx->completion_lock) |
2599 |
++static void io_apoll_task_func(struct io_kiocb *req, bool *locked) |
2600 |
+ { |
2601 |
+- bool done; |
2602 |
++ struct io_ring_ctx *ctx = req->ctx; |
2603 |
++ int ret; |
2604 |
+ |
2605 |
+- done = __io_poll_complete(req, mask); |
2606 |
+- io_commit_cqring(req->ctx); |
2607 |
+- return done; |
2608 |
++ ret = io_poll_check_events(req); |
2609 |
++ if (ret > 0) |
2610 |
++ return; |
2611 |
++ |
2612 |
++ io_poll_remove_entries(req); |
2613 |
++ spin_lock(&ctx->completion_lock); |
2614 |
++ hash_del(&req->hash_node); |
2615 |
++ spin_unlock(&ctx->completion_lock); |
2616 |
++ |
2617 |
++ if (!ret) |
2618 |
++ io_req_task_submit(req, locked); |
2619 |
++ else |
2620 |
++ io_req_complete_failed(req, ret); |
2621 |
+ } |
2622 |
+ |
2623 |
+-static void io_poll_task_func(struct io_kiocb *req, bool *locked) |
2624 |
++static void __io_poll_execute(struct io_kiocb *req, int mask) |
2625 |
+ { |
2626 |
+- struct io_ring_ctx *ctx = req->ctx; |
2627 |
+- struct io_kiocb *nxt; |
2628 |
++ req->result = mask; |
2629 |
++ if (req->opcode == IORING_OP_POLL_ADD) |
2630 |
++ req->io_task_work.func = io_poll_task_func; |
2631 |
++ else |
2632 |
++ req->io_task_work.func = io_apoll_task_func; |
2633 |
+ |
2634 |
+- if (io_poll_rewait(req, &req->poll)) { |
2635 |
+- spin_unlock(&ctx->completion_lock); |
2636 |
+- } else { |
2637 |
+- bool done; |
2638 |
++ trace_io_uring_task_add(req->ctx, req->opcode, req->user_data, mask); |
2639 |
++ io_req_task_work_add(req); |
2640 |
++} |
2641 |
+ |
2642 |
+- if (req->poll.done) { |
2643 |
+- spin_unlock(&ctx->completion_lock); |
2644 |
+- return; |
2645 |
+- } |
2646 |
+- done = __io_poll_complete(req, req->result); |
2647 |
+- if (done) { |
2648 |
+- io_poll_remove_double(req); |
2649 |
+- hash_del(&req->hash_node); |
2650 |
+- req->poll.done = true; |
2651 |
+- } else { |
2652 |
+- req->result = 0; |
2653 |
+- add_wait_queue(req->poll.head, &req->poll.wait); |
2654 |
+- } |
2655 |
+- io_commit_cqring(ctx); |
2656 |
+- spin_unlock(&ctx->completion_lock); |
2657 |
+- io_cqring_ev_posted(ctx); |
2658 |
++static inline void io_poll_execute(struct io_kiocb *req, int res) |
2659 |
++{ |
2660 |
++ if (io_poll_get_ownership(req)) |
2661 |
++ __io_poll_execute(req, res); |
2662 |
++} |
2663 |
+ |
2664 |
+- if (done) { |
2665 |
+- nxt = io_put_req_find_next(req); |
2666 |
+- if (nxt) |
2667 |
+- io_req_task_submit(nxt, locked); |
2668 |
+- } |
2669 |
+- } |
2670 |
++static void io_poll_cancel_req(struct io_kiocb *req) |
2671 |
++{ |
2672 |
++ io_poll_mark_cancelled(req); |
2673 |
++ /* kick tw, which should complete the request */ |
2674 |
++ io_poll_execute(req, 0); |
2675 |
+ } |
2676 |
+ |
2677 |
+-static int io_poll_double_wake(struct wait_queue_entry *wait, unsigned mode, |
2678 |
+- int sync, void *key) |
2679 |
++static int io_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync, |
2680 |
++ void *key) |
2681 |
+ { |
2682 |
+ struct io_kiocb *req = wait->private; |
2683 |
+- struct io_poll_iocb *poll = io_poll_get_single(req); |
2684 |
++ struct io_poll_iocb *poll = container_of(wait, struct io_poll_iocb, |
2685 |
++ wait); |
2686 |
+ __poll_t mask = key_to_poll(key); |
2687 |
+- unsigned long flags; |
2688 |
+ |
2689 |
+- /* for instances that support it check for an event match first: */ |
2690 |
+- if (mask && !(mask & poll->events)) |
2691 |
+- return 0; |
2692 |
+- if (!(poll->events & EPOLLONESHOT)) |
2693 |
+- return poll->wait.func(&poll->wait, mode, sync, key); |
2694 |
++ if (unlikely(mask & POLLFREE)) { |
2695 |
++ io_poll_mark_cancelled(req); |
2696 |
++ /* we have to kick tw in case it's not already */ |
2697 |
++ io_poll_execute(req, 0); |
2698 |
+ |
2699 |
+- list_del_init(&wait->entry); |
2700 |
++ /* |
2701 |
++ * If the waitqueue is being freed early but someone is already |
2702 |
++ * holds ownership over it, we have to tear down the request as |
2703 |
++ * best we can. That means immediately removing the request from |
2704 |
++ * its waitqueue and preventing all further accesses to the |
2705 |
++ * waitqueue via the request. |
2706 |
++ */ |
2707 |
++ list_del_init(&poll->wait.entry); |
2708 |
+ |
2709 |
+- if (poll->head) { |
2710 |
+- bool done; |
2711 |
+- |
2712 |
+- spin_lock_irqsave(&poll->head->lock, flags); |
2713 |
+- done = list_empty(&poll->wait.entry); |
2714 |
+- if (!done) |
2715 |
+- list_del_init(&poll->wait.entry); |
2716 |
+- /* make sure double remove sees this as being gone */ |
2717 |
+- wait->private = NULL; |
2718 |
+- spin_unlock_irqrestore(&poll->head->lock, flags); |
2719 |
+- if (!done) { |
2720 |
+- /* use wait func handler, so it matches the rq type */ |
2721 |
+- poll->wait.func(&poll->wait, mode, sync, key); |
2722 |
+- } |
2723 |
++ /* |
2724 |
++ * Careful: this *must* be the last step, since as soon |
2725 |
++ * as req->head is NULL'ed out, the request can be |
2726 |
++ * completed and freed, since aio_poll_complete_work() |
2727 |
++ * will no longer need to take the waitqueue lock. |
2728 |
++ */ |
2729 |
++ smp_store_release(&poll->head, NULL); |
2730 |
++ return 1; |
2731 |
+ } |
2732 |
+- req_ref_put(req); |
2733 |
+- return 1; |
2734 |
+-} |
2735 |
+ |
2736 |
+-static void io_init_poll_iocb(struct io_poll_iocb *poll, __poll_t events, |
2737 |
+- wait_queue_func_t wake_func) |
2738 |
+-{ |
2739 |
+- poll->head = NULL; |
2740 |
+- poll->done = false; |
2741 |
+- poll->canceled = false; |
2742 |
+-#define IO_POLL_UNMASK (EPOLLERR|EPOLLHUP|EPOLLNVAL|EPOLLRDHUP) |
2743 |
+- /* mask in events that we always want/need */ |
2744 |
+- poll->events = events | IO_POLL_UNMASK; |
2745 |
+- INIT_LIST_HEAD(&poll->wait.entry); |
2746 |
+- init_waitqueue_func_entry(&poll->wait, wake_func); |
2747 |
++ /* for instances that support it check for an event match first */ |
2748 |
++ if (mask && !(mask & poll->events)) |
2749 |
++ return 0; |
2750 |
++ |
2751 |
++ if (io_poll_get_ownership(req)) |
2752 |
++ __io_poll_execute(req, mask); |
2753 |
++ return 1; |
2754 |
+ } |
2755 |
+ |
2756 |
+ static void __io_queue_proc(struct io_poll_iocb *poll, struct io_poll_table *pt, |
2757 |
+@@ -5528,10 +5586,10 @@ static void __io_queue_proc(struct io_poll_iocb *poll, struct io_poll_table *pt, |
2758 |
+ * if this happens. |
2759 |
+ */ |
2760 |
+ if (unlikely(pt->nr_entries)) { |
2761 |
+- struct io_poll_iocb *poll_one = poll; |
2762 |
++ struct io_poll_iocb *first = poll; |
2763 |
+ |
2764 |
+ /* double add on the same waitqueue head, ignore */ |
2765 |
+- if (poll_one->head == head) |
2766 |
++ if (first->head == head) |
2767 |
+ return; |
2768 |
+ /* already have a 2nd entry, fail a third attempt */ |
2769 |
+ if (*poll_ptr) { |
2770 |
+@@ -5540,25 +5598,19 @@ static void __io_queue_proc(struct io_poll_iocb *poll, struct io_poll_table *pt, |
2771 |
+ pt->error = -EINVAL; |
2772 |
+ return; |
2773 |
+ } |
2774 |
+- /* |
2775 |
+- * Can't handle multishot for double wait for now, turn it |
2776 |
+- * into one-shot mode. |
2777 |
+- */ |
2778 |
+- if (!(poll_one->events & EPOLLONESHOT)) |
2779 |
+- poll_one->events |= EPOLLONESHOT; |
2780 |
++ |
2781 |
+ poll = kmalloc(sizeof(*poll), GFP_ATOMIC); |
2782 |
+ if (!poll) { |
2783 |
+ pt->error = -ENOMEM; |
2784 |
+ return; |
2785 |
+ } |
2786 |
+- io_init_poll_iocb(poll, poll_one->events, io_poll_double_wake); |
2787 |
+- req_ref_get(req); |
2788 |
+- poll->wait.private = req; |
2789 |
++ io_init_poll_iocb(poll, first->events, first->wait.func); |
2790 |
+ *poll_ptr = poll; |
2791 |
+ } |
2792 |
+ |
2793 |
+ pt->nr_entries++; |
2794 |
+ poll->head = head; |
2795 |
++ poll->wait.private = req; |
2796 |
+ |
2797 |
+ if (poll->events & EPOLLEXCLUSIVE) |
2798 |
+ add_wait_queue_exclusive(head, &poll->wait); |
2799 |
+@@ -5566,70 +5618,24 @@ static void __io_queue_proc(struct io_poll_iocb *poll, struct io_poll_table *pt, |
2800 |
+ add_wait_queue(head, &poll->wait); |
2801 |
+ } |
2802 |
+ |
2803 |
+-static void io_async_queue_proc(struct file *file, struct wait_queue_head *head, |
2804 |
++static void io_poll_queue_proc(struct file *file, struct wait_queue_head *head, |
2805 |
+ struct poll_table_struct *p) |
2806 |
+ { |
2807 |
+ struct io_poll_table *pt = container_of(p, struct io_poll_table, pt); |
2808 |
+- struct async_poll *apoll = pt->req->apoll; |
2809 |
+- |
2810 |
+- __io_queue_proc(&apoll->poll, pt, head, &apoll->double_poll); |
2811 |
+-} |
2812 |
+- |
2813 |
+-static void io_async_task_func(struct io_kiocb *req, bool *locked) |
2814 |
+-{ |
2815 |
+- struct async_poll *apoll = req->apoll; |
2816 |
+- struct io_ring_ctx *ctx = req->ctx; |
2817 |
+- |
2818 |
+- trace_io_uring_task_run(req->ctx, req, req->opcode, req->user_data); |
2819 |
+ |
2820 |
+- if (io_poll_rewait(req, &apoll->poll)) { |
2821 |
+- spin_unlock(&ctx->completion_lock); |
2822 |
+- return; |
2823 |
+- } |
2824 |
+- |
2825 |
+- hash_del(&req->hash_node); |
2826 |
+- io_poll_remove_double(req); |
2827 |
+- apoll->poll.done = true; |
2828 |
+- spin_unlock(&ctx->completion_lock); |
2829 |
+- |
2830 |
+- if (!READ_ONCE(apoll->poll.canceled)) |
2831 |
+- io_req_task_submit(req, locked); |
2832 |
+- else |
2833 |
+- io_req_complete_failed(req, -ECANCELED); |
2834 |
+-} |
2835 |
+- |
2836 |
+-static int io_async_wake(struct wait_queue_entry *wait, unsigned mode, int sync, |
2837 |
+- void *key) |
2838 |
+-{ |
2839 |
+- struct io_kiocb *req = wait->private; |
2840 |
+- struct io_poll_iocb *poll = &req->apoll->poll; |
2841 |
+- |
2842 |
+- trace_io_uring_poll_wake(req->ctx, req->opcode, req->user_data, |
2843 |
+- key_to_poll(key)); |
2844 |
+- |
2845 |
+- return __io_async_wake(req, poll, key_to_poll(key), io_async_task_func); |
2846 |
++ __io_queue_proc(&pt->req->poll, pt, head, |
2847 |
++ (struct io_poll_iocb **) &pt->req->async_data); |
2848 |
+ } |
2849 |
+ |
2850 |
+-static void io_poll_req_insert(struct io_kiocb *req) |
2851 |
++static int __io_arm_poll_handler(struct io_kiocb *req, |
2852 |
++ struct io_poll_iocb *poll, |
2853 |
++ struct io_poll_table *ipt, __poll_t mask) |
2854 |
+ { |
2855 |
+ struct io_ring_ctx *ctx = req->ctx; |
2856 |
+- struct hlist_head *list; |
2857 |
+- |
2858 |
+- list = &ctx->cancel_hash[hash_long(req->user_data, ctx->cancel_hash_bits)]; |
2859 |
+- hlist_add_head(&req->hash_node, list); |
2860 |
+-} |
2861 |
+- |
2862 |
+-static __poll_t __io_arm_poll_handler(struct io_kiocb *req, |
2863 |
+- struct io_poll_iocb *poll, |
2864 |
+- struct io_poll_table *ipt, __poll_t mask, |
2865 |
+- wait_queue_func_t wake_func) |
2866 |
+- __acquires(&ctx->completion_lock) |
2867 |
+-{ |
2868 |
+- struct io_ring_ctx *ctx = req->ctx; |
2869 |
+- bool cancel = false; |
2870 |
++ int v; |
2871 |
+ |
2872 |
+ INIT_HLIST_NODE(&req->hash_node); |
2873 |
+- io_init_poll_iocb(poll, mask, wake_func); |
2874 |
++ io_init_poll_iocb(poll, mask, io_poll_wake); |
2875 |
+ poll->file = req->file; |
2876 |
+ poll->wait.private = req; |
2877 |
+ |
2878 |
+@@ -5638,31 +5644,56 @@ static __poll_t __io_arm_poll_handler(struct io_kiocb *req, |
2879 |
+ ipt->error = 0; |
2880 |
+ ipt->nr_entries = 0; |
2881 |
+ |
2882 |
++ /* |
2883 |
++ * Take the ownership to delay any tw execution up until we're done |
2884 |
++ * with poll arming. see io_poll_get_ownership(). |
2885 |
++ */ |
2886 |
++ atomic_set(&req->poll_refs, 1); |
2887 |
+ mask = vfs_poll(req->file, &ipt->pt) & poll->events; |
2888 |
+- if (unlikely(!ipt->nr_entries) && !ipt->error) |
2889 |
+- ipt->error = -EINVAL; |
2890 |
++ |
2891 |
++ if (mask && (poll->events & EPOLLONESHOT)) { |
2892 |
++ io_poll_remove_entries(req); |
2893 |
++ /* no one else has access to the req, forget about the ref */ |
2894 |
++ return mask; |
2895 |
++ } |
2896 |
++ if (!mask && unlikely(ipt->error || !ipt->nr_entries)) { |
2897 |
++ io_poll_remove_entries(req); |
2898 |
++ if (!ipt->error) |
2899 |
++ ipt->error = -EINVAL; |
2900 |
++ return 0; |
2901 |
++ } |
2902 |
+ |
2903 |
+ spin_lock(&ctx->completion_lock); |
2904 |
+- if (ipt->error || (mask && (poll->events & EPOLLONESHOT))) |
2905 |
+- io_poll_remove_double(req); |
2906 |
+- if (likely(poll->head)) { |
2907 |
+- spin_lock_irq(&poll->head->lock); |
2908 |
+- if (unlikely(list_empty(&poll->wait.entry))) { |
2909 |
+- if (ipt->error) |
2910 |
+- cancel = true; |
2911 |
++ io_poll_req_insert(req); |
2912 |
++ spin_unlock(&ctx->completion_lock); |
2913 |
++ |
2914 |
++ if (mask) { |
2915 |
++ /* can't multishot if failed, just queue the event we've got */ |
2916 |
++ if (unlikely(ipt->error || !ipt->nr_entries)) { |
2917 |
++ poll->events |= EPOLLONESHOT; |
2918 |
+ ipt->error = 0; |
2919 |
+- mask = 0; |
2920 |
+ } |
2921 |
+- if ((mask && (poll->events & EPOLLONESHOT)) || ipt->error) |
2922 |
+- list_del_init(&poll->wait.entry); |
2923 |
+- else if (cancel) |
2924 |
+- WRITE_ONCE(poll->canceled, true); |
2925 |
+- else if (!poll->done) /* actually waiting for an event */ |
2926 |
+- io_poll_req_insert(req); |
2927 |
+- spin_unlock_irq(&poll->head->lock); |
2928 |
++ __io_poll_execute(req, mask); |
2929 |
++ return 0; |
2930 |
+ } |
2931 |
+ |
2932 |
+- return mask; |
2933 |
++ /* |
2934 |
++ * Release ownership. If someone tried to queue a tw while it was |
2935 |
++ * locked, kick it off for them. |
2936 |
++ */ |
2937 |
++ v = atomic_dec_return(&req->poll_refs); |
2938 |
++ if (unlikely(v & IO_POLL_REF_MASK)) |
2939 |
++ __io_poll_execute(req, 0); |
2940 |
++ return 0; |
2941 |
++} |
2942 |
++ |
2943 |
++static void io_async_queue_proc(struct file *file, struct wait_queue_head *head, |
2944 |
++ struct poll_table_struct *p) |
2945 |
++{ |
2946 |
++ struct io_poll_table *pt = container_of(p, struct io_poll_table, pt); |
2947 |
++ struct async_poll *apoll = pt->req->apoll; |
2948 |
++ |
2949 |
++ __io_queue_proc(&apoll->poll, pt, head, &apoll->double_poll); |
2950 |
+ } |
2951 |
+ |
2952 |
+ enum { |
2953 |
+@@ -5677,7 +5708,8 @@ static int io_arm_poll_handler(struct io_kiocb *req) |
2954 |
+ struct io_ring_ctx *ctx = req->ctx; |
2955 |
+ struct async_poll *apoll; |
2956 |
+ struct io_poll_table ipt; |
2957 |
+- __poll_t ret, mask = EPOLLONESHOT | POLLERR | POLLPRI; |
2958 |
++ __poll_t mask = EPOLLONESHOT | POLLERR | POLLPRI; |
2959 |
++ int ret; |
2960 |
+ |
2961 |
+ if (!req->file || !file_can_poll(req->file)) |
2962 |
+ return IO_APOLL_ABORTED; |
2963 |
+@@ -5704,11 +5736,8 @@ static int io_arm_poll_handler(struct io_kiocb *req) |
2964 |
+ req->apoll = apoll; |
2965 |
+ req->flags |= REQ_F_POLLED; |
2966 |
+ ipt.pt._qproc = io_async_queue_proc; |
2967 |
+- io_req_set_refcount(req); |
2968 |
+ |
2969 |
+- ret = __io_arm_poll_handler(req, &apoll->poll, &ipt, mask, |
2970 |
+- io_async_wake); |
2971 |
+- spin_unlock(&ctx->completion_lock); |
2972 |
++ ret = __io_arm_poll_handler(req, &apoll->poll, &ipt, mask); |
2973 |
+ if (ret || ipt.error) |
2974 |
+ return ret ? IO_APOLL_READY : IO_APOLL_ABORTED; |
2975 |
+ |
2976 |
+@@ -5717,43 +5746,6 @@ static int io_arm_poll_handler(struct io_kiocb *req) |
2977 |
+ return IO_APOLL_OK; |
2978 |
+ } |
2979 |
+ |
2980 |
+-static bool __io_poll_remove_one(struct io_kiocb *req, |
2981 |
+- struct io_poll_iocb *poll, bool do_cancel) |
2982 |
+- __must_hold(&req->ctx->completion_lock) |
2983 |
+-{ |
2984 |
+- bool do_complete = false; |
2985 |
+- |
2986 |
+- if (!poll->head) |
2987 |
+- return false; |
2988 |
+- spin_lock_irq(&poll->head->lock); |
2989 |
+- if (do_cancel) |
2990 |
+- WRITE_ONCE(poll->canceled, true); |
2991 |
+- if (!list_empty(&poll->wait.entry)) { |
2992 |
+- list_del_init(&poll->wait.entry); |
2993 |
+- do_complete = true; |
2994 |
+- } |
2995 |
+- spin_unlock_irq(&poll->head->lock); |
2996 |
+- hash_del(&req->hash_node); |
2997 |
+- return do_complete; |
2998 |
+-} |
2999 |
+- |
3000 |
+-static bool io_poll_remove_one(struct io_kiocb *req) |
3001 |
+- __must_hold(&req->ctx->completion_lock) |
3002 |
+-{ |
3003 |
+- bool do_complete; |
3004 |
+- |
3005 |
+- io_poll_remove_double(req); |
3006 |
+- do_complete = __io_poll_remove_one(req, io_poll_get_single(req), true); |
3007 |
+- |
3008 |
+- if (do_complete) { |
3009 |
+- io_cqring_fill_event(req->ctx, req->user_data, -ECANCELED, 0); |
3010 |
+- io_commit_cqring(req->ctx); |
3011 |
+- req_set_fail(req); |
3012 |
+- io_put_req_deferred(req); |
3013 |
+- } |
3014 |
+- return do_complete; |
3015 |
+-} |
3016 |
+- |
3017 |
+ /* |
3018 |
+ * Returns true if we found and killed one or more poll requests |
3019 |
+ */ |
3020 |
+@@ -5762,7 +5754,8 @@ static bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk, |
3021 |
+ { |
3022 |
+ struct hlist_node *tmp; |
3023 |
+ struct io_kiocb *req; |
3024 |
+- int posted = 0, i; |
3025 |
++ bool found = false; |
3026 |
++ int i; |
3027 |
+ |
3028 |
+ spin_lock(&ctx->completion_lock); |
3029 |
+ for (i = 0; i < (1U << ctx->cancel_hash_bits); i++) { |
3030 |
+@@ -5770,16 +5763,15 @@ static bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk, |
3031 |
+ |
3032 |
+ list = &ctx->cancel_hash[i]; |
3033 |
+ hlist_for_each_entry_safe(req, tmp, list, hash_node) { |
3034 |
+- if (io_match_task_safe(req, tsk, cancel_all)) |
3035 |
+- posted += io_poll_remove_one(req); |
3036 |
++ if (io_match_task_safe(req, tsk, cancel_all)) { |
3037 |
++ hlist_del_init(&req->hash_node); |
3038 |
++ io_poll_cancel_req(req); |
3039 |
++ found = true; |
3040 |
++ } |
3041 |
+ } |
3042 |
+ } |
3043 |
+ spin_unlock(&ctx->completion_lock); |
3044 |
+- |
3045 |
+- if (posted) |
3046 |
+- io_cqring_ev_posted(ctx); |
3047 |
+- |
3048 |
+- return posted != 0; |
3049 |
++ return found; |
3050 |
+ } |
3051 |
+ |
3052 |
+ static struct io_kiocb *io_poll_find(struct io_ring_ctx *ctx, __u64 sqe_addr, |
3053 |
+@@ -5800,19 +5792,26 @@ static struct io_kiocb *io_poll_find(struct io_ring_ctx *ctx, __u64 sqe_addr, |
3054 |
+ return NULL; |
3055 |
+ } |
3056 |
+ |
3057 |
++static bool io_poll_disarm(struct io_kiocb *req) |
3058 |
++ __must_hold(&ctx->completion_lock) |
3059 |
++{ |
3060 |
++ if (!io_poll_get_ownership(req)) |
3061 |
++ return false; |
3062 |
++ io_poll_remove_entries(req); |
3063 |
++ hash_del(&req->hash_node); |
3064 |
++ return true; |
3065 |
++} |
3066 |
++ |
3067 |
+ static int io_poll_cancel(struct io_ring_ctx *ctx, __u64 sqe_addr, |
3068 |
+ bool poll_only) |
3069 |
+ __must_hold(&ctx->completion_lock) |
3070 |
+ { |
3071 |
+- struct io_kiocb *req; |
3072 |
++ struct io_kiocb *req = io_poll_find(ctx, sqe_addr, poll_only); |
3073 |
+ |
3074 |
+- req = io_poll_find(ctx, sqe_addr, poll_only); |
3075 |
+ if (!req) |
3076 |
+ return -ENOENT; |
3077 |
+- if (io_poll_remove_one(req)) |
3078 |
+- return 0; |
3079 |
+- |
3080 |
+- return -EALREADY; |
3081 |
++ io_poll_cancel_req(req); |
3082 |
++ return 0; |
3083 |
+ } |
3084 |
+ |
3085 |
+ static __poll_t io_poll_parse_events(const struct io_uring_sqe *sqe, |
3086 |
+@@ -5862,23 +5861,6 @@ static int io_poll_update_prep(struct io_kiocb *req, |
3087 |
+ return 0; |
3088 |
+ } |
3089 |
+ |
3090 |
+-static int io_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync, |
3091 |
+- void *key) |
3092 |
+-{ |
3093 |
+- struct io_kiocb *req = wait->private; |
3094 |
+- struct io_poll_iocb *poll = &req->poll; |
3095 |
+- |
3096 |
+- return __io_async_wake(req, poll, key_to_poll(key), io_poll_task_func); |
3097 |
+-} |
3098 |
+- |
3099 |
+-static void io_poll_queue_proc(struct file *file, struct wait_queue_head *head, |
3100 |
+- struct poll_table_struct *p) |
3101 |
+-{ |
3102 |
+- struct io_poll_table *pt = container_of(p, struct io_poll_table, pt); |
3103 |
+- |
3104 |
+- __io_queue_proc(&pt->req->poll, pt, head, (struct io_poll_iocb **) &pt->req->async_data); |
3105 |
+-} |
3106 |
+- |
3107 |
+ static int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) |
3108 |
+ { |
3109 |
+ struct io_poll_iocb *poll = &req->poll; |
3110 |
+@@ -5900,90 +5882,57 @@ static int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe |
3111 |
+ static int io_poll_add(struct io_kiocb *req, unsigned int issue_flags) |
3112 |
+ { |
3113 |
+ struct io_poll_iocb *poll = &req->poll; |
3114 |
+- struct io_ring_ctx *ctx = req->ctx; |
3115 |
+ struct io_poll_table ipt; |
3116 |
+- __poll_t mask; |
3117 |
+- bool done; |
3118 |
++ int ret; |
3119 |
+ |
3120 |
+ ipt.pt._qproc = io_poll_queue_proc; |
3121 |
+ |
3122 |
+- mask = __io_arm_poll_handler(req, &req->poll, &ipt, poll->events, |
3123 |
+- io_poll_wake); |
3124 |
+- |
3125 |
+- if (mask) { /* no async, we'd stolen it */ |
3126 |
+- ipt.error = 0; |
3127 |
+- done = io_poll_complete(req, mask); |
3128 |
+- } |
3129 |
+- spin_unlock(&ctx->completion_lock); |
3130 |
+- |
3131 |
+- if (mask) { |
3132 |
+- io_cqring_ev_posted(ctx); |
3133 |
+- if (done) |
3134 |
+- io_put_req(req); |
3135 |
+- } |
3136 |
+- return ipt.error; |
3137 |
++ ret = __io_arm_poll_handler(req, &req->poll, &ipt, poll->events); |
3138 |
++ if (!ret && ipt.error) |
3139 |
++ req_set_fail(req); |
3140 |
++ ret = ret ?: ipt.error; |
3141 |
++ if (ret) |
3142 |
++ __io_req_complete(req, issue_flags, ret, 0); |
3143 |
++ return 0; |
3144 |
+ } |
3145 |
+ |
3146 |
+ static int io_poll_update(struct io_kiocb *req, unsigned int issue_flags) |
3147 |
+ { |
3148 |
+ struct io_ring_ctx *ctx = req->ctx; |
3149 |
+ struct io_kiocb *preq; |
3150 |
+- bool completing; |
3151 |
+- int ret; |
3152 |
++ int ret2, ret = 0; |
3153 |
+ |
3154 |
+ spin_lock(&ctx->completion_lock); |
3155 |
+ preq = io_poll_find(ctx, req->poll_update.old_user_data, true); |
3156 |
+- if (!preq) { |
3157 |
+- ret = -ENOENT; |
3158 |
+- goto err; |
3159 |
++ if (!preq || !io_poll_disarm(preq)) { |
3160 |
++ spin_unlock(&ctx->completion_lock); |
3161 |
++ ret = preq ? -EALREADY : -ENOENT; |
3162 |
++ goto out; |
3163 |
+ } |
3164 |
++ spin_unlock(&ctx->completion_lock); |
3165 |
+ |
3166 |
+- if (!req->poll_update.update_events && !req->poll_update.update_user_data) { |
3167 |
+- completing = true; |
3168 |
+- ret = io_poll_remove_one(preq) ? 0 : -EALREADY; |
3169 |
+- goto err; |
3170 |
+- } |
3171 |
++ if (req->poll_update.update_events || req->poll_update.update_user_data) { |
3172 |
++ /* only mask one event flags, keep behavior flags */ |
3173 |
++ if (req->poll_update.update_events) { |
3174 |
++ preq->poll.events &= ~0xffff; |
3175 |
++ preq->poll.events |= req->poll_update.events & 0xffff; |
3176 |
++ preq->poll.events |= IO_POLL_UNMASK; |
3177 |
++ } |
3178 |
++ if (req->poll_update.update_user_data) |
3179 |
++ preq->user_data = req->poll_update.new_user_data; |
3180 |
+ |
3181 |
+- /* |
3182 |
+- * Don't allow racy completion with singleshot, as we cannot safely |
3183 |
+- * update those. For multishot, if we're racing with completion, just |
3184 |
+- * let completion re-add it. |
3185 |
+- */ |
3186 |
+- io_poll_remove_double(preq); |
3187 |
+- completing = !__io_poll_remove_one(preq, &preq->poll, false); |
3188 |
+- if (completing && (preq->poll.events & EPOLLONESHOT)) { |
3189 |
+- ret = -EALREADY; |
3190 |
+- goto err; |
3191 |
++ ret2 = io_poll_add(preq, issue_flags); |
3192 |
++ /* successfully updated, don't complete poll request */ |
3193 |
++ if (!ret2) |
3194 |
++ goto out; |
3195 |
+ } |
3196 |
+- /* we now have a detached poll request. reissue. */ |
3197 |
+- ret = 0; |
3198 |
+-err: |
3199 |
+- if (ret < 0) { |
3200 |
+- spin_unlock(&ctx->completion_lock); |
3201 |
++ req_set_fail(preq); |
3202 |
++ io_req_complete(preq, -ECANCELED); |
3203 |
++out: |
3204 |
++ if (ret < 0) |
3205 |
+ req_set_fail(req); |
3206 |
+- io_req_complete(req, ret); |
3207 |
+- return 0; |
3208 |
+- } |
3209 |
+- /* only mask one event flags, keep behavior flags */ |
3210 |
+- if (req->poll_update.update_events) { |
3211 |
+- preq->poll.events &= ~0xffff; |
3212 |
+- preq->poll.events |= req->poll_update.events & 0xffff; |
3213 |
+- preq->poll.events |= IO_POLL_UNMASK; |
3214 |
+- } |
3215 |
+- if (req->poll_update.update_user_data) |
3216 |
+- preq->user_data = req->poll_update.new_user_data; |
3217 |
+- spin_unlock(&ctx->completion_lock); |
3218 |
+- |
3219 |
+ /* complete update request, we're done with it */ |
3220 |
+ io_req_complete(req, ret); |
3221 |
+- |
3222 |
+- if (!completing) { |
3223 |
+- ret = io_poll_add(preq, issue_flags); |
3224 |
+- if (ret < 0) { |
3225 |
+- req_set_fail(preq); |
3226 |
+- io_req_complete(preq, ret); |
3227 |
+- } |
3228 |
+- } |
3229 |
+ return 0; |
3230 |
+ } |
3231 |
+ |
3232 |
+@@ -6045,7 +5994,7 @@ static int io_timeout_cancel(struct io_ring_ctx *ctx, __u64 user_data) |
3233 |
+ return PTR_ERR(req); |
3234 |
+ |
3235 |
+ req_set_fail(req); |
3236 |
+- io_cqring_fill_event(ctx, req->user_data, -ECANCELED, 0); |
3237 |
++ io_fill_cqe_req(req, -ECANCELED, 0); |
3238 |
+ io_put_req_deferred(req); |
3239 |
+ return 0; |
3240 |
+ } |
3241 |
+@@ -8271,8 +8220,7 @@ static void __io_rsrc_put_work(struct io_rsrc_node *ref_node) |
3242 |
+ |
3243 |
+ io_ring_submit_lock(ctx, lock_ring); |
3244 |
+ spin_lock(&ctx->completion_lock); |
3245 |
+- io_cqring_fill_event(ctx, prsrc->tag, 0, 0); |
3246 |
+- ctx->cq_extra++; |
3247 |
++ io_fill_cqe_aux(ctx, prsrc->tag, 0, 0); |
3248 |
+ io_commit_cqring(ctx); |
3249 |
+ spin_unlock(&ctx->completion_lock); |
3250 |
+ io_cqring_ev_posted(ctx); |
3251 |
+diff --git a/fs/ksmbd/mgmt/tree_connect.c b/fs/ksmbd/mgmt/tree_connect.c |
3252 |
+index 0d28e723a28c7..940385c6a9135 100644 |
3253 |
+--- a/fs/ksmbd/mgmt/tree_connect.c |
3254 |
++++ b/fs/ksmbd/mgmt/tree_connect.c |
3255 |
+@@ -18,7 +18,7 @@ |
3256 |
+ struct ksmbd_tree_conn_status |
3257 |
+ ksmbd_tree_conn_connect(struct ksmbd_session *sess, char *share_name) |
3258 |
+ { |
3259 |
+- struct ksmbd_tree_conn_status status = {-EINVAL, NULL}; |
3260 |
++ struct ksmbd_tree_conn_status status = {-ENOENT, NULL}; |
3261 |
+ struct ksmbd_tree_connect_response *resp = NULL; |
3262 |
+ struct ksmbd_share_config *sc; |
3263 |
+ struct ksmbd_tree_connect *tree_conn = NULL; |
3264 |
+diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c |
3265 |
+index 28b5d20c8766e..55ee639703ff0 100644 |
3266 |
+--- a/fs/ksmbd/smb2pdu.c |
3267 |
++++ b/fs/ksmbd/smb2pdu.c |
3268 |
+@@ -1932,8 +1932,9 @@ out_err1: |
3269 |
+ rsp->hdr.Status = STATUS_SUCCESS; |
3270 |
+ rc = 0; |
3271 |
+ break; |
3272 |
++ case -ENOENT: |
3273 |
+ case KSMBD_TREE_CONN_STATUS_NO_SHARE: |
3274 |
+- rsp->hdr.Status = STATUS_BAD_NETWORK_PATH; |
3275 |
++ rsp->hdr.Status = STATUS_BAD_NETWORK_NAME; |
3276 |
+ break; |
3277 |
+ case -ENOMEM: |
3278 |
+ case KSMBD_TREE_CONN_STATUS_NOMEM: |
3279 |
+@@ -2318,15 +2319,15 @@ static int smb2_remove_smb_xattrs(struct path *path) |
3280 |
+ name += strlen(name) + 1) { |
3281 |
+ ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name)); |
3282 |
+ |
3283 |
+- if (strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) && |
3284 |
+- strncmp(&name[XATTR_USER_PREFIX_LEN], DOS_ATTRIBUTE_PREFIX, |
3285 |
+- DOS_ATTRIBUTE_PREFIX_LEN) && |
3286 |
+- strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX, STREAM_PREFIX_LEN)) |
3287 |
+- continue; |
3288 |
+- |
3289 |
+- err = ksmbd_vfs_remove_xattr(user_ns, path->dentry, name); |
3290 |
+- if (err) |
3291 |
+- ksmbd_debug(SMB, "remove xattr failed : %s\n", name); |
3292 |
++ if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) && |
3293 |
++ !strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX, |
3294 |
++ STREAM_PREFIX_LEN)) { |
3295 |
++ err = ksmbd_vfs_remove_xattr(user_ns, path->dentry, |
3296 |
++ name); |
3297 |
++ if (err) |
3298 |
++ ksmbd_debug(SMB, "remove xattr failed : %s\n", |
3299 |
++ name); |
3300 |
++ } |
3301 |
+ } |
3302 |
+ out: |
3303 |
+ kvfree(xattr_list); |
3304 |
+diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c |
3305 |
+index e8bfa709270d1..4652b97969957 100644 |
3306 |
+--- a/fs/ntfs3/xattr.c |
3307 |
++++ b/fs/ntfs3/xattr.c |
3308 |
+@@ -118,7 +118,7 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea, |
3309 |
+ |
3310 |
+ run_init(&run); |
3311 |
+ |
3312 |
+- err = attr_load_runs(attr_ea, ni, &run, NULL); |
3313 |
++ err = attr_load_runs_range(ni, ATTR_EA, NULL, 0, &run, 0, size); |
3314 |
+ if (!err) |
3315 |
+ err = ntfs_read_run_nb(sbi, &run, 0, ea_p, size, NULL); |
3316 |
+ run_close(&run); |
3317 |
+@@ -443,6 +443,11 @@ update_ea: |
3318 |
+ /* Delete xattr, ATTR_EA */ |
3319 |
+ ni_remove_attr_le(ni, attr, mi, le); |
3320 |
+ } else if (attr->non_res) { |
3321 |
++ err = attr_load_runs_range(ni, ATTR_EA, NULL, 0, &ea_run, 0, |
3322 |
++ size); |
3323 |
++ if (err) |
3324 |
++ goto out; |
3325 |
++ |
3326 |
+ err = ntfs_sb_write_run(sbi, &ea_run, 0, ea_all, size, 0); |
3327 |
+ if (err) |
3328 |
+ goto out; |
3329 |
+diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h |
3330 |
+index 9cdbd209388ed..1648ce265cba0 100644 |
3331 |
+--- a/include/drm/drm_bridge.h |
3332 |
++++ b/include/drm/drm_bridge.h |
3333 |
+@@ -911,9 +911,20 @@ struct drm_bridge *devm_drm_panel_bridge_add(struct device *dev, |
3334 |
+ struct drm_bridge *devm_drm_panel_bridge_add_typed(struct device *dev, |
3335 |
+ struct drm_panel *panel, |
3336 |
+ u32 connector_type); |
3337 |
++struct drm_connector *drm_panel_bridge_connector(struct drm_bridge *bridge); |
3338 |
++#endif |
3339 |
++ |
3340 |
++#if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL_BRIDGE) |
3341 |
+ struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, struct device_node *node, |
3342 |
+ u32 port, u32 endpoint); |
3343 |
+-struct drm_connector *drm_panel_bridge_connector(struct drm_bridge *bridge); |
3344 |
++#else |
3345 |
++static inline struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, |
3346 |
++ struct device_node *node, |
3347 |
++ u32 port, |
3348 |
++ u32 endpoint) |
3349 |
++{ |
3350 |
++ return ERR_PTR(-ENODEV); |
3351 |
++} |
3352 |
+ #endif |
3353 |
+ |
3354 |
+ #endif |
3355 |
+diff --git a/include/linux/rmap.h b/include/linux/rmap.h |
3356 |
+index c976cc6de2574..c29d9c13378b3 100644 |
3357 |
+--- a/include/linux/rmap.h |
3358 |
++++ b/include/linux/rmap.h |
3359 |
+@@ -39,12 +39,15 @@ struct anon_vma { |
3360 |
+ atomic_t refcount; |
3361 |
+ |
3362 |
+ /* |
3363 |
+- * Count of child anon_vmas and VMAs which points to this anon_vma. |
3364 |
++ * Count of child anon_vmas. Equals to the count of all anon_vmas that |
3365 |
++ * have ->parent pointing to this one, including itself. |
3366 |
+ * |
3367 |
+ * This counter is used for making decision about reusing anon_vma |
3368 |
+ * instead of forking new one. See comments in function anon_vma_clone. |
3369 |
+ */ |
3370 |
+- unsigned degree; |
3371 |
++ unsigned long num_children; |
3372 |
++ /* Count of VMAs whose ->anon_vma pointer points to this object. */ |
3373 |
++ unsigned long num_active_vmas; |
3374 |
+ |
3375 |
+ struct anon_vma *parent; /* Parent of this anon_vma */ |
3376 |
+ |
3377 |
+diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h |
3378 |
+index cbd719e5329a4..ae598ed86b50b 100644 |
3379 |
+--- a/include/linux/skbuff.h |
3380 |
++++ b/include/linux/skbuff.h |
3381 |
+@@ -2328,6 +2328,14 @@ static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset) |
3382 |
+ |
3383 |
+ #endif /* NET_SKBUFF_DATA_USES_OFFSET */ |
3384 |
+ |
3385 |
++static inline void skb_assert_len(struct sk_buff *skb) |
3386 |
++{ |
3387 |
++#ifdef CONFIG_DEBUG_NET |
3388 |
++ if (WARN_ONCE(!skb->len, "%s\n", __func__)) |
3389 |
++ DO_ONCE_LITE(skb_dump, KERN_ERR, skb, false); |
3390 |
++#endif /* CONFIG_DEBUG_NET */ |
3391 |
++} |
3392 |
++ |
3393 |
+ /* |
3394 |
+ * Add data to an sk_buff |
3395 |
+ */ |
3396 |
+diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h |
3397 |
+index 73bedd128d529..0c742cdf413c0 100644 |
3398 |
+--- a/include/linux/skmsg.h |
3399 |
++++ b/include/linux/skmsg.h |
3400 |
+@@ -283,7 +283,8 @@ static inline void sk_msg_sg_copy_clear(struct sk_msg *msg, u32 start) |
3401 |
+ |
3402 |
+ static inline struct sk_psock *sk_psock(const struct sock *sk) |
3403 |
+ { |
3404 |
+- return rcu_dereference_sk_user_data(sk); |
3405 |
++ return __rcu_dereference_sk_user_data_with_flags(sk, |
3406 |
++ SK_USER_DATA_PSOCK); |
3407 |
+ } |
3408 |
+ |
3409 |
+ static inline void sk_psock_set_state(struct sk_psock *psock, |
3410 |
+diff --git a/include/net/sock.h b/include/net/sock.h |
3411 |
+index 49a6315d521ff..cb1a1bb64ed81 100644 |
3412 |
+--- a/include/net/sock.h |
3413 |
++++ b/include/net/sock.h |
3414 |
+@@ -543,14 +543,26 @@ enum sk_pacing { |
3415 |
+ SK_PACING_FQ = 2, |
3416 |
+ }; |
3417 |
+ |
3418 |
+-/* Pointer stored in sk_user_data might not be suitable for copying |
3419 |
+- * when cloning the socket. For instance, it can point to a reference |
3420 |
+- * counted object. sk_user_data bottom bit is set if pointer must not |
3421 |
+- * be copied. |
3422 |
++/* flag bits in sk_user_data |
3423 |
++ * |
3424 |
++ * - SK_USER_DATA_NOCOPY: Pointer stored in sk_user_data might |
3425 |
++ * not be suitable for copying when cloning the socket. For instance, |
3426 |
++ * it can point to a reference counted object. sk_user_data bottom |
3427 |
++ * bit is set if pointer must not be copied. |
3428 |
++ * |
3429 |
++ * - SK_USER_DATA_BPF: Mark whether sk_user_data field is |
3430 |
++ * managed/owned by a BPF reuseport array. This bit should be set |
3431 |
++ * when sk_user_data's sk is added to the bpf's reuseport_array. |
3432 |
++ * |
3433 |
++ * - SK_USER_DATA_PSOCK: Mark whether pointer stored in |
3434 |
++ * sk_user_data points to psock type. This bit should be set |
3435 |
++ * when sk_user_data is assigned to a psock object. |
3436 |
+ */ |
3437 |
+ #define SK_USER_DATA_NOCOPY 1UL |
3438 |
+-#define SK_USER_DATA_BPF 2UL /* Managed by BPF */ |
3439 |
+-#define SK_USER_DATA_PTRMASK ~(SK_USER_DATA_NOCOPY | SK_USER_DATA_BPF) |
3440 |
++#define SK_USER_DATA_BPF 2UL |
3441 |
++#define SK_USER_DATA_PSOCK 4UL |
3442 |
++#define SK_USER_DATA_PTRMASK ~(SK_USER_DATA_NOCOPY | SK_USER_DATA_BPF |\ |
3443 |
++ SK_USER_DATA_PSOCK) |
3444 |
+ |
3445 |
+ /** |
3446 |
+ * sk_user_data_is_nocopy - Test if sk_user_data pointer must not be copied |
3447 |
+@@ -563,24 +575,40 @@ static inline bool sk_user_data_is_nocopy(const struct sock *sk) |
3448 |
+ |
3449 |
+ #define __sk_user_data(sk) ((*((void __rcu **)&(sk)->sk_user_data))) |
3450 |
+ |
3451 |
++/** |
3452 |
++ * __rcu_dereference_sk_user_data_with_flags - return the pointer |
3453 |
++ * only if argument flags all has been set in sk_user_data. Otherwise |
3454 |
++ * return NULL |
3455 |
++ * |
3456 |
++ * @sk: socket |
3457 |
++ * @flags: flag bits |
3458 |
++ */ |
3459 |
++static inline void * |
3460 |
++__rcu_dereference_sk_user_data_with_flags(const struct sock *sk, |
3461 |
++ uintptr_t flags) |
3462 |
++{ |
3463 |
++ uintptr_t sk_user_data = (uintptr_t)rcu_dereference(__sk_user_data(sk)); |
3464 |
++ |
3465 |
++ WARN_ON_ONCE(flags & SK_USER_DATA_PTRMASK); |
3466 |
++ |
3467 |
++ if ((sk_user_data & flags) == flags) |
3468 |
++ return (void *)(sk_user_data & SK_USER_DATA_PTRMASK); |
3469 |
++ return NULL; |
3470 |
++} |
3471 |
++ |
3472 |
+ #define rcu_dereference_sk_user_data(sk) \ |
3473 |
++ __rcu_dereference_sk_user_data_with_flags(sk, 0) |
3474 |
++#define __rcu_assign_sk_user_data_with_flags(sk, ptr, flags) \ |
3475 |
+ ({ \ |
3476 |
+- void *__tmp = rcu_dereference(__sk_user_data((sk))); \ |
3477 |
+- (void *)((uintptr_t)__tmp & SK_USER_DATA_PTRMASK); \ |
3478 |
+-}) |
3479 |
+-#define rcu_assign_sk_user_data(sk, ptr) \ |
3480 |
+-({ \ |
3481 |
+- uintptr_t __tmp = (uintptr_t)(ptr); \ |
3482 |
+- WARN_ON_ONCE(__tmp & ~SK_USER_DATA_PTRMASK); \ |
3483 |
+- rcu_assign_pointer(__sk_user_data((sk)), __tmp); \ |
3484 |
+-}) |
3485 |
+-#define rcu_assign_sk_user_data_nocopy(sk, ptr) \ |
3486 |
+-({ \ |
3487 |
+- uintptr_t __tmp = (uintptr_t)(ptr); \ |
3488 |
+- WARN_ON_ONCE(__tmp & ~SK_USER_DATA_PTRMASK); \ |
3489 |
++ uintptr_t __tmp1 = (uintptr_t)(ptr), \ |
3490 |
++ __tmp2 = (uintptr_t)(flags); \ |
3491 |
++ WARN_ON_ONCE(__tmp1 & ~SK_USER_DATA_PTRMASK); \ |
3492 |
++ WARN_ON_ONCE(__tmp2 & SK_USER_DATA_PTRMASK); \ |
3493 |
+ rcu_assign_pointer(__sk_user_data((sk)), \ |
3494 |
+- __tmp | SK_USER_DATA_NOCOPY); \ |
3495 |
++ __tmp1 | __tmp2); \ |
3496 |
+ }) |
3497 |
++#define rcu_assign_sk_user_data(sk, ptr) \ |
3498 |
++ __rcu_assign_sk_user_data_with_flags(sk, ptr, 0) |
3499 |
+ |
3500 |
+ /* |
3501 |
+ * SK_CAN_REUSE and SK_NO_REUSE on a socket mean that the socket is OK |
3502 |
+diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h |
3503 |
+index e1c4c732aabac..5416f1f1a77a8 100644 |
3504 |
+--- a/include/uapi/linux/btrfs_tree.h |
3505 |
++++ b/include/uapi/linux/btrfs_tree.h |
3506 |
+@@ -146,7 +146,9 @@ |
3507 |
+ |
3508 |
+ /* |
3509 |
+ * dir items are the name -> inode pointers in a directory. There is one |
3510 |
+- * for every name in a directory. |
3511 |
++ * for every name in a directory. BTRFS_DIR_LOG_ITEM_KEY is no longer used |
3512 |
++ * but it's still defined here for documentation purposes and to help avoid |
3513 |
++ * having its numerical value reused in the future. |
3514 |
+ */ |
3515 |
+ #define BTRFS_DIR_LOG_ITEM_KEY 60 |
3516 |
+ #define BTRFS_DIR_LOG_INDEX_KEY 72 |
3517 |
+diff --git a/kernel/kprobes.c b/kernel/kprobes.c |
3518 |
+index 3a3c0166bd1f3..ed3f24a81549c 100644 |
3519 |
+--- a/kernel/kprobes.c |
3520 |
++++ b/kernel/kprobes.c |
3521 |
+@@ -1705,11 +1705,12 @@ static struct kprobe *__disable_kprobe(struct kprobe *p) |
3522 |
+ /* Try to disarm and disable this/parent probe */ |
3523 |
+ if (p == orig_p || aggr_kprobe_disabled(orig_p)) { |
3524 |
+ /* |
3525 |
+- * If kprobes_all_disarmed is set, orig_p |
3526 |
+- * should have already been disarmed, so |
3527 |
+- * skip unneed disarming process. |
3528 |
++ * Don't be lazy here. Even if 'kprobes_all_disarmed' |
3529 |
++ * is false, 'orig_p' might not have been armed yet. |
3530 |
++ * Note arm_all_kprobes() __tries__ to arm all kprobes |
3531 |
++ * on the best effort basis. |
3532 |
+ */ |
3533 |
+- if (!kprobes_all_disarmed) { |
3534 |
++ if (!kprobes_all_disarmed && !kprobe_disabled(orig_p)) { |
3535 |
+ ret = disarm_kprobe(orig_p, true); |
3536 |
+ if (ret) { |
3537 |
+ p->flags &= ~KPROBE_FLAG_DISABLED; |
3538 |
+diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c |
3539 |
+index e215a9c969711..e10cf1b548128 100644 |
3540 |
+--- a/kernel/trace/ftrace.c |
3541 |
++++ b/kernel/trace/ftrace.c |
3542 |
+@@ -2901,6 +2901,16 @@ int ftrace_startup(struct ftrace_ops *ops, int command) |
3543 |
+ |
3544 |
+ ftrace_startup_enable(command); |
3545 |
+ |
3546 |
++ /* |
3547 |
++ * If ftrace is in an undefined state, we just remove ops from list |
3548 |
++ * to prevent the NULL pointer, instead of totally rolling it back and |
3549 |
++ * free trampoline, because those actions could cause further damage. |
3550 |
++ */ |
3551 |
++ if (unlikely(ftrace_disabled)) { |
3552 |
++ __unregister_ftrace_function(ops); |
3553 |
++ return -ENODEV; |
3554 |
++ } |
3555 |
++ |
3556 |
+ ops->flags &= ~FTRACE_OPS_FL_ADDING; |
3557 |
+ |
3558 |
+ return 0; |
3559 |
+diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig |
3560 |
+index 5056663c2aff7..a29eff4f969e3 100644 |
3561 |
+--- a/lib/crypto/Kconfig |
3562 |
++++ b/lib/crypto/Kconfig |
3563 |
+@@ -33,7 +33,6 @@ config CRYPTO_ARCH_HAVE_LIB_CHACHA |
3564 |
+ |
3565 |
+ config CRYPTO_LIB_CHACHA_GENERIC |
3566 |
+ tristate |
3567 |
+- select XOR_BLOCKS |
3568 |
+ help |
3569 |
+ This symbol can be depended upon by arch implementations of the |
3570 |
+ ChaCha library interface that require the generic code as a |
3571 |
+diff --git a/mm/hugetlb.c b/mm/hugetlb.c |
3572 |
+index 405793b8cf0d2..d61b665c45d63 100644 |
3573 |
+--- a/mm/hugetlb.c |
3574 |
++++ b/mm/hugetlb.c |
3575 |
+@@ -5371,7 +5371,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, |
3576 |
+ if (!huge_pte_none(huge_ptep_get(dst_pte))) |
3577 |
+ goto out_release_unlock; |
3578 |
+ |
3579 |
+- if (vm_shared) { |
3580 |
++ if (page_in_pagecache) { |
3581 |
+ page_dup_rmap(page, true); |
3582 |
+ } else { |
3583 |
+ ClearHPageRestoreReserve(page); |
3584 |
+diff --git a/mm/mmap.c b/mm/mmap.c |
3585 |
+index b63336f6984c9..cd1d2680ac585 100644 |
3586 |
+--- a/mm/mmap.c |
3587 |
++++ b/mm/mmap.c |
3588 |
+@@ -2643,6 +2643,18 @@ static void unmap_region(struct mm_struct *mm, |
3589 |
+ tlb_gather_mmu(&tlb, mm); |
3590 |
+ update_hiwater_rss(mm); |
3591 |
+ unmap_vmas(&tlb, vma, start, end); |
3592 |
++ |
3593 |
++ /* |
3594 |
++ * Ensure we have no stale TLB entries by the time this mapping is |
3595 |
++ * removed from the rmap. |
3596 |
++ * Note that we don't have to worry about nested flushes here because |
3597 |
++ * we're holding the mm semaphore for removing the mapping - so any |
3598 |
++ * concurrent flush in this region has to be coming through the rmap, |
3599 |
++ * and we synchronize against that using the rmap lock. |
3600 |
++ */ |
3601 |
++ if ((vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) != 0) |
3602 |
++ tlb_flush_mmu(&tlb); |
3603 |
++ |
3604 |
+ free_pgtables(&tlb, vma, prev ? prev->vm_end : FIRST_USER_ADDRESS, |
3605 |
+ next ? next->vm_start : USER_PGTABLES_CEILING); |
3606 |
+ tlb_finish_mmu(&tlb); |
3607 |
+diff --git a/mm/rmap.c b/mm/rmap.c |
3608 |
+index 3e340ee380cb9..330b361a460ea 100644 |
3609 |
+--- a/mm/rmap.c |
3610 |
++++ b/mm/rmap.c |
3611 |
+@@ -90,7 +90,8 @@ static inline struct anon_vma *anon_vma_alloc(void) |
3612 |
+ anon_vma = kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL); |
3613 |
+ if (anon_vma) { |
3614 |
+ atomic_set(&anon_vma->refcount, 1); |
3615 |
+- anon_vma->degree = 1; /* Reference for first vma */ |
3616 |
++ anon_vma->num_children = 0; |
3617 |
++ anon_vma->num_active_vmas = 0; |
3618 |
+ anon_vma->parent = anon_vma; |
3619 |
+ /* |
3620 |
+ * Initialise the anon_vma root to point to itself. If called |
3621 |
+@@ -198,6 +199,7 @@ int __anon_vma_prepare(struct vm_area_struct *vma) |
3622 |
+ anon_vma = anon_vma_alloc(); |
3623 |
+ if (unlikely(!anon_vma)) |
3624 |
+ goto out_enomem_free_avc; |
3625 |
++ anon_vma->num_children++; /* self-parent link for new root */ |
3626 |
+ allocated = anon_vma; |
3627 |
+ } |
3628 |
+ |
3629 |
+@@ -207,8 +209,7 @@ int __anon_vma_prepare(struct vm_area_struct *vma) |
3630 |
+ if (likely(!vma->anon_vma)) { |
3631 |
+ vma->anon_vma = anon_vma; |
3632 |
+ anon_vma_chain_link(vma, avc, anon_vma); |
3633 |
+- /* vma reference or self-parent link for new root */ |
3634 |
+- anon_vma->degree++; |
3635 |
++ anon_vma->num_active_vmas++; |
3636 |
+ allocated = NULL; |
3637 |
+ avc = NULL; |
3638 |
+ } |
3639 |
+@@ -293,19 +294,19 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src) |
3640 |
+ anon_vma_chain_link(dst, avc, anon_vma); |
3641 |
+ |
3642 |
+ /* |
3643 |
+- * Reuse existing anon_vma if its degree lower than two, |
3644 |
+- * that means it has no vma and only one anon_vma child. |
3645 |
++ * Reuse existing anon_vma if it has no vma and only one |
3646 |
++ * anon_vma child. |
3647 |
+ * |
3648 |
+- * Do not chose parent anon_vma, otherwise first child |
3649 |
+- * will always reuse it. Root anon_vma is never reused: |
3650 |
++ * Root anon_vma is never reused: |
3651 |
+ * it has self-parent reference and at least one child. |
3652 |
+ */ |
3653 |
+ if (!dst->anon_vma && src->anon_vma && |
3654 |
+- anon_vma != src->anon_vma && anon_vma->degree < 2) |
3655 |
++ anon_vma->num_children < 2 && |
3656 |
++ anon_vma->num_active_vmas == 0) |
3657 |
+ dst->anon_vma = anon_vma; |
3658 |
+ } |
3659 |
+ if (dst->anon_vma) |
3660 |
+- dst->anon_vma->degree++; |
3661 |
++ dst->anon_vma->num_active_vmas++; |
3662 |
+ unlock_anon_vma_root(root); |
3663 |
+ return 0; |
3664 |
+ |
3665 |
+@@ -355,6 +356,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma) |
3666 |
+ anon_vma = anon_vma_alloc(); |
3667 |
+ if (!anon_vma) |
3668 |
+ goto out_error; |
3669 |
++ anon_vma->num_active_vmas++; |
3670 |
+ avc = anon_vma_chain_alloc(GFP_KERNEL); |
3671 |
+ if (!avc) |
3672 |
+ goto out_error_free_anon_vma; |
3673 |
+@@ -375,7 +377,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma) |
3674 |
+ vma->anon_vma = anon_vma; |
3675 |
+ anon_vma_lock_write(anon_vma); |
3676 |
+ anon_vma_chain_link(vma, avc, anon_vma); |
3677 |
+- anon_vma->parent->degree++; |
3678 |
++ anon_vma->parent->num_children++; |
3679 |
+ anon_vma_unlock_write(anon_vma); |
3680 |
+ |
3681 |
+ return 0; |
3682 |
+@@ -407,7 +409,7 @@ void unlink_anon_vmas(struct vm_area_struct *vma) |
3683 |
+ * to free them outside the lock. |
3684 |
+ */ |
3685 |
+ if (RB_EMPTY_ROOT(&anon_vma->rb_root.rb_root)) { |
3686 |
+- anon_vma->parent->degree--; |
3687 |
++ anon_vma->parent->num_children--; |
3688 |
+ continue; |
3689 |
+ } |
3690 |
+ |
3691 |
+@@ -415,7 +417,7 @@ void unlink_anon_vmas(struct vm_area_struct *vma) |
3692 |
+ anon_vma_chain_free(avc); |
3693 |
+ } |
3694 |
+ if (vma->anon_vma) { |
3695 |
+- vma->anon_vma->degree--; |
3696 |
++ vma->anon_vma->num_active_vmas--; |
3697 |
+ |
3698 |
+ /* |
3699 |
+ * vma would still be needed after unlink, and anon_vma will be prepared |
3700 |
+@@ -433,7 +435,8 @@ void unlink_anon_vmas(struct vm_area_struct *vma) |
3701 |
+ list_for_each_entry_safe(avc, next, &vma->anon_vma_chain, same_vma) { |
3702 |
+ struct anon_vma *anon_vma = avc->anon_vma; |
3703 |
+ |
3704 |
+- VM_WARN_ON(anon_vma->degree); |
3705 |
++ VM_WARN_ON(anon_vma->num_children); |
3706 |
++ VM_WARN_ON(anon_vma->num_active_vmas); |
3707 |
+ put_anon_vma(anon_vma); |
3708 |
+ |
3709 |
+ list_del(&avc->same_vma); |
3710 |
+diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c |
3711 |
+index a0e0c2bdbb49a..e8de1e7d6ff48 100644 |
3712 |
+--- a/net/bluetooth/l2cap_core.c |
3713 |
++++ b/net/bluetooth/l2cap_core.c |
3714 |
+@@ -1992,11 +1992,11 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm, |
3715 |
+ src_match = !bacmp(&c->src, src); |
3716 |
+ dst_match = !bacmp(&c->dst, dst); |
3717 |
+ if (src_match && dst_match) { |
3718 |
+- c = l2cap_chan_hold_unless_zero(c); |
3719 |
+- if (c) { |
3720 |
+- read_unlock(&chan_list_lock); |
3721 |
+- return c; |
3722 |
+- } |
3723 |
++ if (!l2cap_chan_hold_unless_zero(c)) |
3724 |
++ continue; |
3725 |
++ |
3726 |
++ read_unlock(&chan_list_lock); |
3727 |
++ return c; |
3728 |
+ } |
3729 |
+ |
3730 |
+ /* Closest match */ |
3731 |
+diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c |
3732 |
+index 655ee0e2de86d..a9fb16b9c735a 100644 |
3733 |
+--- a/net/bpf/test_run.c |
3734 |
++++ b/net/bpf/test_run.c |
3735 |
+@@ -469,6 +469,9 @@ static int convert___skb_to_skb(struct sk_buff *skb, struct __sk_buff *__skb) |
3736 |
+ { |
3737 |
+ struct qdisc_skb_cb *cb = (struct qdisc_skb_cb *)skb->cb; |
3738 |
+ |
3739 |
++ if (!skb->len) |
3740 |
++ return -EINVAL; |
3741 |
++ |
3742 |
+ if (!__skb) |
3743 |
+ return 0; |
3744 |
+ |
3745 |
+diff --git a/net/core/dev.c b/net/core/dev.c |
3746 |
+index 276cca563325e..be51644e95dae 100644 |
3747 |
+--- a/net/core/dev.c |
3748 |
++++ b/net/core/dev.c |
3749 |
+@@ -4147,6 +4147,7 @@ static int __dev_queue_xmit(struct sk_buff *skb, struct net_device *sb_dev) |
3750 |
+ bool again = false; |
3751 |
+ |
3752 |
+ skb_reset_mac_header(skb); |
3753 |
++ skb_assert_len(skb); |
3754 |
+ |
3755 |
+ if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_SCHED_TSTAMP)) |
3756 |
+ __skb_tstamp_tx(skb, NULL, NULL, skb->sk, SCM_TSTAMP_SCHED); |
3757 |
+diff --git a/net/core/neighbour.c b/net/core/neighbour.c |
3758 |
+index ff049733cceeb..b3556c5c1c08e 100644 |
3759 |
+--- a/net/core/neighbour.c |
3760 |
++++ b/net/core/neighbour.c |
3761 |
+@@ -279,11 +279,26 @@ static int neigh_del_timer(struct neighbour *n) |
3762 |
+ return 0; |
3763 |
+ } |
3764 |
+ |
3765 |
+-static void pneigh_queue_purge(struct sk_buff_head *list) |
3766 |
++static void pneigh_queue_purge(struct sk_buff_head *list, struct net *net) |
3767 |
+ { |
3768 |
++ struct sk_buff_head tmp; |
3769 |
++ unsigned long flags; |
3770 |
+ struct sk_buff *skb; |
3771 |
+ |
3772 |
+- while ((skb = skb_dequeue(list)) != NULL) { |
3773 |
++ skb_queue_head_init(&tmp); |
3774 |
++ spin_lock_irqsave(&list->lock, flags); |
3775 |
++ skb = skb_peek(list); |
3776 |
++ while (skb != NULL) { |
3777 |
++ struct sk_buff *skb_next = skb_peek_next(skb, list); |
3778 |
++ if (net == NULL || net_eq(dev_net(skb->dev), net)) { |
3779 |
++ __skb_unlink(skb, list); |
3780 |
++ __skb_queue_tail(&tmp, skb); |
3781 |
++ } |
3782 |
++ skb = skb_next; |
3783 |
++ } |
3784 |
++ spin_unlock_irqrestore(&list->lock, flags); |
3785 |
++ |
3786 |
++ while ((skb = __skb_dequeue(&tmp))) { |
3787 |
+ dev_put(skb->dev); |
3788 |
+ kfree_skb(skb); |
3789 |
+ } |
3790 |
+@@ -357,9 +372,9 @@ static int __neigh_ifdown(struct neigh_table *tbl, struct net_device *dev, |
3791 |
+ write_lock_bh(&tbl->lock); |
3792 |
+ neigh_flush_dev(tbl, dev, skip_perm); |
3793 |
+ pneigh_ifdown_and_unlock(tbl, dev); |
3794 |
+- |
3795 |
+- del_timer_sync(&tbl->proxy_timer); |
3796 |
+- pneigh_queue_purge(&tbl->proxy_queue); |
3797 |
++ pneigh_queue_purge(&tbl->proxy_queue, dev_net(dev)); |
3798 |
++ if (skb_queue_empty_lockless(&tbl->proxy_queue)) |
3799 |
++ del_timer_sync(&tbl->proxy_timer); |
3800 |
+ return 0; |
3801 |
+ } |
3802 |
+ |
3803 |
+@@ -1735,7 +1750,7 @@ int neigh_table_clear(int index, struct neigh_table *tbl) |
3804 |
+ /* It is not clean... Fix it to unload IPv6 module safely */ |
3805 |
+ cancel_delayed_work_sync(&tbl->gc_work); |
3806 |
+ del_timer_sync(&tbl->proxy_timer); |
3807 |
+- pneigh_queue_purge(&tbl->proxy_queue); |
3808 |
++ pneigh_queue_purge(&tbl->proxy_queue, NULL); |
3809 |
+ neigh_ifdown(tbl, NULL); |
3810 |
+ if (atomic_read(&tbl->entries)) |
3811 |
+ pr_crit("neighbour leakage\n"); |
3812 |
+diff --git a/net/core/skmsg.c b/net/core/skmsg.c |
3813 |
+index f50f8d95b6283..4ddcfac344984 100644 |
3814 |
+--- a/net/core/skmsg.c |
3815 |
++++ b/net/core/skmsg.c |
3816 |
+@@ -731,7 +731,9 @@ struct sk_psock *sk_psock_init(struct sock *sk, int node) |
3817 |
+ sk_psock_set_state(psock, SK_PSOCK_TX_ENABLED); |
3818 |
+ refcount_set(&psock->refcnt, 1); |
3819 |
+ |
3820 |
+- rcu_assign_sk_user_data_nocopy(sk, psock); |
3821 |
++ __rcu_assign_sk_user_data_with_flags(sk, psock, |
3822 |
++ SK_USER_DATA_NOCOPY | |
3823 |
++ SK_USER_DATA_PSOCK); |
3824 |
+ sock_hold(sk); |
3825 |
+ |
3826 |
+ out: |
3827 |
+diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig |
3828 |
+index 92a747896f808..4f645d51c2573 100644 |
3829 |
+--- a/net/netfilter/Kconfig |
3830 |
++++ b/net/netfilter/Kconfig |
3831 |
+@@ -133,7 +133,6 @@ config NF_CONNTRACK_ZONES |
3832 |
+ |
3833 |
+ config NF_CONNTRACK_PROCFS |
3834 |
+ bool "Supply CT list in procfs (OBSOLETE)" |
3835 |
+- default y |
3836 |
+ depends on PROC_FS |
3837 |
+ help |
3838 |
+ This option enables for the list of known conntrack entries |
3839 |
+diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c |
3840 |
+index 88c3b5cf8d94c..968dac3fcf58a 100644 |
3841 |
+--- a/net/packet/af_packet.c |
3842 |
++++ b/net/packet/af_packet.c |
3843 |
+@@ -2989,8 +2989,8 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len) |
3844 |
+ if (err) |
3845 |
+ goto out_free; |
3846 |
+ |
3847 |
+- if (sock->type == SOCK_RAW && |
3848 |
+- !dev_validate_header(dev, skb->data, len)) { |
3849 |
++ if ((sock->type == SOCK_RAW && |
3850 |
++ !dev_validate_header(dev, skb->data, len)) || !skb->len) { |
3851 |
+ err = -EINVAL; |
3852 |
+ goto out_free; |
3853 |
+ } |
3854 |
+diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost |
3855 |
+index 48585c4d04ade..0273bf7375e26 100644 |
3856 |
+--- a/scripts/Makefile.modpost |
3857 |
++++ b/scripts/Makefile.modpost |
3858 |
+@@ -87,8 +87,7 @@ obj := $(KBUILD_EXTMOD) |
3859 |
+ src := $(obj) |
3860 |
+ |
3861 |
+ # Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS |
3862 |
+-include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \ |
3863 |
+- $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile) |
3864 |
++include $(if $(wildcard $(src)/Kbuild), $(src)/Kbuild, $(src)/Makefile) |
3865 |
+ |
3866 |
+ # modpost option for external modules |
3867 |
+ MODPOST += -e |
3868 |
+diff --git a/sound/soc/sh/rz-ssi.c b/sound/soc/sh/rz-ssi.c |
3869 |
+index 6d794eaaf4c39..2e33a1fa0a6f4 100644 |
3870 |
+--- a/sound/soc/sh/rz-ssi.c |
3871 |
++++ b/sound/soc/sh/rz-ssi.c |
3872 |
+@@ -1022,32 +1022,36 @@ static int rz_ssi_probe(struct platform_device *pdev) |
3873 |
+ |
3874 |
+ ssi->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); |
3875 |
+ if (IS_ERR(ssi->rstc)) { |
3876 |
+- rz_ssi_release_dma_channels(ssi); |
3877 |
+- return PTR_ERR(ssi->rstc); |
3878 |
++ ret = PTR_ERR(ssi->rstc); |
3879 |
++ goto err_reset; |
3880 |
+ } |
3881 |
+ |
3882 |
+ reset_control_deassert(ssi->rstc); |
3883 |
+ pm_runtime_enable(&pdev->dev); |
3884 |
+ ret = pm_runtime_resume_and_get(&pdev->dev); |
3885 |
+ if (ret < 0) { |
3886 |
+- rz_ssi_release_dma_channels(ssi); |
3887 |
+- pm_runtime_disable(ssi->dev); |
3888 |
+- reset_control_assert(ssi->rstc); |
3889 |
+- return dev_err_probe(ssi->dev, ret, "pm_runtime_resume_and_get failed\n"); |
3890 |
++ dev_err(&pdev->dev, "pm_runtime_resume_and_get failed\n"); |
3891 |
++ goto err_pm; |
3892 |
+ } |
3893 |
+ |
3894 |
+ ret = devm_snd_soc_register_component(&pdev->dev, &rz_ssi_soc_component, |
3895 |
+ rz_ssi_soc_dai, |
3896 |
+ ARRAY_SIZE(rz_ssi_soc_dai)); |
3897 |
+ if (ret < 0) { |
3898 |
+- rz_ssi_release_dma_channels(ssi); |
3899 |
+- |
3900 |
+- pm_runtime_put(ssi->dev); |
3901 |
+- pm_runtime_disable(ssi->dev); |
3902 |
+- reset_control_assert(ssi->rstc); |
3903 |
+ dev_err(&pdev->dev, "failed to register snd component\n"); |
3904 |
++ goto err_snd_soc; |
3905 |
+ } |
3906 |
+ |
3907 |
++ return 0; |
3908 |
++ |
3909 |
++err_snd_soc: |
3910 |
++ pm_runtime_put(ssi->dev); |
3911 |
++err_pm: |
3912 |
++ pm_runtime_disable(ssi->dev); |
3913 |
++ reset_control_assert(ssi->rstc); |
3914 |
++err_reset: |
3915 |
++ rz_ssi_release_dma_channels(ssi); |
3916 |
++ |
3917 |
+ return ret; |
3918 |
+ } |
3919 |
+ |
3920 |
+diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c |
3921 |
+index 168fd802d70bd..9bfead5efc4c1 100644 |
3922 |
+--- a/sound/usb/quirks.c |
3923 |
++++ b/sound/usb/quirks.c |
3924 |
+@@ -1903,6 +1903,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = { |
3925 |
+ QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
3926 |
+ DEVICE_FLG(0x21b4, 0x0081, /* AudioQuest DragonFly */ |
3927 |
+ QUIRK_FLAG_GET_SAMPLE_RATE), |
3928 |
++ DEVICE_FLG(0x2522, 0x0007, /* LH Labs Geek Out HD Audio 1V5 */ |
3929 |
++ QUIRK_FLAG_SET_IFACE_FIRST), |
3930 |
+ DEVICE_FLG(0x2708, 0x0002, /* Audient iD14 */ |
3931 |
+ QUIRK_FLAG_IGNORE_CTL_ERROR), |
3932 |
+ DEVICE_FLG(0x2912, 0x30c8, /* Audioengine D1 */ |
3933 |
+diff --git a/tools/testing/selftests/netfilter/nft_flowtable.sh b/tools/testing/selftests/netfilter/nft_flowtable.sh |
3934 |
+index d4ffebb989f88..c336e6c148d1f 100755 |
3935 |
+--- a/tools/testing/selftests/netfilter/nft_flowtable.sh |
3936 |
++++ b/tools/testing/selftests/netfilter/nft_flowtable.sh |
3937 |
+@@ -14,6 +14,11 @@ |
3938 |
+ # nft_flowtable.sh -o8000 -l1500 -r2000 |
3939 |
+ # |
3940 |
+ |
3941 |
++sfx=$(mktemp -u "XXXXXXXX") |
3942 |
++ns1="ns1-$sfx" |
3943 |
++ns2="ns2-$sfx" |
3944 |
++nsr1="nsr1-$sfx" |
3945 |
++nsr2="nsr2-$sfx" |
3946 |
+ |
3947 |
+ # Kselftest framework requirement - SKIP code is 4. |
3948 |
+ ksft_skip=4 |
3949 |
+@@ -36,18 +41,17 @@ checktool (){ |
3950 |
+ checktool "nft --version" "run test without nft tool" |
3951 |
+ checktool "ip -Version" "run test without ip tool" |
3952 |
+ checktool "which nc" "run test without nc (netcat)" |
3953 |
+-checktool "ip netns add nsr1" "create net namespace" |
3954 |
++checktool "ip netns add $nsr1" "create net namespace $nsr1" |
3955 |
+ |
3956 |
+-ip netns add ns1 |
3957 |
+-ip netns add ns2 |
3958 |
+- |
3959 |
+-ip netns add nsr2 |
3960 |
++ip netns add $ns1 |
3961 |
++ip netns add $ns2 |
3962 |
++ip netns add $nsr2 |
3963 |
+ |
3964 |
+ cleanup() { |
3965 |
+- for i in 1 2; do |
3966 |
+- ip netns del ns$i |
3967 |
+- ip netns del nsr$i |
3968 |
+- done |
3969 |
++ ip netns del $ns1 |
3970 |
++ ip netns del $ns2 |
3971 |
++ ip netns del $nsr1 |
3972 |
++ ip netns del $nsr2 |
3973 |
+ |
3974 |
+ rm -f "$ns1in" "$ns1out" |
3975 |
+ rm -f "$ns2in" "$ns2out" |
3976 |
+@@ -59,22 +63,21 @@ trap cleanup EXIT |
3977 |
+ |
3978 |
+ sysctl -q net.netfilter.nf_log_all_netns=1 |
3979 |
+ |
3980 |
+-ip link add veth0 netns nsr1 type veth peer name eth0 netns ns1 |
3981 |
+-ip link add veth1 netns nsr1 type veth peer name veth0 netns nsr2 |
3982 |
++ip link add veth0 netns $nsr1 type veth peer name eth0 netns $ns1 |
3983 |
++ip link add veth1 netns $nsr1 type veth peer name veth0 netns $nsr2 |
3984 |
+ |
3985 |
+-ip link add veth1 netns nsr2 type veth peer name eth0 netns ns2 |
3986 |
++ip link add veth1 netns $nsr2 type veth peer name eth0 netns $ns2 |
3987 |
+ |
3988 |
+ for dev in lo veth0 veth1; do |
3989 |
+- for i in 1 2; do |
3990 |
+- ip -net nsr$i link set $dev up |
3991 |
+- done |
3992 |
++ ip -net $nsr1 link set $dev up |
3993 |
++ ip -net $nsr2 link set $dev up |
3994 |
+ done |
3995 |
+ |
3996 |
+-ip -net nsr1 addr add 10.0.1.1/24 dev veth0 |
3997 |
+-ip -net nsr1 addr add dead:1::1/64 dev veth0 |
3998 |
++ip -net $nsr1 addr add 10.0.1.1/24 dev veth0 |
3999 |
++ip -net $nsr1 addr add dead:1::1/64 dev veth0 |
4000 |
+ |
4001 |
+-ip -net nsr2 addr add 10.0.2.1/24 dev veth1 |
4002 |
+-ip -net nsr2 addr add dead:2::1/64 dev veth1 |
4003 |
++ip -net $nsr2 addr add 10.0.2.1/24 dev veth1 |
4004 |
++ip -net $nsr2 addr add dead:2::1/64 dev veth1 |
4005 |
+ |
4006 |
+ # set different MTUs so we need to push packets coming from ns1 (large MTU) |
4007 |
+ # to ns2 (smaller MTU) to stack either to perform fragmentation (ip_no_pmtu_disc=1), |
4008 |
+@@ -106,49 +109,56 @@ do |
4009 |
+ esac |
4010 |
+ done |
4011 |
+ |
4012 |
+-if ! ip -net nsr1 link set veth0 mtu $omtu; then |
4013 |
++if ! ip -net $nsr1 link set veth0 mtu $omtu; then |
4014 |
+ exit 1 |
4015 |
+ fi |
4016 |
+ |
4017 |
+-ip -net ns1 link set eth0 mtu $omtu |
4018 |
++ip -net $ns1 link set eth0 mtu $omtu |
4019 |
+ |
4020 |
+-if ! ip -net nsr2 link set veth1 mtu $rmtu; then |
4021 |
++if ! ip -net $nsr2 link set veth1 mtu $rmtu; then |
4022 |
+ exit 1 |
4023 |
+ fi |
4024 |
+ |
4025 |
+-ip -net ns2 link set eth0 mtu $rmtu |
4026 |
++ip -net $ns2 link set eth0 mtu $rmtu |
4027 |
+ |
4028 |
+ # transfer-net between nsr1 and nsr2. |
4029 |
+ # these addresses are not used for connections. |
4030 |
+-ip -net nsr1 addr add 192.168.10.1/24 dev veth1 |
4031 |
+-ip -net nsr1 addr add fee1:2::1/64 dev veth1 |
4032 |
+- |
4033 |
+-ip -net nsr2 addr add 192.168.10.2/24 dev veth0 |
4034 |
+-ip -net nsr2 addr add fee1:2::2/64 dev veth0 |
4035 |
+- |
4036 |
+-for i in 1 2; do |
4037 |
+- ip netns exec nsr$i sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null |
4038 |
+- ip netns exec nsr$i sysctl net.ipv4.conf.veth1.forwarding=1 > /dev/null |
4039 |
+- |
4040 |
+- ip -net ns$i link set lo up |
4041 |
+- ip -net ns$i link set eth0 up |
4042 |
+- ip -net ns$i addr add 10.0.$i.99/24 dev eth0 |
4043 |
+- ip -net ns$i route add default via 10.0.$i.1 |
4044 |
+- ip -net ns$i addr add dead:$i::99/64 dev eth0 |
4045 |
+- ip -net ns$i route add default via dead:$i::1 |
4046 |
+- if ! ip netns exec ns$i sysctl net.ipv4.tcp_no_metrics_save=1 > /dev/null; then |
4047 |
++ip -net $nsr1 addr add 192.168.10.1/24 dev veth1 |
4048 |
++ip -net $nsr1 addr add fee1:2::1/64 dev veth1 |
4049 |
++ |
4050 |
++ip -net $nsr2 addr add 192.168.10.2/24 dev veth0 |
4051 |
++ip -net $nsr2 addr add fee1:2::2/64 dev veth0 |
4052 |
++ |
4053 |
++for i in 0 1; do |
4054 |
++ ip netns exec $nsr1 sysctl net.ipv4.conf.veth$i.forwarding=1 > /dev/null |
4055 |
++ ip netns exec $nsr2 sysctl net.ipv4.conf.veth$i.forwarding=1 > /dev/null |
4056 |
++done |
4057 |
++ |
4058 |
++for ns in $ns1 $ns2;do |
4059 |
++ ip -net $ns link set lo up |
4060 |
++ ip -net $ns link set eth0 up |
4061 |
++ |
4062 |
++ if ! ip netns exec $ns sysctl net.ipv4.tcp_no_metrics_save=1 > /dev/null; then |
4063 |
+ echo "ERROR: Check Originator/Responder values (problem during address addition)" |
4064 |
+ exit 1 |
4065 |
+ fi |
4066 |
+- |
4067 |
+ # don't set ip DF bit for first two tests |
4068 |
+- ip netns exec ns$i sysctl net.ipv4.ip_no_pmtu_disc=1 > /dev/null |
4069 |
++ ip netns exec $ns sysctl net.ipv4.ip_no_pmtu_disc=1 > /dev/null |
4070 |
+ done |
4071 |
+ |
4072 |
+-ip -net nsr1 route add default via 192.168.10.2 |
4073 |
+-ip -net nsr2 route add default via 192.168.10.1 |
4074 |
++ip -net $ns1 addr add 10.0.1.99/24 dev eth0 |
4075 |
++ip -net $ns2 addr add 10.0.2.99/24 dev eth0 |
4076 |
++ip -net $ns1 route add default via 10.0.1.1 |
4077 |
++ip -net $ns2 route add default via 10.0.2.1 |
4078 |
++ip -net $ns1 addr add dead:1::99/64 dev eth0 |
4079 |
++ip -net $ns2 addr add dead:2::99/64 dev eth0 |
4080 |
++ip -net $ns1 route add default via dead:1::1 |
4081 |
++ip -net $ns2 route add default via dead:2::1 |
4082 |
++ |
4083 |
++ip -net $nsr1 route add default via 192.168.10.2 |
4084 |
++ip -net $nsr2 route add default via 192.168.10.1 |
4085 |
+ |
4086 |
+-ip netns exec nsr1 nft -f - <<EOF |
4087 |
++ip netns exec $nsr1 nft -f - <<EOF |
4088 |
+ table inet filter { |
4089 |
+ flowtable f1 { |
4090 |
+ hook ingress priority 0 |
4091 |
+@@ -197,18 +207,18 @@ if [ $? -ne 0 ]; then |
4092 |
+ fi |
4093 |
+ |
4094 |
+ # test basic connectivity |
4095 |
+-if ! ip netns exec ns1 ping -c 1 -q 10.0.2.99 > /dev/null; then |
4096 |
+- echo "ERROR: ns1 cannot reach ns2" 1>&2 |
4097 |
++if ! ip netns exec $ns1 ping -c 1 -q 10.0.2.99 > /dev/null; then |
4098 |
++ echo "ERROR: $ns1 cannot reach ns2" 1>&2 |
4099 |
+ exit 1 |
4100 |
+ fi |
4101 |
+ |
4102 |
+-if ! ip netns exec ns2 ping -c 1 -q 10.0.1.99 > /dev/null; then |
4103 |
+- echo "ERROR: ns2 cannot reach ns1" 1>&2 |
4104 |
++if ! ip netns exec $ns2 ping -c 1 -q 10.0.1.99 > /dev/null; then |
4105 |
++ echo "ERROR: $ns2 cannot reach $ns1" 1>&2 |
4106 |
+ exit 1 |
4107 |
+ fi |
4108 |
+ |
4109 |
+ if [ $ret -eq 0 ];then |
4110 |
+- echo "PASS: netns routing/connectivity: ns1 can reach ns2" |
4111 |
++ echo "PASS: netns routing/connectivity: $ns1 can reach $ns2" |
4112 |
+ fi |
4113 |
+ |
4114 |
+ ns1in=$(mktemp) |
4115 |
+@@ -312,24 +322,24 @@ make_file "$ns2in" |
4116 |
+ |
4117 |
+ # First test: |
4118 |
+ # No PMTU discovery, nsr1 is expected to fragment packets from ns1 to ns2 as needed. |
4119 |
+-if test_tcp_forwarding ns1 ns2; then |
4120 |
++if test_tcp_forwarding $ns1 $ns2; then |
4121 |
+ echo "PASS: flow offloaded for ns1/ns2" |
4122 |
+ else |
4123 |
+ echo "FAIL: flow offload for ns1/ns2:" 1>&2 |
4124 |
+- ip netns exec nsr1 nft list ruleset |
4125 |
++ ip netns exec $nsr1 nft list ruleset |
4126 |
+ ret=1 |
4127 |
+ fi |
4128 |
+ |
4129 |
+ # delete default route, i.e. ns2 won't be able to reach ns1 and |
4130 |
+ # will depend on ns1 being masqueraded in nsr1. |
4131 |
+ # expect ns1 has nsr1 address. |
4132 |
+-ip -net ns2 route del default via 10.0.2.1 |
4133 |
+-ip -net ns2 route del default via dead:2::1 |
4134 |
+-ip -net ns2 route add 192.168.10.1 via 10.0.2.1 |
4135 |
++ip -net $ns2 route del default via 10.0.2.1 |
4136 |
++ip -net $ns2 route del default via dead:2::1 |
4137 |
++ip -net $ns2 route add 192.168.10.1 via 10.0.2.1 |
4138 |
+ |
4139 |
+ # Second test: |
4140 |
+ # Same, but with NAT enabled. |
4141 |
+-ip netns exec nsr1 nft -f - <<EOF |
4142 |
++ip netns exec $nsr1 nft -f - <<EOF |
4143 |
+ table ip nat { |
4144 |
+ chain prerouting { |
4145 |
+ type nat hook prerouting priority 0; policy accept; |
4146 |
+@@ -343,47 +353,47 @@ table ip nat { |
4147 |
+ } |
4148 |
+ EOF |
4149 |
+ |
4150 |
+-if test_tcp_forwarding_nat ns1 ns2; then |
4151 |
++if test_tcp_forwarding_nat $ns1 $ns2; then |
4152 |
+ echo "PASS: flow offloaded for ns1/ns2 with NAT" |
4153 |
+ else |
4154 |
+ echo "FAIL: flow offload for ns1/ns2 with NAT" 1>&2 |
4155 |
+- ip netns exec nsr1 nft list ruleset |
4156 |
++ ip netns exec $nsr1 nft list ruleset |
4157 |
+ ret=1 |
4158 |
+ fi |
4159 |
+ |
4160 |
+ # Third test: |
4161 |
+ # Same as second test, but with PMTU discovery enabled. |
4162 |
+-handle=$(ip netns exec nsr1 nft -a list table inet filter | grep something-to-grep-for | cut -d \# -f 2) |
4163 |
++handle=$(ip netns exec $nsr1 nft -a list table inet filter | grep something-to-grep-for | cut -d \# -f 2) |
4164 |
+ |
4165 |
+-if ! ip netns exec nsr1 nft delete rule inet filter forward $handle; then |
4166 |
++if ! ip netns exec $nsr1 nft delete rule inet filter forward $handle; then |
4167 |
+ echo "FAIL: Could not delete large-packet accept rule" |
4168 |
+ exit 1 |
4169 |
+ fi |
4170 |
+ |
4171 |
+-ip netns exec ns1 sysctl net.ipv4.ip_no_pmtu_disc=0 > /dev/null |
4172 |
+-ip netns exec ns2 sysctl net.ipv4.ip_no_pmtu_disc=0 > /dev/null |
4173 |
++ip netns exec $ns1 sysctl net.ipv4.ip_no_pmtu_disc=0 > /dev/null |
4174 |
++ip netns exec $ns2 sysctl net.ipv4.ip_no_pmtu_disc=0 > /dev/null |
4175 |
+ |
4176 |
+-if test_tcp_forwarding_nat ns1 ns2; then |
4177 |
++if test_tcp_forwarding_nat $ns1 $ns2; then |
4178 |
+ echo "PASS: flow offloaded for ns1/ns2 with NAT and pmtu discovery" |
4179 |
+ else |
4180 |
+ echo "FAIL: flow offload for ns1/ns2 with NAT and pmtu discovery" 1>&2 |
4181 |
+- ip netns exec nsr1 nft list ruleset |
4182 |
++ ip netns exec $nsr1 nft list ruleset |
4183 |
+ fi |
4184 |
+ |
4185 |
+ # Another test: |
4186 |
+ # Add bridge interface br0 to Router1, with NAT enabled. |
4187 |
+-ip -net nsr1 link add name br0 type bridge |
4188 |
+-ip -net nsr1 addr flush dev veth0 |
4189 |
+-ip -net nsr1 link set up dev veth0 |
4190 |
+-ip -net nsr1 link set veth0 master br0 |
4191 |
+-ip -net nsr1 addr add 10.0.1.1/24 dev br0 |
4192 |
+-ip -net nsr1 addr add dead:1::1/64 dev br0 |
4193 |
+-ip -net nsr1 link set up dev br0 |
4194 |
++ip -net $nsr1 link add name br0 type bridge |
4195 |
++ip -net $nsr1 addr flush dev veth0 |
4196 |
++ip -net $nsr1 link set up dev veth0 |
4197 |
++ip -net $nsr1 link set veth0 master br0 |
4198 |
++ip -net $nsr1 addr add 10.0.1.1/24 dev br0 |
4199 |
++ip -net $nsr1 addr add dead:1::1/64 dev br0 |
4200 |
++ip -net $nsr1 link set up dev br0 |
4201 |
+ |
4202 |
+-ip netns exec nsr1 sysctl net.ipv4.conf.br0.forwarding=1 > /dev/null |
4203 |
++ip netns exec $nsr1 sysctl net.ipv4.conf.br0.forwarding=1 > /dev/null |
4204 |
+ |
4205 |
+ # br0 with NAT enabled. |
4206 |
+-ip netns exec nsr1 nft -f - <<EOF |
4207 |
++ip netns exec $nsr1 nft -f - <<EOF |
4208 |
+ flush table ip nat |
4209 |
+ table ip nat { |
4210 |
+ chain prerouting { |
4211 |
+@@ -398,59 +408,59 @@ table ip nat { |
4212 |
+ } |
4213 |
+ EOF |
4214 |
+ |
4215 |
+-if test_tcp_forwarding_nat ns1 ns2; then |
4216 |
++if test_tcp_forwarding_nat $ns1 $ns2; then |
4217 |
+ echo "PASS: flow offloaded for ns1/ns2 with bridge NAT" |
4218 |
+ else |
4219 |
+ echo "FAIL: flow offload for ns1/ns2 with bridge NAT" 1>&2 |
4220 |
+- ip netns exec nsr1 nft list ruleset |
4221 |
++ ip netns exec $nsr1 nft list ruleset |
4222 |
+ ret=1 |
4223 |
+ fi |
4224 |
+ |
4225 |
+ # Another test: |
4226 |
+ # Add bridge interface br0 to Router1, with NAT and VLAN. |
4227 |
+-ip -net nsr1 link set veth0 nomaster |
4228 |
+-ip -net nsr1 link set down dev veth0 |
4229 |
+-ip -net nsr1 link add link veth0 name veth0.10 type vlan id 10 |
4230 |
+-ip -net nsr1 link set up dev veth0 |
4231 |
+-ip -net nsr1 link set up dev veth0.10 |
4232 |
+-ip -net nsr1 link set veth0.10 master br0 |
4233 |
+- |
4234 |
+-ip -net ns1 addr flush dev eth0 |
4235 |
+-ip -net ns1 link add link eth0 name eth0.10 type vlan id 10 |
4236 |
+-ip -net ns1 link set eth0 up |
4237 |
+-ip -net ns1 link set eth0.10 up |
4238 |
+-ip -net ns1 addr add 10.0.1.99/24 dev eth0.10 |
4239 |
+-ip -net ns1 route add default via 10.0.1.1 |
4240 |
+-ip -net ns1 addr add dead:1::99/64 dev eth0.10 |
4241 |
+- |
4242 |
+-if test_tcp_forwarding_nat ns1 ns2; then |
4243 |
++ip -net $nsr1 link set veth0 nomaster |
4244 |
++ip -net $nsr1 link set down dev veth0 |
4245 |
++ip -net $nsr1 link add link veth0 name veth0.10 type vlan id 10 |
4246 |
++ip -net $nsr1 link set up dev veth0 |
4247 |
++ip -net $nsr1 link set up dev veth0.10 |
4248 |
++ip -net $nsr1 link set veth0.10 master br0 |
4249 |
++ |
4250 |
++ip -net $ns1 addr flush dev eth0 |
4251 |
++ip -net $ns1 link add link eth0 name eth0.10 type vlan id 10 |
4252 |
++ip -net $ns1 link set eth0 up |
4253 |
++ip -net $ns1 link set eth0.10 up |
4254 |
++ip -net $ns1 addr add 10.0.1.99/24 dev eth0.10 |
4255 |
++ip -net $ns1 route add default via 10.0.1.1 |
4256 |
++ip -net $ns1 addr add dead:1::99/64 dev eth0.10 |
4257 |
++ |
4258 |
++if test_tcp_forwarding_nat $ns1 $ns2; then |
4259 |
+ echo "PASS: flow offloaded for ns1/ns2 with bridge NAT and VLAN" |
4260 |
+ else |
4261 |
+ echo "FAIL: flow offload for ns1/ns2 with bridge NAT and VLAN" 1>&2 |
4262 |
+- ip netns exec nsr1 nft list ruleset |
4263 |
++ ip netns exec $nsr1 nft list ruleset |
4264 |
+ ret=1 |
4265 |
+ fi |
4266 |
+ |
4267 |
+ # restore test topology (remove bridge and VLAN) |
4268 |
+-ip -net nsr1 link set veth0 nomaster |
4269 |
+-ip -net nsr1 link set veth0 down |
4270 |
+-ip -net nsr1 link set veth0.10 down |
4271 |
+-ip -net nsr1 link delete veth0.10 type vlan |
4272 |
+-ip -net nsr1 link delete br0 type bridge |
4273 |
+-ip -net ns1 addr flush dev eth0.10 |
4274 |
+-ip -net ns1 link set eth0.10 down |
4275 |
+-ip -net ns1 link set eth0 down |
4276 |
+-ip -net ns1 link delete eth0.10 type vlan |
4277 |
++ip -net $nsr1 link set veth0 nomaster |
4278 |
++ip -net $nsr1 link set veth0 down |
4279 |
++ip -net $nsr1 link set veth0.10 down |
4280 |
++ip -net $nsr1 link delete veth0.10 type vlan |
4281 |
++ip -net $nsr1 link delete br0 type bridge |
4282 |
++ip -net $ns1 addr flush dev eth0.10 |
4283 |
++ip -net $ns1 link set eth0.10 down |
4284 |
++ip -net $ns1 link set eth0 down |
4285 |
++ip -net $ns1 link delete eth0.10 type vlan |
4286 |
+ |
4287 |
+ # restore address in ns1 and nsr1 |
4288 |
+-ip -net ns1 link set eth0 up |
4289 |
+-ip -net ns1 addr add 10.0.1.99/24 dev eth0 |
4290 |
+-ip -net ns1 route add default via 10.0.1.1 |
4291 |
+-ip -net ns1 addr add dead:1::99/64 dev eth0 |
4292 |
+-ip -net ns1 route add default via dead:1::1 |
4293 |
+-ip -net nsr1 addr add 10.0.1.1/24 dev veth0 |
4294 |
+-ip -net nsr1 addr add dead:1::1/64 dev veth0 |
4295 |
+-ip -net nsr1 link set up dev veth0 |
4296 |
++ip -net $ns1 link set eth0 up |
4297 |
++ip -net $ns1 addr add 10.0.1.99/24 dev eth0 |
4298 |
++ip -net $ns1 route add default via 10.0.1.1 |
4299 |
++ip -net $ns1 addr add dead:1::99/64 dev eth0 |
4300 |
++ip -net $ns1 route add default via dead:1::1 |
4301 |
++ip -net $nsr1 addr add 10.0.1.1/24 dev veth0 |
4302 |
++ip -net $nsr1 addr add dead:1::1/64 dev veth0 |
4303 |
++ip -net $nsr1 link set up dev veth0 |
4304 |
+ |
4305 |
+ KEY_SHA="0x"$(ps -xaf | sha1sum | cut -d " " -f 1) |
4306 |
+ KEY_AES="0x"$(ps -xaf | md5sum | cut -d " " -f 1) |
4307 |
+@@ -480,23 +490,23 @@ do_esp() { |
4308 |
+ |
4309 |
+ } |
4310 |
+ |
4311 |
+-do_esp nsr1 192.168.10.1 192.168.10.2 10.0.1.0/24 10.0.2.0/24 $SPI1 $SPI2 |
4312 |
++do_esp $nsr1 192.168.10.1 192.168.10.2 10.0.1.0/24 10.0.2.0/24 $SPI1 $SPI2 |
4313 |
+ |
4314 |
+-do_esp nsr2 192.168.10.2 192.168.10.1 10.0.2.0/24 10.0.1.0/24 $SPI2 $SPI1 |
4315 |
++do_esp $nsr2 192.168.10.2 192.168.10.1 10.0.2.0/24 10.0.1.0/24 $SPI2 $SPI1 |
4316 |
+ |
4317 |
+-ip netns exec nsr1 nft delete table ip nat |
4318 |
++ip netns exec $nsr1 nft delete table ip nat |
4319 |
+ |
4320 |
+ # restore default routes |
4321 |
+-ip -net ns2 route del 192.168.10.1 via 10.0.2.1 |
4322 |
+-ip -net ns2 route add default via 10.0.2.1 |
4323 |
+-ip -net ns2 route add default via dead:2::1 |
4324 |
++ip -net $ns2 route del 192.168.10.1 via 10.0.2.1 |
4325 |
++ip -net $ns2 route add default via 10.0.2.1 |
4326 |
++ip -net $ns2 route add default via dead:2::1 |
4327 |
+ |
4328 |
+-if test_tcp_forwarding ns1 ns2; then |
4329 |
++if test_tcp_forwarding $ns1 $ns2; then |
4330 |
+ echo "PASS: ipsec tunnel mode for ns1/ns2" |
4331 |
+ else |
4332 |
+ echo "FAIL: ipsec tunnel mode for ns1/ns2" |
4333 |
+- ip netns exec nsr1 nft list ruleset 1>&2 |
4334 |
+- ip netns exec nsr1 cat /proc/net/xfrm_stat 1>&2 |
4335 |
++ ip netns exec $nsr1 nft list ruleset 1>&2 |
4336 |
++ ip netns exec $nsr1 cat /proc/net/xfrm_stat 1>&2 |
4337 |
+ fi |
4338 |
+ |
4339 |
+ exit $ret |