diff options
Diffstat (limited to 'src/VBox/Storage/ISCSI.cpp')
-rw-r--r-- | src/VBox/Storage/ISCSI.cpp | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/src/VBox/Storage/ISCSI.cpp b/src/VBox/Storage/ISCSI.cpp index a89cb1df8..172c4f379 100644 --- a/src/VBox/Storage/ISCSI.cpp +++ b/src/VBox/Storage/ISCSI.cpp @@ -1,10 +1,10 @@ -/* $Id: ISCSI.cpp $ */ +/* $Id: ISCSI.cpp 37688 2011-06-29 15:26:05Z vboxsync $ */ /** @file * iSCSI initiator driver, VD backend. */ /* - * Copyright (C) 2006-2010 Oracle Corporation + * Copyright (C) 2006-2011 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -584,7 +584,7 @@ typedef struct ISCSIIMAGE /** Pointer to the target hostname. */ char *pszHostname; - /** Pointer to the target hostname. */ + /** Port to use on the target host. */ uint32_t uPort; /** Socket handle of the TCP connection. */ VDSOCKET Socket; @@ -910,10 +910,28 @@ static int iscsiTransportConnect(PISCSIIMAGE pImage) if (!pImage->pszInitiatorName) return VERR_NO_MEMORY; } + LogRel(("iSCSI: connect from initiator %s with source port %u\n", pImage->pszInitiatorName, pImage->ISID & 65535)); return VINF_SUCCESS; } +static int iscsiTransportClose(PISCSIIMAGE pImage) +{ + int rc; + + LogFlowFunc(("(%s:%d)\n", pImage->pszHostname, pImage->uPort)); + if (iscsiIsClientConnected(pImage)) + { + LogRel(("iSCSI: disconnect from initiator %s with source port %u\n", pImage->pszInitiatorName, pImage->ISID & 65535)); + rc = pImage->pInterfaceNetCallbacks->pfnClientClose(pImage->Socket); + } + else + rc = VINF_SUCCESS; + LogFlowFunc(("returns %Rrc\n", rc)); + return rc; +} + + static int iscsiTransportRead(PISCSIIMAGE pImage, PISCSIRES paResponse, unsigned int cnResponse) { int rc = VINF_SUCCESS; @@ -957,7 +975,7 @@ static int iscsiTransportRead(PISCSIIMAGE pImage, PISCSIRES paResponse, unsigned if (cbActuallyRead == 0) { /* The other end has closed the connection. */ - pImage->pInterfaceNetCallbacks->pfnClientClose(pImage->Socket); + iscsiTransportClose(pImage); pImage->state = ISCSISTATE_FREE; rc = VERR_NET_CONNECTION_RESET; break; @@ -1115,10 +1133,7 @@ static int iscsiTransportOpen(PISCSIIMAGE pImage) uint16_t uPort; /* Clean up previous connection data. */ - if (iscsiIsClientConnected(pImage)) - { - pImage->pInterfaceNetCallbacks->pfnClientClose(pImage->Socket); - } + iscsiTransportClose(pImage); if (pImage->pszHostname) { RTMemFree(pImage->pszHostname); @@ -1211,22 +1226,6 @@ static int iscsiTransportOpen(PISCSIIMAGE pImage) } -static int iscsiTransportClose(PISCSIIMAGE pImage) -{ - int rc; - - LogFlowFunc(("(%s:%d)\n", pImage->pszHostname, pImage->uPort)); - if (iscsiIsClientConnected(pImage)) - { - rc = pImage->pInterfaceNetCallbacks->pfnClientClose(pImage->Socket); - } - else - rc = VINF_SUCCESS; - LogFlowFunc(("returns %Rrc\n", rc)); - return rc; -} - - /** * Attach to an iSCSI target. Performs all operations necessary to enter * Full Feature Phase. @@ -1977,6 +1976,7 @@ out_release: * about 30-40 seconds, or the guest will lose its patience. */ iscsiTransportClose(pImage); pImage->state = ISCSISTATE_FREE; + rc = VERR_BROKEN_PIPE; } RTSemMutexRelease(pImage->Mutex); @@ -2238,7 +2238,7 @@ static void iscsiPDUTxAdd(PISCSIIMAGE pImage, PISCSIPDUTX pIScsiPDUTx, bool fFro { if (!fFront) { - /* Link the PDU at the tail of the list. */ + /* Insert PDU at the tail of the list. */ if (!pImage->pIScsiPDUTxHead) pImage->pIScsiPDUTxHead = pIScsiPDUTx; else @@ -2247,7 +2247,7 @@ static void iscsiPDUTxAdd(PISCSIIMAGE pImage, PISCSIPDUTX pIScsiPDUTx, bool fFro } else { - /* Link PDU to at the front of the list. */ + /* Insert PDU at the beginning of the list. */ pIScsiPDUTx->pNext = pImage->pIScsiPDUTxHead; pImage->pIScsiPDUTxHead = pIScsiPDUTx; if (!pImage->pIScsiPDUTxTail) @@ -2503,8 +2503,13 @@ static int iscsiRecvPDUProcess(PISCSIIMAGE pImage, PISCSIRES paRes, uint32_t cnR pIScsiPDUTx->cbSgLeft = sizeof(pIScsiPDUTx->aBHS); RTSgBufInit(&pIScsiPDUTx->SgBuf, pIScsiPDUTx->aISCSIReq, cnISCSIReq); - /* Link the PDU to the list. */ - iscsiPDUTxAdd(pImage, pIScsiPDUTx, false /* fFront */); + /* + * Link the PDU to the list. + * Insert at the front of the list to send the response as soon as possible + * to avoid frequent reconnects for a slow connection when there are many PDUs + * waiting. + */ + iscsiPDUTxAdd(pImage, pIScsiPDUTx, true /* fFront */); /* Start transfer of a PDU if there is no one active at the moment. */ if (!pImage->pIScsiPDUTxCur) @@ -3239,6 +3244,9 @@ static void iscsiReattach(PISCSIIMAGE pImage) RTMemFree(pIScsiPDUTx); } + /* Clear the tail pointer (safety precaution). */ + pImage->pIScsiPDUTxTail = NULL; + /* Clear the current PDU too. */ if (pImage->pIScsiPDUTxCur) { @@ -5167,13 +5175,6 @@ static void iscsiDump(void *pBackendData) } } -/** @copydoc VBOXHDDBACKEND::pfnIsAsyncIOSupported */ -static bool iscsiIsAsyncIOSupported(void *pBackendData) -{ - PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData; - return pImage->fCmdQueuingSupported; -} - /** @copydoc VBOXHDDBACKEND::pfnAsyncRead */ static int iscsiAsyncRead(void *pBackendData, uint64_t uOffset, size_t cbToRead, PVDIOCTX pIoCtx, size_t *pcbActuallyRead) @@ -5620,8 +5621,6 @@ VBOXHDDBACKEND g_ISCSIBackend = NULL, /* pfnSetParentFilename */ NULL, - /* pfnIsAsyncIOSupported */ - iscsiIsAsyncIOSupported, /* pfnAsyncRead */ iscsiAsyncRead, /* pfnAsyncWrite */ |