From patchwork Mon Jan 25 08:11:02 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: 8104401 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 045F6BEEED for ; Mon, 25 Jan 2016 08:14:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1905E20306 for ; Mon, 25 Jan 2016 08:14:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 278372034F for ; Mon, 25 Jan 2016 08:14:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754845AbcAYIO0 (ORCPT ); Mon, 25 Jan 2016 03:14:26 -0500 Received: from mail-oi0-f49.google.com ([209.85.218.49]:36297 "EHLO mail-oi0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754021AbcAYIOI (ORCPT ); Mon, 25 Jan 2016 03:14:08 -0500 Received: by mail-oi0-f49.google.com with SMTP id o124so82805556oia.3 for ; Mon, 25 Jan 2016 00:14:07 -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=a5zWfMrq9hlL6W+P2W2eK2LNgfJ5BW920XvMkADcNKFH6u2Ar0D+vixEolPaDDggW6 8pJNQO9Q4QOYYdnZbOAkOkywBoVHQJarG37gArFifeBFgi9lLLJ4Q2oHUmLKmNM0vCF5 N2L3ggzFdvg6W6j5msnu2ICFlosD3V9Wnv+uh2RmdNzpM8pO2U27xN7NZ7HRfoRXb3jh w4vGmyS4zvM/6rYAYQmGFBCNn+ZRc8C/xSZwix4oNlePqHSYiyOF+ZYHYv3PFLq8ilYp hujRVYCaOlSGe4JCOKMtiHF3no31UENdTBuOeoyUsk4NwbYUYnx+9xGtTFj5qaHg1GsN SAXQ== 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=SKKjATSn2iOi71GZLXx/5nm0CdN1iBGBlosGA6nT2k1NK+zbMSrtdaS6E5H39ASKep OiqCzI3XZbFlgtLJTKszrltF5nVeRMYUBgewR/j9fANcxmweQX4Kf5aMP9ilyDqK85am Sd6InUbInytKQvcGvqRbUB6t9VhsSmqmwhhnU1Y4Dg/f5Z2+DniJw0gsnIZLJpX2VMFR dbp1VbC1o/9OMZJaiV2UwsxbjlWLQBW0WW18fMGEMMTSD0apWFH0pmNnOG6zVkybQEq1 Q9vheTqJZn5Pg3qdlhJ85FECqxS8PNlarJrEIhU72IoBgb+b1OeOF/XmTfI+simF4MgD VE/w== X-Gm-Message-State: AG10YOTgxM9GbXuewDEmPo+iXrZZ0tHeAD23XJaXdV2W7OsGdtA0IkhmNyUtflEbxBo8qA== X-Received: by 10.202.209.138 with SMTP id i132mr11711818oig.122.1453709647443; Mon, 25 Jan 2016 00:14:07 -0800 (PST) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by smtp.gmail.com with ESMTPSA id v142sm9939087oie.28.2016.01.25.00.14.06 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 25 Jan 2016 00:14:06 -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-v2 08/12] sbp-target: Convert to TARGET_SCF_ACK_KREF I/O krefs Date: Mon, 25 Jan 2016 08:11:02 +0000 Message-Id: <1453709466-6308-9-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1453709466-6308-1-git-send-email-nab@daterainc.com> References: <1453709466-6308-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)