[PATCH 4.9 011/310] IB/srpt: Avoid that aborting a command triggers a kernel warning

From: Greg Kroah-Hartman
Date: Wed Apr 11 2018 - 14:52:52 EST


4.9-stable review patch. If anyone has any objections, please let me know.

------------------

From: Bart Van Assche <bart.vanassche@xxxxxxxxxxx>


[ Upstream commit bd2c52d733f126ff75f99c537a27655b2db07e28 ]

Avoid that the following warning is triggered:

WARNING: CPU: 10 PID: 166 at ../drivers/infiniband/ulp/srpt/ib_srpt.c:2674 srpt_release_cmd+0x139/0x140 [ib_srpt]
CPU: 10 PID: 166 Comm: kworker/u24:8 Not tainted 4.9.4-1-default #1
Workqueue: tmr-fileio target_tmr_work [target_core_mod]
Call Trace:
[<ffffffffaa3c4f70>] dump_stack+0x63/0x83
[<ffffffffaa0844eb>] __warn+0xcb/0xf0
[<ffffffffaa0845dd>] warn_slowpath_null+0x1d/0x20
[<ffffffffc06ba429>] srpt_release_cmd+0x139/0x140 [ib_srpt]
[<ffffffffc06e4377>] target_release_cmd_kref+0xb7/0x120 [target_core_mod]
[<ffffffffc06e4d7f>] target_put_sess_cmd+0x2f/0x60 [target_core_mod]
[<ffffffffc06e15e0>] core_tmr_lun_reset+0x340/0x790 [target_core_mod]
[<ffffffffc06e4816>] target_tmr_work+0xe6/0x140 [target_core_mod]
[<ffffffffaa09e4d3>] process_one_work+0x1f3/0x4d0
[<ffffffffaa09e7f8>] worker_thread+0x48/0x4e0
[<ffffffffaa09e7b0>] ? process_one_work+0x4d0/0x4d0
[<ffffffffaa0a46da>] kthread+0xca/0xe0
[<ffffffffaa0a4610>] ? kthread_park+0x60/0x60
[<ffffffffaa71b775>] ret_from_fork+0x25/0x30

Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxxxxxx>
Reviewed-by: Hannes Reinecke <hare@xxxxxxxx>
Cc: Doug Ledford <dledford@xxxxxxxxxx>
Cc: Christoph Hellwig <hch@xxxxxx>
Cc: David Disseldorp <ddiss@xxxxxxx>
Signed-off-by: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>
Signed-off-by: Sasha Levin <alexander.levin@xxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/infiniband/ulp/srpt/ib_srpt.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -2666,7 +2666,8 @@ static void srpt_release_cmd(struct se_c
struct srpt_rdma_ch *ch = ioctx->ch;
unsigned long flags;

- WARN_ON(ioctx->state != SRPT_STATE_DONE);
+ WARN_ON_ONCE(ioctx->state != SRPT_STATE_DONE &&
+ !(ioctx->cmd.transport_state & CMD_T_ABORTED));

if (ioctx->n_rw_ctx) {
srpt_free_rw_ctxs(ch, ioctx);