From patchwork Mon Jan 25 08:11:06 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: 8104451 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 EB0B09F859 for ; Mon, 25 Jan 2016 08:14:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EFC5820364 for ; Mon, 25 Jan 2016 08:14:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 011CF2034F for ; Mon, 25 Jan 2016 08:14:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751913AbcAYIOg (ORCPT ); Mon, 25 Jan 2016 03:14:36 -0500 Received: from mail-ob0-f176.google.com ([209.85.214.176]:33991 "EHLO mail-ob0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751569AbcAYIOQ (ORCPT ); Mon, 25 Jan 2016 03:14:16 -0500 Received: by mail-ob0-f176.google.com with SMTP id vt7so109978693obb.1 for ; Mon, 25 Jan 2016 00:14:16 -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=i6ONeYURm+wFamh0VF1JT5dmIBGe1ExXkJ64FPxxdkA=; b=F88GG2PN0Zb61WJc1XcBwatM9rXzaVJQj1onRW8xQ3oyyAEKypO3t/kW0jfuJkG4NW yVmXLS8Kd4BmZmQGtxqjXVCFtF04xKN/AHjOgo4/9f9uX8qaBJRG6lZKis3UdN4R05P1 ORoxuXP2/4f+aIppkk2xVxBB1JadXY4p+8yeCKlIrQBUvRUQjTRLT2gl0Ez1i2icVOVG 6remS/4k3qWrBEfxKKQRs8JjAX9StVnTxB3RZjFRBAGuDDxP5DFGQG6Dv9E+MIGWncAf spgO1gWPZQi1P2PjAaA1xm5rXlE5WYj/Kw8JCVev7HsQevsJzzLmmNdSPTt6sbZyW3IH EUUQ== 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=i6ONeYURm+wFamh0VF1JT5dmIBGe1ExXkJ64FPxxdkA=; b=CCDY/h+XlEhHdJOZi0RMrXkH7GMmTJC+slmrUCzMjx49XzXDBeJxYT72dr7xD/b6Y8 QvkxvAajuIfZ+7+5vuNALQNw4QMuk6OBqOQjfw3e0QsVIQ5M5RoKeEZ3mLnidEavVB9h qtNafjt2FeDvnFtzGuNwARYQo4Y2CMxCd4iCKp/eqtK5SeUy2LdzyQhvTbr/tG1/A7OB 8c+/tSqTxudKpRGG4UHVTHDE45yvizT8fLXpSbdNtQ5nsEJW/l3qQtwLaFyeq+09szck /2mPOG5CSZad0afiL9dhy6anGU2Fssm/W+JjhB4v+lj9qGbZ9TcBrPO9x/JVKeK9/t8B 3DhQ== X-Gm-Message-State: AG10YOSRmWVQDCGHesBwP3ZsOYt9x65SarvwXuGqsoE1oreqffKKLMZyZFCUyyQ/jClzYg== X-Received: by 10.60.58.6 with SMTP id m6mr11078460oeq.47.1453709655873; Mon, 25 Jan 2016 00:14:15 -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.15 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 25 Jan 2016 00:14:15 -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 , David Vrabel Subject: [PATCH-v2 12/12] xen-scsiback: Convert to TARGET_SCF_ACK_KREF I/O krefs Date: Mon, 25 Jan 2016 08:11:06 +0000 Message-Id: <1453709466-6308-13-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: Juergen Gross Cc: Hannes Reinecke Cc: David Vrabel Signed-off-by: Nicholas Bellinger --- drivers/xen/xen-scsiback.c | 53 +++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index 640fb22..a10e5f1 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -381,6 +381,12 @@ static void scsiback_cmd_done(struct vscsibk_pend *pending_req) scsiback_do_resp_with_sense(sense_buffer, errors, resid, pending_req, pending_req->rqid); scsiback_put(info); + /* + * Drop the extra KREF_ACK reference taken by target_submit_cmd_map_sgls() + * ahead of scsiback_check_stop_free() -> transport_generic_free_cmd() + * final se_cmd->cmd_kref put. + */ + target_put_sess_cmd(&pending_req->se_cmd); } static void scsiback_cmd_exec(struct vscsibk_pend *pending_req) @@ -398,7 +404,7 @@ static void scsiback_cmd_exec(struct vscsibk_pend *pending_req) rc = target_submit_cmd_map_sgls(se_cmd, sess, pending_req->cmnd, pending_req->sense_buffer, pending_req->v2p->lun, pending_req->data_len, 0, - pending_req->sc_data_direction, 0, + pending_req->sc_data_direction, TARGET_SCF_ACK_KREF, pending_req->sgl, pending_req->n_sg, NULL, 0, NULL, 0); if (rc < 0) { @@ -587,31 +593,28 @@ static void scsiback_disconnect(struct vscsibk_info *info) static void scsiback_device_action(struct vscsibk_pend *pending_req, enum tcm_tmreq_table act, int tag) { - int rc, err = FAILED; struct scsiback_tpg *tpg = pending_req->v2p->tpg; + struct scsiback_nexus *nexus = tpg->tpg_nexus; struct se_cmd *se_cmd = &pending_req->se_cmd; struct scsiback_tmr *tmr; + u64 unpacked_lun = pending_req->v2p->lun; + int rc, err = FAILED; tmr = kzalloc(sizeof(struct scsiback_tmr), GFP_KERNEL); - if (!tmr) - goto out; + if (!tmr) { + target_put_sess_cmd(se_cmd); + goto err; + } init_waitqueue_head(&tmr->tmr_wait); - transport_init_se_cmd(se_cmd, tpg->se_tpg.se_tpg_tfo, - tpg->tpg_nexus->tvn_se_sess, 0, DMA_NONE, TCM_SIMPLE_TAG, - &pending_req->sense_buffer[0]); - - rc = core_tmr_alloc_req(se_cmd, tmr, act, GFP_KERNEL); - if (rc < 0) - goto out; - - se_cmd->se_tmr_req->ref_task_tag = tag; + rc = target_submit_tmr(&pending_req->se_cmd, nexus->tvn_se_sess, + &pending_req->sense_buffer[0], + unpacked_lun, tmr, act, GFP_KERNEL, + tag, TARGET_SCF_ACK_KREF); + if (rc) + goto err; - if (transport_lookup_tmr_lun(se_cmd, pending_req->v2p->lun) < 0) - goto out; - - transport_generic_handle_tmr(se_cmd); wait_event(tmr->tmr_wait, atomic_read(&tmr->tmr_complete)); err = (se_cmd->se_tmr_req->response == TMR_FUNCTION_COMPLETE) ? @@ -1368,16 +1371,7 @@ static u32 scsiback_tpg_get_inst_index(struct se_portal_group *se_tpg) static int scsiback_check_stop_free(struct se_cmd *se_cmd) { - /* - * Do not release struct se_cmd's containing a valid TMR pointer. - * These will be released directly in scsiback_device_action() - * with transport_generic_free_cmd(). - */ - if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB) - return 0; - - transport_generic_free_cmd(se_cmd, 0); - return 1; + return transport_generic_free_cmd(se_cmd, 0); } static void scsiback_release_cmd(struct se_cmd *se_cmd) @@ -1385,6 +1379,11 @@ static void scsiback_release_cmd(struct se_cmd *se_cmd) struct se_session *se_sess = se_cmd->se_sess; struct se_tmr_req *se_tmr = se_cmd->se_tmr_req; + if (se_tmr && se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB) { + struct scsiback_tmr *tmr = se_tmr->fabric_tmr_ptr; + kfree(tmr); + } + percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag); }