From: Mike Christie <michael.christie@oracle.com>
To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com,
mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com,
varun@chelsio.com, martin.petersen@oracle.com,
linux-scsi@vger.kernel.org, jejb@linux.ibm.com
Subject: [PATCH 08/22] libiscsi: add task prealloc/free callouts
Date: Thu, 17 Dec 2020 00:41:58 -0600 [thread overview]
Message-ID: <1608187332-4434-9-git-send-email-michael.christie@oracle.com> (raw)
In-Reply-To: <1608187332-4434-1-git-send-email-michael.christie@oracle.com>
Some drivers need to allocate resources that functions
like dma_alloc* that can't be allocated with the iscsi_task struct.
The next patches have the iscsi drivers use the block/scsi mq cmd
allocators for scsi tasks and the drivers can use the init_cmd_priv
callout to allocate these extra resource for scsi tasks there. For
mgmt tasks, drivers can use the callouts added in this patch.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
drivers/scsi/libiscsi.c | 21 +++++++++++++++++++--
include/scsi/scsi_transport_iscsi.h | 5 +++++
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 65bcdcc..9833fc3 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -2904,10 +2904,15 @@ struct iscsi_cls_session *
task->itt = cmd_i;
task->state = ISCSI_TASK_FREE;
INIT_LIST_HEAD(&task->running);
+
+ if (iscsit->alloc_task_priv) {
+ if (iscsit->alloc_task_priv(session, task))
+ goto free_task_priv;
+ }
}
if (!try_module_get(iscsit->owner))
- goto module_get_fail;
+ goto free_task_priv;
if (iscsi_add_session(cls_session, id))
goto cls_session_fail;
@@ -2916,7 +2921,12 @@ struct iscsi_cls_session *
cls_session_fail:
module_put(iscsit->owner);
-module_get_fail:
+free_task_priv:
+ for (cmd_i--; cmd_i >= 0; cmd_i--) {
+ if (iscsit->free_task_priv)
+ iscsit->free_task_priv(session, session->cmds[cmd_i]);
+ }
+
iscsi_pool_free(&session->cmdpool);
cmdpool_alloc_fail:
iscsi_free_session(cls_session);
@@ -2935,6 +2945,13 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
struct iscsi_session *session = cls_session->dd_data;
struct module *owner = cls_session->transport->owner;
struct Scsi_Host *shost = session->host;
+ int cmd_i;
+
+ for (cmd_i = 0; cmd_i < session->cmds_max; cmd_i++) {
+ if (session->tt->free_task_priv)
+ session->tt->free_task_priv(session,
+ session->cmds[cmd_i]);
+ }
iscsi_pool_free(&session->cmdpool);
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 8a26a2f..cdd358e 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -22,6 +22,7 @@
struct scsi_cmnd;
struct iscsi_cls_conn;
struct iscsi_conn;
+struct iscsi_session;
struct iscsi_task;
struct sockaddr;
struct iscsi_iface;
@@ -106,6 +107,10 @@ struct iscsi_transport {
void (*get_stats) (struct iscsi_cls_conn *conn,
struct iscsi_stats *stats);
+ int (*alloc_task_priv) (struct iscsi_session *session,
+ struct iscsi_task *task);
+ void (*free_task_priv) (struct iscsi_session *session,
+ struct iscsi_task *task);
int (*init_task) (struct iscsi_task *task);
int (*xmit_task) (struct iscsi_task *task);
void (*cleanup_task) (struct iscsi_task *task);
--
1.8.3.1
next prev parent reply other threads:[~2020-12-17 6:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-17 6:41 [RFC PATCH 00/22 V3] iscsi: lock clean ups Mike Christie
2020-12-17 6:41 ` [PATCH 01/22] libiscsi: fix iscsi_prep_scsi_cmd_pdu error handling Mike Christie
2020-12-17 6:41 ` [PATCH 02/22] libiscsi: drop taskqueuelock Mike Christie
2020-12-17 6:41 ` [PATCH 03/22] libiscsi: fix iscsi_task use after free Mike Christie
2020-12-17 6:41 ` [PATCH 04/22] qla4xxx: use iscsi_is_session_online Mike Christie
2020-12-17 6:41 ` [PATCH 05/22] iscsi class: drop session lock in iscsi_session_chkready Mike Christie
2020-12-17 6:41 ` [PATCH 06/22] libiscsi: remove queued_cmdsn Mike Christie
2020-12-17 6:41 ` [PATCH 07/22] libiscsi: drop frwd lock for session state Mike Christie
2020-12-17 6:41 ` Mike Christie [this message]
2020-12-17 6:41 ` [PATCH 09/22] qedi: implement alloc_task_priv/free_task_priv Mike Christie
2020-12-17 6:42 ` [PATCH 10/22] bnx2i: " Mike Christie
2020-12-17 6:42 ` [PATCH 11/22] iser, be2iscsi, qla4xxx: set scsi_host_template cmd_size Mike Christie
2020-12-17 6:42 ` [PATCH 12/22] bnx2i: " Mike Christie
2020-12-17 6:42 ` [PATCH 13/22] qedi: " Mike Christie
2020-12-17 6:42 ` [PATCH 14/22] iscsi_tcp, libcxgbi: " Mike Christie
2020-12-17 6:42 ` [PATCH 15/22] libiscsi: use scsi_host_busy_iter Mike Christie
2020-12-17 6:42 ` [PATCH 16/22] be2iscsi: " Mike Christie
2020-12-17 6:42 ` [PATCH 17/22] bnx2i: prep driver for switch to blk tags Mike Christie
2020-12-17 6:42 ` [PATCH 18/22] qedi: " Mike Christie
2020-12-17 6:42 ` [PATCH 19/22] libiscsi: use blk/scsi-ml mq cmd pre-allocator Mike Christie
2020-12-17 6:42 ` [PATCH 20/22] libiscsi: rm iscsi_put_task back_lock requirement Mike Christie
2020-12-17 6:42 ` [PATCH 21/22] libiscsi: drop back_lock from xmit path Mike Christie
2020-12-17 6:42 ` [PATCH 22/22] libiscsi: fix conn_send_pdu API Mike Christie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1608187332-4434-9-git-send-email-michael.christie@oracle.com \
--to=michael.christie@oracle.com \
--cc=GR-QLogic-Storage-Upstream@marvell.com \
--cc=cleech@redhat.com \
--cc=jejb@linux.ibm.com \
--cc=lduncan@suse.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mrangankar@marvell.com \
--cc=njavali@marvell.com \
--cc=varun@chelsio.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).