VirtualBox

Ignore:
Timestamp:
Aug 18, 2013 12:30:02 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
88090
Message:

Devices/Storage: Preparations for non 512 byte sector sizes. Add a new getter in the block and media interfaces and remove uses of 512 constants and use the reported sector size from the underlying medium

Location:
trunk/src/VBox/Devices/Storage/VSCSI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VSCSI/VSCSIInternal.h

    r44889 r47829  
    364364
    365365/**
     366 * Wrapper for the get medium sector size I/O callback.
     367 *
     368 * @returns VBox status code.
     369 * @param   pVScsiLun     The LUN.
     370 * @param   pcbSectorSize Where to store the sector size on success.
     371 */
     372DECLINLINE(int) vscsiLunMediumGetSectorSize(PVSCSILUNINT pVScsiLun, uint32_t *pcbSectorSize)
     373{
     374    return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunMediumGetSectorSize(pVScsiLun,
     375                                                                           pVScsiLun->pvVScsiLunUser,
     376                                                                           pcbSectorSize);
     377}
     378
     379/**
    366380 * Wrapper for the get medium lock/unlock I/O callback.
    367381 *
  • trunk/src/VBox/Devices/Storage/VSCSI/VSCSILunSbc.cpp

    r46598 r47829  
    3333
    3434/** Maximum of amount of LBAs to unmap with one command. */
    35 #define VSCSI_UNMAP_LBAS_MAX ((10*_1M) / 512)
     35#define VSCSI_UNMAP_LBAS_MAX(a_cbSector) ((10*_1M) / a_cbSector)
    3636
    3737/**
     
    4242    /** Core LUN structure */
    4343    VSCSILUNINT    Core;
     44    /** Sector size of the medium. */
     45    uint32_t       cbSector;
    4446    /** Size of the virtual disk. */
    4547    uint64_t       cSectors;
     
    5759    int cVpdPages = 0;
    5860
    59     rc = vscsiLunMediumGetSize(pVScsiLun, &cbDisk);
     61    rc = vscsiLunMediumGetSectorSize(pVScsiLun, &pVScsiLunSbc->cbSector);
    6062    if (RT_SUCCESS(rc))
    61         pVScsiLunSbc->cSectors = cbDisk / 512; /* Fixed sector size */
     63    {
     64        rc = vscsiLunMediumGetSize(pVScsiLun, &cbDisk);
     65        if (RT_SUCCESS(rc))
     66            pVScsiLunSbc->cSectors = cbDisk / pVScsiLunSbc->cbSector;
     67    }
    6268
    6369    if (RT_SUCCESS(rc))
     
    100106                pBlkPage->u32OptTrfLength              = 0;
    101107                pBlkPage->u32MaxPreXdTrfLength         = 0;
    102                 pBlkPage->u32MaxUnmapLbaCount          = RT_H2BE_U32(VSCSI_UNMAP_LBAS_MAX);
     108                pBlkPage->u32MaxUnmapLbaCount          = RT_H2BE_U32(VSCSI_UNMAP_LBAS_MAX(pVScsiLunSbc->cbSector));
    103109                pBlkPage->u32MaxUnmapBlkDescCount      = UINT32_C(0xffffffff);
    104110                pBlkPage->u32OptUnmapGranularity       = 0;
     
    246252            else
    247253                vscsiH2BEU32(aReply, pVScsiLunSbc->cSectors - 1);
    248             vscsiH2BEU32(&aReply[4], 512);
     254            vscsiH2BEU32(&aReply[4], pVScsiLunSbc->cbSector);
    249255            RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, aReply, sizeof(aReply));
    250256            rcReq = vscsiLunReqSenseOkSet(pVScsiLun, pVScsiReq);
Note: See TracChangeset for help on using the changeset viewer.

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