From patchwork Thu May 11 00:23:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9720799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D0E7F60236 for ; Thu, 11 May 2017 00:23:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D739D2863A for ; Thu, 11 May 2017 00:23:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C849428646; Thu, 11 May 2017 00:23:32 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_TVD_MIME_EPI 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 A72D42863A for ; Thu, 11 May 2017 00:23:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751820AbdEKAXa (ORCPT ); Wed, 10 May 2017 20:23:30 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:12759 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751096AbdEKAX3 (ORCPT ); Wed, 10 May 2017 20:23:29 -0400 X-IronPort-AV: E=Sophos;i="5.38,321,1491235200"; d="scan'208,223";a="16744049" Received: from mail-by2nam03lp0050.outbound.protection.outlook.com (HELO NAM03-BY2-obe.outbound.protection.outlook.com) ([216.32.180.50]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2017 08:23:28 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=qqqhbD/2qBskB362381c5epxaC0hxHD5PGtn1MewPSU=; b=b7dpXfWxHVqPdCjhXBRdswkYo0uJe0iDpZywtoDoU9b1vCtieLpPkeGWTxddQatkLNjhk+sWiDEdsMrLcLq5qIpootSTWUp2AxqogRKhl8y7P4ghKV90QB0D4ZaI4S6VR6fbNapzPWIl7D3nvH2vzKDMYl5btLFAdPxbCwARbp0= Received: from CY1PR0401MB1536.namprd04.prod.outlook.com (10.163.19.154) by CY1PR0401MB1533.namprd04.prod.outlook.com (10.163.19.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1084.16; Thu, 11 May 2017 00:23:26 +0000 Received: from CY1PR0401MB1536.namprd04.prod.outlook.com ([10.163.19.154]) by CY1PR0401MB1536.namprd04.prod.outlook.com ([10.163.19.154]) with mapi id 15.01.1084.020; Thu, 11 May 2017 00:23:26 +0000 From: Bart Van Assche To: "hch@lst.de" CC: "ddiss@suse.de" , "hare@suse.com" , "target-devel@vger.kernel.org" , "agrover@redhat.com" , "nab@linux-iscsi.org" , "stable@vger.kernel.org" Subject: Re: [PATCH 03/19] target: Avoid that aborting a command sporadically hangs Thread-Topic: [PATCH 03/19] target: Avoid that aborting a command sporadically hangs Thread-Index: AQHSyezOsXURj6CLG0iwBmUWbv+oEQ== Date: Thu, 11 May 2017 00:23:26 +0000 Message-ID: <1494462204.12318.1.camel@sandisk.com> References: <20170504225102.8931-1-bart.vanassche@sandisk.com> <20170504225102.8931-4-bart.vanassche@sandisk.com> <20170505085355.GC4858@lst.de> In-Reply-To: <20170505085355.GC4858@lst.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: authentication-results: lst.de; dkim=none (message not signed) header.d=none; lst.de; dmarc=none action=none header.from=sandisk.com; x-originating-ip: [63.163.107.100] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; CY1PR0401MB1533; 7:HIC/Nq+kbY6Ey1qlWNEA1we4oUiqyJ8cmxiReLQm2BYQMfvTacrjtOMtvlV6+lq8Gk+N7bxaA/gu11b5ibwP4Wy085UvVwuy2RJSH0E2YerQl55Ymro727pQ7eI+YcevT6Fm13/Vj3aZJItYLYAzYBBGUwjr0SHE307anrpvyVtsWF4sugiPfcnN5H9NaNcjVJqDscWowK/gjEuUJCfhkIc4nohnSvbZdJsIP7KMeoqZG1kk5gFWe6hGRkUufEauQIsV2+YWX+Rkov+VWb1qeImMRIY4Hf30oRtZLP+XYNAhFV8HEy16U2Z4PtzbhpmvJ8YRwaNWwvqdM0qm500zVA==; 20:9neb77Uuc9Jy1BOpzM1hdmVovlD0MztXcoj8XW+E2sIeqpb4zjeh/XJ0sE9Pn6Gwe8C5EmDbForok4YwV9SmDwZLRovQUcsSkDfpmxb2Pmtu+eMVZVVutBmC0mkPK+O7A/KrYnvqahCUVX91OV6H7MJEArQK+llfEIcXvrD1uJ4= x-ms-office365-filtering-correlation-id: 96e807a4-2c04-41ea-6add-08d49803f11c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081); SRVR:CY1PR0401MB1533; wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(17755550239193); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(102415395)(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123558100)(20161123555025)(20161123564025)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148); SRVR:CY1PR0401MB1533; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0401MB1533; x-forefront-prvs: 0304E36CA3 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(39860400002)(39840400002)(39450400003)(39850400002)(39410400002)(39400400002)(377424004)(24454002)(7736002)(2351001)(4326008)(122556002)(54906002)(478600001)(53936002)(6916009)(2900100001)(3280700002)(72206003)(110136004)(5660300001)(38730400002)(8936002)(99286003)(36756003)(102836003)(3846002)(305945005)(6246003)(6512007)(2950100002)(229853002)(6116002)(76176999)(86362001)(1730700003)(81166006)(25786009)(50986999)(5640700003)(77096006)(6486002)(6436002)(5890100001)(8676002)(54356999)(2501003)(6506006)(99936001)(33646002)(103116003)(2906002)(66066001)(3660700001)(189998001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0401MB1533; H:CY1PR0401MB1536.namprd04.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-originalarrivaltime: 11 May 2017 00:23:26.2327 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0401MB1533 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 On Fri, 2017-05-05 at 10:53 +0200, Christoph Hellwig wrote: > On Thu, May 04, 2017 at 03:50:46PM -0700, Bart Van Assche wrote: > > For several target drivers (e.g. ib_srpt and ib_isert) sleeping inside > > transport_generic_free_cmd() causes RDMA completion processing to stall. > > Hence only sleep inside this function if the (iSCSI) target driver > > requires this. > > This looks reasonable to me: > > Reviewed-by: Christoph Hellwig > > But as a further step can we try to move the waiting behavior entirely > into the caller that actually cares, > > e.g. move the conditional target_wait_free_cmd before the call > to transport_generic_free_cmd in transport_generic_free_cmd, > and move this second wait_for_completion after the > transport_generic_free_cmd call based on an indicator (return value > or se_cmd flag)? Hello Christoph, I have started working on eliminating the waiting code from transport_generic_free_cmd(). I'm still working on a patch for the iSCSI target driver. What I came up so far for the loop and Xen scsiback drivers is attached to this e-mail. Bart. From 4c961dc45bb5d35cdefa8f0f94ebd8453a9d6cc4 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 10 May 2017 15:01:38 -0700 Subject: [PATCH 5/5] target/tcm_loop: Make TMF processing slightly faster Target drivers must guarantee that struct se_cmd and struct se_tmr_req exist as long as target_tmr_work() is in progress. This is why the tcm_loop driver today passes 1 as second argument to transport_generic_free_cmd() from inside the TMF code. Instead of making the TMF code wait, make the TMF code obtain two references (SCF_ACK_KREF) and drop one reference from inside the .check_stop_free() callback. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: David Disseldorp --- drivers/target/loopback/tcm_loop.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 48d751c53104..136d70285f9a 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -51,27 +51,18 @@ static int tcm_loop_queue_status(struct se_cmd *se_cmd); */ static int tcm_loop_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 tcm_loop_device_reset() - * with transport_generic_free_cmd(). - */ - if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB) - return 0; - /* - * Release the struct se_cmd, which will make a callback to release - * struct tcm_loop_cmd * in tcm_loop_deallocate_core_cmd() - */ - transport_generic_free_cmd(se_cmd, 0); - return 1; + return transport_generic_free_cmd(se_cmd, 0); } static void tcm_loop_release_cmd(struct se_cmd *se_cmd) { struct tcm_loop_cmd *tl_cmd = container_of(se_cmd, struct tcm_loop_cmd, tl_se_cmd); + struct se_tmr_req *se_tmr = se_cmd->se_tmr_req; + struct tcm_loop_tmr *tl_tmr = se_tmr ? se_tmr->fabric_tmr_ptr : NULL; kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); + kfree(tl_tmr); } static int tcm_loop_show_info(struct seq_file *m, struct Scsi_Host *host) @@ -251,19 +242,23 @@ static int tcm_loop_issue_tmr(struct tcm_loop_tpg *tl_tpg, rc = target_submit_tmr(se_cmd, se_sess, NULL, 0 /* unpacked_lun */, tl_tmr, tmr, GFP_KERNEL, TCM_SIMPLE_TAG, - 0 /*flags*/); + TARGET_SCF_ACK_KREF); if (rc < 0) goto release; wait_for_completion(&tl_tmr->done); ret = se_cmd->se_tmr_req->response; + target_put_sess_cmd(se_cmd); + +out: + return ret; release: if (se_cmd) - transport_generic_free_cmd(se_cmd, 1); + transport_generic_free_cmd(se_cmd, 0); else kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); kfree(tl_tmr); - return ret; + goto out; } static int tcm_loop_abort_task(struct scsi_cmnd *sc) -- 2.12.2