From 8cf1945432f383ce8906f000d3296d1584573234 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Tue, 30 Jul 2019 07:58:07 +0900 Subject: [PATCH] iscsi: Hot remove callback closes LUN directly without using event call This patch is in the patch series to migrate iSCSI connection management from core based to SPDK thread based. The callback to hot removal of LUN, iscsi_conn_remove_lun, is called on the same core when the corresponding LUN is opened. Additionally, all operations in iscsi_conn_remove_lun are completed synchronously. Hence inline _iscsi_conn_remove_lun into iscsi_conn_remove_lun. Add assert to check the function is called on the specified core. This change is helpful to achieve the goal of the patch series because spdk_event can have two parameters but spdk_msg can have only a single variable, and hence we cannot convert simply and have to introduce a context allocated dynamically otherwise. Signed-off-by: Shuhei Matsumoto Change-Id: Iaebf18265dfe839f7361b09539527a1806aed1c4 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463551 Tested-by: SPDK CI Jenkins Reviewed-by: Paul Luse Reviewed-by: Changpeng Liu Reviewed-by: Darek Stojaczyk Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Broadcom SPDK FC-NVMe CI --- lib/iscsi/conn.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index 48ec99c74..6a55b8ecc 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -603,14 +603,15 @@ iscsi_conn_close_luns(struct spdk_iscsi_conn *conn) } static void -_iscsi_conn_remove_lun(void *arg1, void *arg2) +iscsi_conn_remove_lun(struct spdk_scsi_lun *lun, void *remove_ctx) { - struct spdk_iscsi_conn *conn = arg1; - struct spdk_scsi_lun *lun = arg2; + struct spdk_iscsi_conn *conn = remove_ctx; int lun_id = spdk_scsi_lun_get_id(lun); struct spdk_iscsi_pdu *pdu, *tmp_pdu; struct spdk_iscsi_task *iscsi_task, *tmp_iscsi_task; + assert(conn->lcore == spdk_env_get_current_core()); + /* If a connection is already in stating status, just return */ if (conn->state >= ISCSI_CONN_STATE_EXITING) { return; @@ -648,17 +649,6 @@ _iscsi_conn_remove_lun(void *arg1, void *arg2) iscsi_conn_close_lun(conn, lun_id); } -static void -iscsi_conn_remove_lun(struct spdk_scsi_lun *lun, void *remove_ctx) -{ - struct spdk_iscsi_conn *conn = remove_ctx; - struct spdk_event *event; - - event = spdk_event_allocate(conn->lcore, _iscsi_conn_remove_lun, - conn, lun); - spdk_event_call(event); -} - static void iscsi_conn_open_luns(struct spdk_iscsi_conn *conn) {