From patchwork Sat Jan 30 07:05:56 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: 8169931 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 CACC59F6DA for ; Sat, 30 Jan 2016 07:09:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CB26B20395 for ; Sat, 30 Jan 2016 07:09:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C915620397 for ; Sat, 30 Jan 2016 07:09:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756496AbcA3HJX (ORCPT ); Sat, 30 Jan 2016 02:09:23 -0500 Received: from mail-ob0-f173.google.com ([209.85.214.173]:33753 "EHLO mail-ob0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756550AbcA3HJF (ORCPT ); Sat, 30 Jan 2016 02:09:05 -0500 Received: by mail-ob0-f173.google.com with SMTP id is5so81398761obc.0 for ; Fri, 29 Jan 2016 23:09:05 -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=+XFrcZVtW1MYxthSqRd+Kj8dPoSJhx2EgBmpuj+j76A=; b=pBtlKoLT40N9YHFk1YdUeixgSGunw6lQtR+grfySW27oYZHZRoyUKVRPBru6vBvZlM +iR9kJHFo9H4V6U+csZKArUUCiY7vwxZnCrWXs3nmB6QWHADS/3ZPg5QSnXDbyNxW87g krQtj6E7axi+i7LRvzHjaIfWnMnazICeomoZWP6OhBbfSy3PCXGfek9Kbqydd5/sB6kl bEF44Hytyt7nTIeme9SWcril2GyjUHDQw+J2B0PLyG5l71yX2jPrlubkZTPASlfaBi/8 nytOeDW2VSS4dA5fnopfKsGkfiGrnkgySal0FKeE+RnnKb0wDD08ECfjAh+KiW5RjUxs lZ2Q== 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=+XFrcZVtW1MYxthSqRd+Kj8dPoSJhx2EgBmpuj+j76A=; b=YdjvQ+07HdQpyLeYUmxkE/4MyZj9pgDG5BfxQnr/kBSprrTknbL4pmp+7u41xv0zVD vNbrzzzyB23I2gf63p61f3qH936VJh8JLRkhTEPswEb07A+hUvJypLtHR8s+BXJjABU7 RywpjCtA5ekcNAPNz/Q4zcwMqrDEAmiBZL4UjW30sv6IqUTzNjR23MyqrgL+t6QvYprt zo3ZwfJcPjbwklsMfpW19VkURo1ptcvjgHRkyfWo7aqJ5MjnUiaJpWNsBZDgyd+Jq2Jo BhaS6wpo+ujUEEYes5hBeLRJ5ycRzTWkdJwuSfGD4VtLOeOgRe7wbjCyyb+MPf6RKr5U XWfA== X-Gm-Message-State: AG10YORn+0dQLgGKj7+vqNtk7Pi3PdgzZYPuX8wSvxei7hqqHn9pT7jUKmoU2gWuF8SWFg== X-Received: by 10.182.33.101 with SMTP id q5mr9771961obi.28.1454137744861; Fri, 29 Jan 2016 23:09:04 -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.09.04 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 29 Jan 2016 23:09:04 -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-v3 12/14] xen-scsiback: Convert to TARGET_SCF_ACK_KREF I/O krefs Date: Sat, 30 Jan 2016 07:05:56 +0000 Message-Id: <1454137558-30396-13-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: Juergen Gross Cc: Hannes Reinecke Cc: David Vrabel Signed-off-by: Nicholas Bellinger --- drivers/xen/xen-scsiback.c | 56 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index ea3b822..eaf9e21 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -386,6 +386,12 @@ static void scsiback_cmd_done(struct vscsibk_pend *pending_req) scsiback_fast_flush_area(pending_req); scsiback_do_resp_with_sense(sense_buffer, errors, resid, pending_req); 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) @@ -403,7 +409,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) { @@ -592,31 +598,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; - - if (transport_lookup_tmr_lun(se_cmd, pending_req->v2p->lun) < 0) - goto out; + 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; - 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) ? @@ -625,7 +628,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, scsiback_do_resp_with_sense(NULL, err, 0, pending_req); transport_generic_free_cmd(&pending_req->se_cmd, 1); return; -out: +err: if (tmr) kfree(tmr); scsiback_do_resp_with_sense(NULL, err, 0, pending_req); @@ -1370,21 +1373,18 @@ 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) { 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); }