From 72f9d8fa821f07c3d67f2bff8aefbc679629055d Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sun, 2 Jan 2011 17:38:27 +1100 Subject: [PATCH] Add a new pdu flag : NO_CALLBACK This flag is used when we dont want the CANCEL callback to be invoked if the context is destroyed. Thsi will be used for the sequence where we send multiple PDUs to the target for one single scsi task, such as -> WRITE10 cdb -> DATAOUT -< RESPONSE Since if the context is destroyed when the command is in flight, we already get the CANCEL callback for the WRITE10 PDU, so we dont need to invoke it again for when we destroy the DATAOUT pdu, since they both refer to the same task. --- include/iscsi-private.h | 2 ++ lib/init.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/iscsi-private.h b/include/iscsi-private.h index a1a33b9..859391a 100644 --- a/include/iscsi-private.h +++ b/include/iscsi-private.h @@ -152,6 +152,8 @@ struct iscsi_pdu { /* There will not be a response to this pdu, so delete it once it is sent on the wire. Dont put it on the wait-queue */ #define ISCSI_PDU_DELETE_WHEN_SENT 0x00000001 +/* Dont call the CANCEL callback when the context is destroyed */ +#define ISCSI_PDU_NO_CALLBACK 0x00000002 uint32_t flags; uint32_t itt; diff --git a/lib/init.c b/lib/init.c index 4e8d681..e5eef93 100644 --- a/lib/init.c +++ b/lib/init.c @@ -138,14 +138,16 @@ iscsi_destroy_context(struct iscsi_context *iscsi) while ((pdu = iscsi->outqueue)) { SLIST_REMOVE(&iscsi->outqueue, pdu); - pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL, - pdu->private_data); + if ( !(pdu->flags & ISCSI_PDU_NO_CALLBACK)) { + pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL, + pdu->private_data); + } iscsi_free_pdu(iscsi, pdu); } while ((pdu = iscsi->waitpdu)) { SLIST_REMOVE(&iscsi->waitpdu, pdu); pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL, - pdu->private_data); + pdu->private_data); iscsi_free_pdu(iscsi, pdu); }