Repository navigation
Commit ee291e6
target/iscsi: Fix network portal creation race
When creating network portals rapidly, such as when restoring a
configuration, LIO's code to reuse existing portals can return a false
negative if the thread hasn't run yet and set np_thread_state to
ISCSI_NP_THREAD_ACTIVE. This causes an error in the network stack
when attempting to bind to the same address/port.
This patch sets NP_THREAD_ACTIVE before the np is placed on g_np_list,
so even if the thread hasn't run yet, iscsit_get_np will return the
existing np.
Also, convert np_lock -> np_mutex + hold across adding new net portal
to g_np_list to prevent a race where two threads may attempt to create
the same network portal, resulting in one of them failing.
(nab: Add missing mutex_unlocks in iscsit_add_np failure paths)
(DanC: Fix incorrect spin_unlock -> spin_unlock_bh)
Signed-off-by: Andy Grover <agrover@redhat.com>
Cc: <stable@vger.kernel.org> raspberrypi#3.1+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>1 parent 76736db commit ee291e6
1 file changed
Lines changed: 21 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
310 | 313 | | |
311 | 314 | | |
312 | 315 | | |
313 | 316 | | |
314 | 317 | | |
315 | 318 | | |
316 | 319 | | |
317 | | - | |
318 | 320 | | |
319 | | - | |
| 321 | + | |
320 | 322 | | |
321 | | - | |
| 323 | + | |
322 | 324 | | |
323 | 325 | | |
324 | 326 | | |
| |||
330 | 332 | | |
331 | 333 | | |
332 | 334 | | |
333 | | - | |
334 | | - | |
| 335 | + | |
335 | 336 | | |
336 | 337 | | |
337 | | - | |
| 338 | + | |
338 | 339 | | |
339 | | - | |
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| |||
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
353 | 356 | | |
354 | 357 | | |
355 | 358 | | |
356 | 359 | | |
357 | | - | |
| 360 | + | |
| 361 | + | |
358 | 362 | | |
| 363 | + | |
359 | 364 | | |
360 | 365 | | |
361 | 366 | | |
362 | 367 | | |
| 368 | + | |
363 | 369 | | |
364 | 370 | | |
365 | 371 | | |
| |||
382 | 388 | | |
383 | 389 | | |
384 | 390 | | |
| 391 | + | |
385 | 392 | | |
386 | 393 | | |
387 | 394 | | |
| |||
390 | 397 | | |
391 | 398 | | |
392 | 399 | | |
| 400 | + | |
393 | 401 | | |
394 | 402 | | |
395 | 403 | | |
| |||
400 | 408 | | |
401 | 409 | | |
402 | 410 | | |
| 411 | + | |
403 | 412 | | |
404 | | - | |
405 | 413 | | |
406 | | - | |
| 414 | + | |
407 | 415 | | |
408 | 416 | | |
409 | 417 | | |
| |||
469 | 477 | | |
470 | 478 | | |
471 | 479 | | |
472 | | - | |
| 480 | + | |
473 | 481 | | |
474 | | - | |
| 482 | + | |
475 | 483 | | |
476 | 484 | | |
477 | 485 | | |
| |||
0 commit comments