From patchwork Sat Jan 30 07:05:51 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: 8169871 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 B02FA9FBE9 for ; Sat, 30 Jan 2016 07:09:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B76E220396 for ; Sat, 30 Jan 2016 07:09:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CC6AB20395 for ; Sat, 30 Jan 2016 07:09:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756286AbcA3HJC (ORCPT ); Sat, 30 Jan 2016 02:09:02 -0500 Received: from mail-ob0-f169.google.com ([209.85.214.169]:33793 "EHLO mail-ob0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756272AbcA3HI6 (ORCPT ); Sat, 30 Jan 2016 02:08:58 -0500 Received: by mail-ob0-f169.google.com with SMTP id wb13so48466263obb.1 for ; Fri, 29 Jan 2016 23:08:57 -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=DPp1fCtTV4QypOn+8W6FLtSwiqRr9D4bO8rel59Kfig=; b=H3uy7Ag6Mqhdp7XAkecYyoXbNtTVH7t/BcExjFwQY585TubnHgkjCM4TpziXyHFN4n utiOVFK0h0J3oEb8mUj7Ph1Rk7X/sQCtay90uhdxdhMQ85OdKhUWmY4ILPVDp7/N/x4P aiExnl5vkyLYJvnEkhNn78CnCQlMZaLIHU+X9Sct2PsgXwY6jqVNj3DtpgbpvuXU0u7z CA7T7wy9osoBpGPSfSyVqsUydp4BVTTgbzE+JNn2OPjuYBXp4nfNX5ipvyytGx0LgXLH ef1rc3O+8Kazc77QUl9J6ZHBCKjhTPnwfX2p8egQWKhCR2lfnzws58iECGpWXU3wdQed OyTA== 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=DPp1fCtTV4QypOn+8W6FLtSwiqRr9D4bO8rel59Kfig=; b=kypf0wNIlgxatqTYElZfJQ/sT+e9JZ4wY9quuUJG8JSB295ksU0gLFG49gD+4Fvavp wuDR9R6jETQh53L5DoLEU56MT4N3mKaBrurwe9B2D1XXLdi+5EkSbwcU373m64B1AzWk VaDUo0l1qWCPlpjhV2lqBybrbYpArOt7OHhp7lvoJK96H8AU+m64ikR87khhg2DN3YsL +W91cL4zSvCNGjNC0Gta6SqtWzoOdc4/rqtvZCtkTFvG3qS24cSwVcYaafuACSwrfmQf 7gVRCeOoHohG8xoLgzAIKhQeMEtyUQzUhbyEe0WiWFfvdDBGsFiWzNFVgC36wSe6uYeR Xerg== X-Gm-Message-State: AG10YOQGqIUqp0lZDPit9GpgMRS5AvqvOejYuOeTkz2gFRSP+4/BCNRkXCzSqO7i6znCNA== X-Received: by 10.60.232.164 with SMTP id tp4mr10124931oec.55.1454137737719; Fri, 29 Jan 2016 23:08:57 -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.56 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 29 Jan 2016 23:08:57 -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 07/14] sbp-target: Conversion to percpu_ida tag pre-allocation Date: Sat, 30 Jan 2016 07:05:51 +0000 Message-Id: <1454137558-30396-8-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 | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c index ddd3398..756e87f 100644 --- a/drivers/target/sbp/sbp_target.c +++ b/drivers/target/sbp/sbp_target.c @@ -209,8 +209,10 @@ static struct sbp_session *sbp_session_create( INIT_DELAYED_WORK(&sess->maint_work, session_maintenance_work); sess->guid = guid; - sess->se_sess = target_alloc_session(&tpg->se_tpg, 0, 0, TARGET_PROT_NORMAL, - guid_str, sess, NULL); + sess->se_sess = target_alloc_session(&tpg->se_tpg, 128, + sizeof(struct sbp_target_request), + TARGET_PROT_NORMAL, guid_str, + sess, NULL); if (IS_ERR(sess->se_sess)) { pr_err("failed to init se_session\n"); ret = PTR_ERR(sess->se_sess); @@ -921,6 +923,24 @@ static inline bool tgt_agent_check_active(struct sbp_target_agent *agent) return active; } +static struct sbp_target_request *sbp_mgt_get_req(struct sbp_session *sess, + struct fw_card *card, u64 next_orb) +{ + struct se_session *se_sess = sess->se_sess; + struct sbp_target_request *req; + int tag; + + tag = percpu_ida_alloc(&se_sess->sess_tag_pool, GFP_ATOMIC); + if (tag < 0) + return ERR_PTR(-ENOMEM); + + req = &((struct sbp_target_request *)se_sess->sess_cmd_map)[tag]; + req->se_cmd.map_tag = tag; + req->se_cmd.tag = next_orb; + + return req; +} + static void tgt_agent_fetch_work(struct work_struct *work) { struct sbp_target_agent *agent = @@ -932,7 +952,7 @@ static void tgt_agent_fetch_work(struct work_struct *work) u64 next_orb = agent->orb_pointer; while (next_orb && tgt_agent_check_active(agent)) { - req = kzalloc(sizeof(*req), GFP_KERNEL); + req = sbp_mgt_get_req(sess, sess->card, next_orb); if (!req) { spin_lock_bh(&agent->lock); agent->state = AGENT_STATE_DEAD; @@ -1430,9 +1450,13 @@ static int sbp_send_sense(struct sbp_target_request *req) static void sbp_free_request(struct sbp_target_request *req) { + struct se_cmd *se_cmd = &req->se_cmd; + struct se_session *se_sess = se_cmd->se_sess; + kfree(req->pg_tbl); kfree(req->cmd_buf); - kfree(req); + + percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag); } static void sbp_mgt_agent_process(struct work_struct *work) @@ -1592,8 +1616,12 @@ static void sbp_mgt_agent_rw(struct fw_card *card, rcode = RCODE_CONFLICT_ERROR; goto out; } - + // XXX: +#if 0 + req = sbp_mgt_get_req(agent->login->sess, card); +#else req = kzalloc(sizeof(*req), GFP_ATOMIC); +#endif if (!req) { rcode = RCODE_CONFLICT_ERROR; goto out;