Commit febe562
Nicholas Bellinger
target: Fix LUN_RESET active I/O handling for ACK_KREF
This patch fixes a NULL pointer se_cmd->cmd_kref < 0
refcount bug during TMR LUN_RESET with active se_cmd
I/O, that can be triggered during se_cmd descriptor
shutdown + release via core_tmr_drain_state_list() code.
To address this bug, add common __target_check_io_state()
helper for ABORT_TASK + LUN_RESET w/ CMD_T_COMPLETE
checking, and set CMD_T_ABORTED + obtain ->cmd_kref for
both cases ahead of last target_put_sess_cmd() after
TFO->aborted_task() -> transport_cmd_finish_abort()
callback has completed.
It also introduces SCF_ACK_KREF to determine when
transport_cmd_finish_abort() needs to drop the second
extra reference, ahead of calling target_put_sess_cmd()
for the final kref_put(&se_cmd->cmd_kref).
It also updates transport_cmd_check_stop() to avoid
holding se_cmd->t_state_lock while dropping se_cmd
device state via target_remove_from_state_list(), now
that core_tmr_drain_state_list() is holding the
se_device lock while checking se_cmd state from
within TMR logic.
Finally, move transport_put_cmd() release of SGL +
TMR + extended CDB memory into target_free_cmd_mem()
in order to avoid potential resource leaks in TMR
ABORT_TASK + LUN_RESET code-paths. Also update
target_release_cmd_kref() accordingly.
Reviewed-by: Quinn Tran <quinn.tran@qlogic.com>
Cc: Himanshu Madhani <himanshu.madhani@qlogic.com>
Cc: Sagi Grimberg <sagig@mellanox.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Andy Grover <agrover@redhat.com>
Cc: Mike Christie <mchristi@redhat.com>
Cc: stable@vger.kernel.org # 3.10+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>1 parent a07100e commit febe562
File tree
3 files changed
+76
-61
lines changed- drivers/target
- include/target
3 files changed
+76
-61
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
110 | 138 | | |
111 | 139 | | |
112 | 140 | | |
| |||
130 | 158 | | |
131 | 159 | | |
132 | 160 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | 161 | | |
137 | 162 | | |
138 | 163 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
| 164 | + | |
144 | 165 | | |
145 | | - | |
146 | 166 | | |
147 | | - | |
148 | 167 | | |
149 | 168 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | 169 | | |
154 | 170 | | |
155 | 171 | | |
156 | 172 | | |
157 | 173 | | |
158 | 174 | | |
159 | | - | |
160 | 175 | | |
| 176 | + | |
161 | 177 | | |
162 | 178 | | |
163 | 179 | | |
| |||
242 | 258 | | |
243 | 259 | | |
244 | 260 | | |
| 261 | + | |
245 | 262 | | |
246 | 263 | | |
| 264 | + | |
247 | 265 | | |
248 | 266 | | |
249 | 267 | | |
| |||
282 | 300 | | |
283 | 301 | | |
284 | 302 | | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
285 | 313 | | |
286 | 314 | | |
287 | 315 | | |
288 | 316 | | |
289 | 317 | | |
290 | 318 | | |
291 | 319 | | |
292 | | - | |
| 320 | + | |
293 | 321 | | |
294 | 322 | | |
295 | 323 | | |
| |||
313 | 341 | | |
314 | 342 | | |
315 | 343 | | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
| 344 | + | |
| 345 | + | |
324 | 346 | | |
325 | 347 | | |
| 348 | + | |
326 | 349 | | |
327 | 350 | | |
328 | 351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
534 | 534 | | |
535 | 535 | | |
536 | 536 | | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | 537 | | |
541 | 538 | | |
542 | 539 | | |
| |||
561 | 558 | | |
562 | 559 | | |
563 | 560 | | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | 561 | | |
569 | 562 | | |
570 | 563 | | |
| |||
574 | 567 | | |
575 | 568 | | |
576 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
577 | 574 | | |
578 | 575 | | |
579 | 576 | | |
| |||
627 | 624 | | |
628 | 625 | | |
629 | 626 | | |
| 627 | + | |
| 628 | + | |
630 | 629 | | |
631 | 630 | | |
632 | 631 | | |
| |||
638 | 637 | | |
639 | 638 | | |
640 | 639 | | |
641 | | - | |
| 640 | + | |
642 | 641 | | |
643 | 642 | | |
644 | 643 | | |
| |||
706 | 705 | | |
707 | 706 | | |
708 | 707 | | |
709 | | - | |
| 708 | + | |
710 | 709 | | |
711 | 710 | | |
712 | 711 | | |
| |||
2222 | 2221 | | |
2223 | 2222 | | |
2224 | 2223 | | |
2225 | | - | |
2226 | | - | |
| 2224 | + | |
| 2225 | + | |
2227 | 2226 | | |
2228 | | - | |
2229 | | - | |
| 2227 | + | |
2230 | 2228 | | |
2231 | | - | |
| 2229 | + | |
2232 | 2230 | | |
2233 | 2231 | | |
2234 | | - | |
2235 | | - | |
2236 | | - | |
2237 | | - | |
2238 | | - | |
2239 | 2232 | | |
2240 | 2233 | | |
2241 | 2234 | | |
2242 | 2235 | | |
2243 | 2236 | | |
2244 | 2237 | | |
2245 | 2238 | | |
2246 | | - | |
2247 | | - | |
2248 | | - | |
2249 | | - | |
2250 | | - | |
2251 | | - | |
2252 | | - | |
2253 | | - | |
2254 | | - | |
2255 | | - | |
2256 | | - | |
2257 | | - | |
2258 | 2239 | | |
2259 | 2240 | | |
2260 | 2241 | | |
| |||
2452 | 2433 | | |
2453 | 2434 | | |
2454 | 2435 | | |
2455 | | - | |
2456 | 2436 | | |
2457 | 2437 | | |
2458 | 2438 | | |
2459 | 2439 | | |
2460 | | - | |
| 2440 | + | |
2461 | 2441 | | |
2462 | | - | |
| 2442 | + | |
2463 | 2443 | | |
2464 | 2444 | | |
2465 | 2445 | | |
| |||
2468 | 2448 | | |
2469 | 2449 | | |
2470 | 2450 | | |
2471 | | - | |
2472 | | - | |
| 2451 | + | |
2473 | 2452 | | |
2474 | | - | |
2475 | | - | |
2476 | 2453 | | |
2477 | 2454 | | |
2478 | 2455 | | |
| |||
2517 | 2494 | | |
2518 | 2495 | | |
2519 | 2496 | | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
2520 | 2507 | | |
2521 | 2508 | | |
2522 | 2509 | | |
| |||
2526 | 2513 | | |
2527 | 2514 | | |
2528 | 2515 | | |
| 2516 | + | |
2529 | 2517 | | |
2530 | 2518 | | |
2531 | 2519 | | |
2532 | 2520 | | |
2533 | 2521 | | |
| 2522 | + | |
2534 | 2523 | | |
2535 | 2524 | | |
2536 | 2525 | | |
2537 | 2526 | | |
2538 | 2527 | | |
2539 | 2528 | | |
| 2529 | + | |
2540 | 2530 | | |
2541 | 2531 | | |
2542 | 2532 | | |
| |||
2548 | 2538 | | |
2549 | 2539 | | |
2550 | 2540 | | |
| 2541 | + | |
2551 | 2542 | | |
2552 | 2543 | | |
2553 | 2544 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
| |||
0 commit comments