From patchwork Thu Mar 1 22:26:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10252763 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 021B660365 for ; Thu, 1 Mar 2018 22:26:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E716127816 for ; Thu, 1 Mar 2018 22:26:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC194286A9; Thu, 1 Mar 2018 22:26:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D2B627816 for ; Thu, 1 Mar 2018 22:26:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162585AbeCAW0q (ORCPT ); Thu, 1 Mar 2018 17:26:46 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:41196 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162580AbeCAW0m (ORCPT ); Thu, 1 Mar 2018 17:26:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1519943203; x=1551479203; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=R+OwMT/c4rGPE5B7oo2UlxwRFWFam87410zc+fQghIA=; b=GR9bFbyLm1bi9HksX+FN6lkLhNW3gjWqirnsh/2M8sJ0NZanBzh5Zrul BwO43TfBMZg5ya3s+rc5cgNx722DWSkJe+PRaE7wBtUhoSuXccJgVn17F APr9oWnd6kpzEs48DuK5waIWnaydUd/gusk6n0853lJDjlQKe/YSPULZ/ P5C0Pg1Sqw8wadiXVnrVcRWFaf47PUDSutNDx74ONncjUbudRaA3D01Ps c8FeBtOw7JOM1QsXkqoaaqmUlvnhy37qHge/vGenV9WIM6I21ERWH/kdL gLSFeaCckh0jNqV7tWfi+zoRj1FSahOJnQ56zHMwMMXqm8YXMLFeaSiv4 Q==; X-IronPort-AV: E=Sophos;i="5.47,409,1515427200"; d="scan'208";a="72564612" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Mar 2018 06:26:36 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 01 Mar 2018 14:20:39 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.171.236]) by uls-op-cesaip01.wdc.com with ESMTP; 01 Mar 2018 14:26:36 -0800 From: Bart Van Assche To: Nicholas Bellinger Cc: Christoph Hellwig , target-devel@vger.kernel.org, Bart Van Assche , Hannes Reinecke , Mike Christie Subject: [PATCH 14/14] target: Fix handling of removed LUNs Date: Thu, 1 Mar 2018 14:26:32 -0800 Message-Id: <20180301222632.31507-15-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180301222632.31507-1-bart.vanassche@wdc.com> References: <20180301222632.31507-1-bart.vanassche@wdc.com> Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Send a valid ASC / ASCQ combination back to the initiator if a SCSI command is received after a LUN has been removed. This patch fixes the following call trace: WARNING: CPU: 0 PID: 4 at drivers/target/target_core_transport.c:3131 translate_sense_reason+0x164/0x190 [target_core_mod] Workqueue: ib-comp-wq ib_cq_poll_work [ib_core] RIP: 0010:translate_sense_reason+0x164/0x190 [target_core_mod] Call Trace: transport_send_check_condition_and_sense+0x95/0x1c0 [target_core_mod] transport_generic_request_failure+0x102/0x270 [target_core_mod] transport_generic_new_cmd+0x138/0x340 [target_core_mod] transport_handle_cdb_direct+0x2f/0x80 [target_core_mod] target_submit_cmd_map_sgls+0x212/0x2a0 [target_core_mod] srpt_handle_new_iu+0x244/0x680 [ib_srpt] __ib_process_cq+0x6d/0xc0 [ib_core] ib_cq_poll_work+0x18/0x50 [ib_core] process_one_work+0x20b/0x6a0 worker_thread+0x35/0x380 kthread+0x117/0x130 ret_from_fork+0x24/0x30 Signed-off-by: Bart Van Assche Cc: Hannes Reinecke Cc: Christoph Hellwig Cc: Mike Christie --- drivers/target/target_core_ua.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/target/target_core_ua.c b/drivers/target/target_core_ua.c index be25eb807a5f..08c1e550babd 100644 --- a/drivers/target/target_core_ua.c +++ b/drivers/target/target_core_ua.c @@ -218,17 +218,15 @@ void core_scsi3_ua_for_check_condition( return; nacl = sess->se_node_acl; - if (!nacl) + if (WARN_ON_ONCE(!nacl)) return; rcu_read_lock(); deve = target_nacl_find_deve(nacl, cmd->orig_fe_lun); - if (!deve) { - rcu_read_unlock(); - return; - } - if (!atomic_read(&deve->ua_count)) { + if (!deve || !atomic_read(&deve->ua_count)) { rcu_read_unlock(); + *asc = 0x25; + *ascq = 0; return; } /*