From patchwork Fri Jan 25 18:34:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10781877 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1DDE3746 for ; Fri, 25 Jan 2019 18:35:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E29F299B5 for ; Fri, 25 Jan 2019 18:35:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 021E42D40C; Fri, 25 Jan 2019 18:35:36 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 85F25299B5 for ; Fri, 25 Jan 2019 18:35:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726347AbfAYSfg (ORCPT ); Fri, 25 Jan 2019 13:35:36 -0500 Received: from out002.mailprotect.be ([83.217.72.86]:42677 "EHLO out002.mailprotect.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726468AbfAYSfg (ORCPT ); Fri, 25 Jan 2019 13:35:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mailprotect.be; s=mail; h=Content-Transfer-Encoding:MIME-Version:References :In-Reply-To:Message-Id:Date:Subject:Cc:To:From:reply-to:sender:bcc: content-type; bh=Ia9PN401CdZpd5j5sXgRL7+D8ITIK2WVCnEaIUITjVk=; b=fvQB6RmjvPVD AyJ43eEwS/+N9dUh74MJH4sh8Sv9n8evNmv1RT6M97N6ecmqgFccpN+BzI7TPCZQr3nMjn3SYXftm 9AiOHLoqxyAysr4sCrYDk0Z3zQ3nTLZyQfumfIIvpnIvs4aoKort2c3D9rz9rCuCQdaqpJL//oppa NiMLJtCkgHhLnmcUP+hEH+aAcJ7LoCInieC70cvnHfN9zgQf+SlCyCVcNzwkUVlWjpkT+fb21D1+L lNEPvy6i9zFsuEAWvUBhlDa0ac+hzNgw9HXgHWkgm1RZrBuBcyRkIS31s1qMnS0xklv6aSdHtc4l7 MkARa6qK54aIrA9bVtw05A==; Received: from smtp-auth.mailprotect.be ([178.208.39.155]) by com-mpt-out002.mailprotect.be with esmtp (Exim 4.89) (envelope-from ) id 1gn6K1-00043b-1R; Fri, 25 Jan 2019 19:35:21 +0100 Received: from desktop-bart.svl.corp.google.com (unknown [104.133.8.89]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-auth.mailprotect.be (Postfix) with ESMTPSA id 0FA94C0E37; Fri, 25 Jan 2019 19:35:16 +0100 (CET) From: Bart Van Assche To: "Martin K . Petersen" Cc: Christoph Hellwig , target-devel@vger.kernel.org, Bart Van Assche , Hannes Reinecke , Nicholas Bellinger , Mike Christie Subject: [PATCH 05/16] target/core: Add target_send_busy() Date: Fri, 25 Jan 2019 10:34:47 -0800 Message-Id: <20190125183458.220477-6-bvanassche@acm.org> X-Mailer: git-send-email 2.20.1.495.gaa96b0ce6b-goog In-Reply-To: <20190125183458.220477-1-bvanassche@acm.org> References: <20190125183458.220477-1-bvanassche@acm.org> MIME-Version: 1.0 X-Originating-IP: 178.208.39.155 X-SpamExperts-Domain: mailprotect.be X-SpamExperts-Username: 178.208.39.128/27 Authentication-Results: mailprotect.be; auth=pass smtp.auth=178.208.39.128/27@mailprotect.be X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing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+zXcnX6m+UeFXprlCOm3BAEb JtCUfKAc5tuMY57sizcN8Ybgo6ZwKd/lAfDURVeqOwDGeVPxhaTP1H+ecpe65ERyZY5hD/iWD0V+ +qD0gbQQTy2MYhai3vEoMrcP3ydYA96eq2KM8TNRPi4PtNSv3zAgl6Rv/trjt4n+OSd+6+F6OunJ 9jihx+Za/cV70jOJzN2r4A== X-Report-Abuse-To: spam@com-mpt-mgt001.mailprotect.be 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 Introduce a function that sends the SCSI status "BUSY" back to the initiator. The next patch will add a call to this function in the srpt target driver. Reviewed-by: Hannes Reinecke Cc: Nicholas Bellinger Cc: Mike Christie Cc: Christoph Hellwig Signed-off-by: Bart Van Assche --- drivers/target/target_core_transport.c | 16 ++++++++++++++++ include/target/target_core_fabric.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 6471ede00336..e3f7e21e6614 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -3246,6 +3246,22 @@ transport_send_check_condition_and_sense(struct se_cmd *cmd, } EXPORT_SYMBOL(transport_send_check_condition_and_sense); +/** + * target_send_busy - Send SCSI BUSY status back to the initiator + * @cmd: SCSI command for which to send a BUSY reply. + * + * Note: Only call this function if target_submit_cmd*() failed. + */ +int target_send_busy(struct se_cmd *cmd) +{ + WARN_ON_ONCE(cmd->se_cmd_flags & SCF_SCSI_TMR_CDB); + + cmd->scsi_status = SAM_STAT_BUSY; + trace_target_cmd_complete(cmd); + return cmd->se_tfo->queue_status(cmd); +} +EXPORT_SYMBOL(target_send_busy); + static void target_tmr_work(struct work_struct *work) { struct se_cmd *cmd = container_of(work, struct se_cmd, work); diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index 691c6b5e6520..8ed90407f062 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -173,6 +173,7 @@ int transport_generic_free_cmd(struct se_cmd *, int); bool transport_wait_for_tasks(struct se_cmd *); int transport_send_check_condition_and_sense(struct se_cmd *, sense_reason_t, int); +int target_send_busy(struct se_cmd *cmd); int target_get_sess_cmd(struct se_cmd *, bool); int target_put_sess_cmd(struct se_cmd *); void target_sess_cmd_list_set_waiting(struct se_session *);