From patchwork Sat Jan 30 07:05:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 8169901 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 67B059FBE9 for ; Sat, 30 Jan 2016 07:09:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 72C8520396 for ; Sat, 30 Jan 2016 07:09:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7AB9F20395 for ; Sat, 30 Jan 2016 07:09:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756501AbcA3HJL (ORCPT ); Sat, 30 Jan 2016 02:09:11 -0500 Received: from mail-ob0-f176.google.com ([209.85.214.176]:33802 "EHLO mail-ob0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756440AbcA3HI7 (ORCPT ); Sat, 30 Jan 2016 02:08:59 -0500 Received: by mail-ob0-f176.google.com with SMTP id wb13so48466508obb.1 for ; Fri, 29 Jan 2016 23:08:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daterainc-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Q2MjFeUV8XuY1f+2VDt692VDms6Q+VJDbi1fVbVt1dU=; b=NVqIax1eZVL4Y46Pzed6RSaeOgGrNq1CWzVMb+LZDPX3VhM0h+ftvsI3tDaJV88pM3 ng6b5wpxFLJfaEtH4niKuOw39dm58+4bAxzDKJFulxI/RSrG8AowLecUS0MX4J/lS4OC MeV4AZJus4hTo3TDsa3XjFHbGkkf0JG31qUlgkB4K4so9xEs6Si3y3JnhB5D29AXbdMu ej8Ln4vFKti9g0OCtUMzt5BSxbHYhbFOhFX/lzodj3eTS+tme268/Ke2Hg4LvdEUFUmb 7aGzMaA1PaXke0MtrZjoT/NkYZUps/fUgBGY6hoK9C2DSiRJ59VdUjTT9m0QuyFSSKKU +H3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Q2MjFeUV8XuY1f+2VDt692VDms6Q+VJDbi1fVbVt1dU=; b=kzNh85aejR/jq7KyahmnXVypI5i1E/nuGeYP2jjqcAEiA1s4m+2cMDzMEVif/SMNyT 3S6giVaKb2DhwTrtmJ+tybZzdR3wJDQ8/EWrxmjWMqOCMNG3ROfUMUlZIyXBImBYPV5i pwfq1GxWK+iqjNak9e5+rpSBBjqOkt3TVONf7P92g8P5SN0qpskZULeyC4wFVK2+kkF8 P/Tt4Ph2BVhujvRHiR4//8PxSfb2M2yGqyrKxhI8Mwt9hWAlvYmYA051kDDtlwxrrueH YdF+EUHIqrr/FSRAoRNRo1EKutV48q8pCuNwyzMh3N2s73HOaTCc650tiSEjNrI/Pca6 ShcA== X-Gm-Message-State: AG10YOQKukay2UlymvotwwdR0vh84FiC8jgaBScdAvJiB+2bDXrI/OEQwI7x86/K92vFyg== X-Received: by 10.60.58.103 with SMTP id p7mr10129858oeq.2.1454137739123; Fri, 29 Jan 2016 23:08:59 -0800 (PST) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by smtp.gmail.com with ESMTPSA id f8sm8655678obs.3.2016.01.29.23.08.58 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 29 Jan 2016 23:08:58 -0800 (PST) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , Christoph Hellwig , Hannes Reinecke , Mike Christie , Sagi Grimberg , Andy Grover , Sebastian Andrzej Siewior , Juergen Gross , Andrzej Pietrasiewicz , Chris Boot , Nicholas Bellinger Subject: [PATCH-v3 08/14] sbp-target: Convert to TARGET_SCF_ACK_KREF I/O krefs Date: Sat, 30 Jan 2016 07:05:52 +0000 Message-Id: <1454137558-30396-9-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1454137558-30396-1-git-send-email-nab@daterainc.com> References: <1454137558-30396-1-git-send-email-nab@daterainc.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nicholas Bellinger Cc: Chris Boot Cc: Christoph Hellwig Cc: Hannes Reinecke Signed-off-by: Nicholas Bellinger --- drivers/target/sbp/sbp_target.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c index 756e87f..251d532 100644 --- a/drivers/target/sbp/sbp_target.c +++ b/drivers/target/sbp/sbp_target.c @@ -893,7 +893,6 @@ static void tgt_agent_process_work(struct work_struct *work) STATUS_BLOCK_SBP_STATUS( SBP_STATUS_REQ_TYPE_NOTSUPP)); sbp_send_status(req); - sbp_free_request(req); return; case 3: /* Dummy ORB */ req->status.status |= cpu_to_be32( @@ -904,7 +903,6 @@ static void tgt_agent_process_work(struct work_struct *work) STATUS_BLOCK_SBP_STATUS( SBP_STATUS_DUMMY_ORB_COMPLETE)); sbp_send_status(req); - sbp_free_request(req); return; default: BUG(); @@ -988,7 +986,6 @@ static void tgt_agent_fetch_work(struct work_struct *work) spin_unlock_bh(&agent->lock); sbp_send_status(req); - sbp_free_request(req); return; } @@ -1235,7 +1232,7 @@ static void sbp_handle_command(struct sbp_target_request *req) req->se_cmd.tag = req->orb_pointer; if (target_submit_cmd(&req->se_cmd, sess->se_sess, req->cmd_buf, req->sense_buf, unpacked_lun, data_length, - TCM_SIMPLE_TAG, data_dir, 0)) + TCM_SIMPLE_TAG, data_dir, TARGET_SCF_ACK_KREF)) goto err; return; @@ -1247,7 +1244,6 @@ err: STATUS_BLOCK_LEN(1) | STATUS_BLOCK_SBP_STATUS(SBP_STATUS_UNSPECIFIED_ERROR)); sbp_send_status(req); - sbp_free_request(req); } /* @@ -1346,22 +1342,29 @@ static int sbp_rw_data(struct sbp_target_request *req) static int sbp_send_status(struct sbp_target_request *req) { - int ret, length; + int rc, ret = 0, length; struct sbp_login_descriptor *login = req->login; length = (((be32_to_cpu(req->status.status) >> 24) & 0x07) + 1) * 4; - ret = sbp_run_request_transaction(req, TCODE_WRITE_BLOCK_REQUEST, + rc = sbp_run_request_transaction(req, TCODE_WRITE_BLOCK_REQUEST, login->status_fifo_addr, &req->status, length); - if (ret != RCODE_COMPLETE) { - pr_debug("sbp_send_status: write failed: 0x%x\n", ret); - return -EIO; + if (rc != RCODE_COMPLETE) { + pr_debug("sbp_send_status: write failed: 0x%x\n", rc); + ret = -EIO; + goto put_ref; } pr_debug("sbp_send_status: status write complete for ORB: 0x%llx\n", req->orb_pointer); - - return 0; + /* + * Drop the extra ACK_KREF reference taken by target_submit_cmd() + * ahead of sbp_check_stop_free() -> transport_generic_free_cmd() + * final se_cmd->cmd_kref put. + */ +put_ref: + target_put_sess_cmd(&req->se_cmd); + return ret; } static void sbp_sense_mangle(struct sbp_target_request *req) @@ -1826,8 +1829,7 @@ static int sbp_check_stop_free(struct se_cmd *se_cmd) struct sbp_target_request *req = container_of(se_cmd, struct sbp_target_request, se_cmd); - transport_generic_free_cmd(&req->se_cmd, 0); - return 1; + return transport_generic_free_cmd(&req->se_cmd, 0); } static int sbp_count_se_tpg_luns(struct se_portal_group *tpg)