From 34f9b158e236c63e7748477608d7581554b510a7 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 12 Feb 2019 03:16:12 +0000 Subject: [PATCH] scst: Only switch to thread context if no Data-Out buffer and no failure This patch avoids that the following is reported: [0]: scst_pre_parse:949:Failed CDB: (h)___0__1__2__3__4__5__6__7__8__9__A__B__C__D__E__F 0: 8b 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 ................ [0]: dev_vdisk: vdisk_parse_offset:2999:Unknown opcode 0x8b [0]: scst_parse_cmd:1333:Atomic context and non-WRITE data direction, rescheduling (cmd 00000000cd981f2b) [0]: scst: scst_process_active_cmd:5571:***CRITICAL ERROR***: cmd 00000000cd981f2b is in invalid state 10) BUG at /home/bart/software/scst.git/scst/src/scst_targ.c:5572 ------------[ cut here ]------------ DEBUG_LOCKS_WARN_ON(val > preempt_count()) WARNING: CPU: 1 PID: 0 at kernel/sched/core.c:3230 preempt_count_sub+0x7f/0xd0 Modules linked in: qla2x00tgt(O) scst_vdisk(O) isert_scst(O) iscsi_scst(O) scst(O) sd_mod sg brd dlm af_packet crct10dif_pclmul hid_generic aesni_intel aes_x86_64 crypto_simd cryptd usbhid glue_helper hid qla2xxx_scst(O) virtio_balloon l CPU: 1 PID: 0 Comm: swapper/1 Tainted: G W O 5.0.0-rc6-dbg+ #2 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Call Trace: __local_bh_enable_ip+0x7e/0x140 local_bh_enable+0x15/0x20 [scst] scst_process_active_cmd+0x555/0x570 [scst] scst_do_job_active.constprop.23+0x57/0xe0 [scst] scst_cmd_tasklet+0x42/0x70 [scst] tasklet_action_common.isra.14+0xc3/0x280 tasklet_action+0x3d/0x50 __do_softirq+0x12d/0x5b7 irq_exit+0xdd/0x100 do_IRQ+0xc3/0x160 common_interrupt+0xf/0xf git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7922 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_targ.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 628239d98..617cc3cbb 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -1327,7 +1327,7 @@ set_res: * be because of the SCST_TGT_DEV_AFTER_* optimization, but during * parsing data_direction can change, so we need to recheck. */ - if (unlikely(scst_cmd_atomic(cmd) && + if (unlikely(scst_cmd_atomic(cmd) && cmd->status == 0 && !(cmd->data_direction & SCST_DATA_WRITE))) { TRACE_DBG_FLAG(TRACE_DEBUG|TRACE_MINOR, "Atomic context and " "non-WRITE data direction, rescheduling (cmd %p)", cmd);