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) {