From 703a5473f71e2b3131d971dae7383d8cb97e2db1 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Fri, 23 Aug 2019 15:26:29 +0900 Subject: [PATCH] iscsi: Restore the previous bug fix for LUN hot plug One recent commit destroyed the critical bug fix for LUN hot plug. Hence this patch restores the critical bug fix. Simple revert is not possible because connections are assigned to poll groups instead of cores now. But we can revert easily because earlier version of the recent patch did that. Fixes #925 The github issue was caused by commit 8cf1945432f383ce8906f000d3296d1584573234. The bug fix restored by this patch is commit 1f6a78620d1f4b7470ccf5ff378fd2eb6cf49c5f. The reference we can follow to create this patch is earlier version of commit fb641c4b542ec7616eeb6b88cce1e14069e66d62. Reported-by: yidong0635 Signed-off-by: Shuhei Matsumoto Signed-off-by: Ziye Yang Signed-off-by: Ben Walker Change-Id: Ie1ba14a59ce48149a8474cbffc56aa08adc1fc4d Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466108 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris --- lib/iscsi/conn.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index c097d8f8d..22cb6d6d8 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -601,14 +601,23 @@ iscsi_conn_close_luns(struct spdk_iscsi_conn *conn) } } +struct _iscsi_conn_remove_ctx { + struct spdk_iscsi_conn *conn; + struct spdk_scsi_lun *lun; +}; + static void -iscsi_conn_remove_lun(struct spdk_scsi_lun *lun, void *remove_ctx) +_iscsi_conn_remove_lun(void *_ctx) { - struct spdk_iscsi_conn *conn = remove_ctx; + struct _iscsi_conn_remove_ctx *ctx = _ctx; + struct spdk_iscsi_conn *conn = ctx->conn; + struct spdk_scsi_lun *lun = ctx->lun; 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; + free(ctx); + assert(spdk_io_channel_get_thread(spdk_io_channel_from_ctx(conn->pg)) == spdk_get_thread()); @@ -649,6 +658,25 @@ iscsi_conn_remove_lun(struct spdk_scsi_lun *lun, void *remove_ctx) 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 _iscsi_conn_remove_ctx *ctx; + + ctx = calloc(1, sizeof(*ctx)); + if (!ctx) { + SPDK_ERRLOG("Unable to remove lun from connection\n"); + return; + } + + ctx->conn = conn; + ctx->lun = lun; + + spdk_thread_send_msg(spdk_io_channel_get_thread(spdk_io_channel_from_ctx(conn->pg)), + _iscsi_conn_remove_lun, ctx); +} + static void iscsi_conn_open_luns(struct spdk_iscsi_conn *conn) {