VirtualBox

Changeset 30941 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jul 20, 2010 6:40:06 PM (14 years ago)
Author:
vboxsync
Message:

Storage/iSCSI: Handle target triggered disconnects properly, without losing requests sporadically. Additionally eliminate some annoying assertions and clean up logging.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/ISCSIHDDCore.cpp

    r30309 r30941  
    251251    ISCSISTATE_IN_LOGOUT
    252252} ISCSISTATE;
     253
     254/**
     255 * iSCSI PDU send flags (and maybe more in the future). */
     256typedef enum ISCSIPDUFLAGS
     257{
     258    /** No special flags */
     259    ISCSIPDU_DEFAULT = 0,
     260    /** Do not attempt to re-attach to the target if the connection is lost */
     261    ISCSIPDU_NO_REATTACH = RT_BIT(1)
     262} ISCSIPDUFLAGS;
    253263
    254264
     
    490500/* iSCSI low-level functions (only to be used from the iSCSI high-level functions). */
    491501static uint32_t iscsiNewITT(PISCSIIMAGE pImage);
    492 static int iscsiSendPDU(PISCSIIMAGE pImage, PISCSIREQ paReq, uint32_t cnReq);
     502static int iscsiSendPDU(PISCSIIMAGE pImage, PISCSIREQ paReq, uint32_t cnReq, uint32_t uFlags);
    493503static int iscsiRecvPDU(PISCSIIMAGE pImage, uint32_t itt, PISCSIRES paRes, uint32_t cnRes);
    494504static int drvISCSIValidatePDU(PISCSIRES paRes, uint32_t cnRes);
     
    626636                pImage->pInterfaceNetCallbacks->pfnClientClose(pImage->Socket);
    627637                pImage->Socket = NIL_RTSOCKET;
     638                pImage->state = ISCSISTATE_FREE;
    628639                rc = VERR_NET_CONNECTION_RESET;
    629640                break;
     
    711722    unsigned int i;
    712723
    713     LogFlow(("iscsiTransportWrite: cnRequest=%d (%s:%d)\n", cnRequest, pImage->pszHostname, pImage->uPort));
     724    LogFlowFunc(("cnRequest=%d (%s:%d)\n", cnRequest, pImage->pszHostname, pImage->uPort));
    714725    if (pImage->Socket == NIL_RTSOCKET)
    715726    {
     
    766777    }
    767778
    768     LogFlow(("iscsiTransportWrite: returns %Rrc\n", rc));
     779    LogFlowFunc(("returns %Rrc\n", rc));
    769780    return rc;
    770781}
     
    10851096        cnISCSIReq++;
    10861097
    1087         rc = iscsiSendPDU(pImage, aISCSIReq, cnISCSIReq);
     1098        rc = iscsiSendPDU(pImage, aISCSIReq, cnISCSIReq, ISCSIPDU_NO_REATTACH);
    10881099        if (RT_SUCCESS(rc))
    10891100        {
     
    13471358    ISCSIREQ aISCSIReq[4];
    13481359    uint32_t aReqBHS[12];
    1349     LogFlow(("iscsiDetach: entering\n"));
     1360    LogFlowFunc(("entering\n"));
    13501361
    13511362    RTSemMutexRequest(pImage->Mutex, RT_INDEFINITE_WAIT);
     
    13771388        cnISCSIReq++;
    13781389
    1379         rc = iscsiSendPDU(pImage, aISCSIReq, cnISCSIReq);
     1390        rc = iscsiSendPDU(pImage, aISCSIReq, cnISCSIReq, ISCSIPDU_NO_REATTACH);
    13801391        if (RT_SUCCESS(rc))
    13811392        {
     
    14151426    RTSemMutexRelease(pImage->Mutex);
    14161427
    1417     LogFlow(("iscsiDetach: leaving\n"));
     1428    LogFlowFunc(("leaving\n"));
    14181429    LogRel(("iSCSI: logout to target %s\n", pImage->pszTargetName));
    14191430    return VINF_SUCCESS;
     
    14471458    bool final = false;
    14481459
    1449     LogFlow(("iscsiCommand: entering, CmdSN=%d\n", pImage->CmdSN));
     1460    LogFlowFunc(("entering, CmdSN=%d\n", pImage->CmdSN));
    14501461
    14511462    Assert(pRequest->enmXfer != SCSIXFER_TO_FROM_TARGET);   /**< @todo not yet supported, would require AHS. */
     
    15041515    }
    15051516
    1506     rc = iscsiSendPDU(pImage, aISCSIReq, cnISCSIReq);
     1517    rc = iscsiSendPDU(pImage, aISCSIReq, cnISCSIReq, ISCSIPDU_DEFAULT);
    15071518    if (RT_FAILURE(rc))
    15081519        goto out_release;
     
    16471658
    16481659out:
    1649     LogFlow(("iscsiCommand: returns %Rrc\n", rc));
     1660    LogFlowFunc(("returns %Rrc\n", rc));
    16501661    return rc;
    16511662}
     
    16771688 * @param   paReq       Pointer to array of iSCSI request sections.
    16781689 * @param   cnReq       Number of valid iSCSI request sections in the array.
     1690 * @param   uFlags      Flags controlling the exact send semantics.
    16791691 */
    1680 static int iscsiSendPDU(PISCSIIMAGE pImage, PISCSIREQ paReq, uint32_t cnReq)
     1692static int iscsiSendPDU(PISCSIIMAGE pImage, PISCSIREQ paReq, uint32_t cnReq,
     1693                        uint32_t uFlags)
    16811694{
    16821695    int rc = VINF_SUCCESS;
     
    16841697     * needs cleaning up of timeout/disconnect handling a bit, as otherwise
    16851698     * too many incorrect errors are signalled. */
    1686     Assert(pImage->paCurrReq == NULL);
    16871699    Assert(cnReq >= 1);
    16881700    Assert(paReq[0].cbSeg >= ISCSI_BHS_SIZE);
     
    16931705        if (RT_SUCCESS(rc))
    16941706            break;
    1695         if (rc != VERR_BROKEN_PIPE && rc != VERR_NET_CONNECTION_REFUSED)
     1707        if (   (uFlags & ISCSIPDU_NO_REATTACH)
     1708            || (rc != VERR_BROKEN_PIPE && rc != VERR_NET_CONNECTION_REFUSED))
    16961709            break;
    16971710        /* No point in reestablishing the connection for a logout */
     
    17541767                if (pImage->paCurrReq != NULL)
    17551768                {
    1756                     rc = iscsiSendPDU(pImage, pImage->paCurrReq, pImage->cnCurrReq);
     1769                    rc = iscsiSendPDU(pImage, pImage->paCurrReq, pImage->cnCurrReq, ISCSIPDU_DEFAULT);
    17571770                    if (RT_FAILURE(rc))
    17581771                        break;
     
    18741887                cnISCSIReq++;
    18751888
    1876                 iscsiSendPDU(pImage, aISCSIReq, cnISCSIReq);
     1889                iscsiSendPDU(pImage, aISCSIReq, cnISCSIReq, ISCSIPDU_NO_REATTACH);
    18771890            }
    18781891        }
     
    19641977        default:
    19651978            /* Do some logging, ignore PDU. */
    1966             LogFlow(("drvISCSIValidatePDU: ignore unhandled PDU, first word %#08x\n", RT_N2H_U32(pcrgResBHS[0])));
     1979            LogFlowFunc(("ignore unhandled PDU, first word %#08x\n", RT_N2H_U32(pcrgResBHS[0])));
    19671980            return VERR_PARSE_ERROR;
    19681981    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette