Commit d3fa3548 authored by Cristina Moraru's avatar Cristina Moraru
Browse files

Fix bug in getLimitUDS



Add missing conversion from network byte order to host byte order
in function getLimitUDS
Signed-off-by: default avatarCristina Moraru <cristina-gabriela.moraru@cern.ch>
parent 51584efa
......@@ -1217,8 +1217,14 @@ namespace SCSI {
udsLimitsPage_t() {
zeroStruct(this);
}
unsigned int maxSupported;
unsigned int maxSize;
unsigned char maxSupported[2];
unsigned char maxSize[2];
};
class udsLimits {
public:
uint16_t maxSupported;
uint16_t maxSize;
};
/**
......
......@@ -223,7 +223,7 @@ private:
bool m_useRAO;
/** Drive-specific RAO parameters */
SCSI::Structures::RAO::udsLimitsPage_t m_raoLimits;
SCSI::Structures::RAO::udsLimits m_raoLimits;
/**
* The promise for reordering the read tasks according to RAO by the
......
......@@ -754,11 +754,12 @@ bool drive::DriveMHVTL::isEncryptionCapEnabled() {
return false;
}
SCSI::Structures::RAO::udsLimitsPage_t drive::DriveGeneric::getLimitUDS() {
SCSI::Structures::RAO::udsLimits drive::DriveGeneric::getLimitUDS() {
SCSI::Structures::LinuxSGIO_t sgh;
SCSI::Structures::RAO::recieveRAO_t cdb;
SCSI::Structures::senseData_t<127> senseBuff;
unsigned char dataBuff[sizeof(SCSI::Structures::RAO::udsLimitsPage_t)];
SCSI::Structures::RAO::udsLimitsPage_t limitsSCSI;
SCSI::Structures::RAO::udsLimits lims;
cdb.serviceAction = 0x1d;
cdb.udsLimits = 1;
......@@ -766,7 +767,7 @@ SCSI::Structures::RAO::udsLimitsPage_t drive::DriveGeneric::getLimitUDS() {
sgh.setCDB(&cdb);
sgh.setSenseBuffer(&senseBuff);
sgh.setDataBuffer(&dataBuff);
sgh.setDataBuffer(&limitsSCSI);
sgh.dxfer_direction = SG_DXFER_FROM_DEV;
/* Manage both system error and SCSI errors. */
......@@ -775,10 +776,10 @@ SCSI::Structures::RAO::udsLimitsPage_t drive::DriveGeneric::getLimitUDS() {
"Failed SG_IO ioctl in DriveGeneric::getLimitUDS");
SCSI::ExceptionLauncher(sgh, "SCSI error in DriveGeneric::getLimitUDS");
SCSI::Structures::RAO::udsLimitsPage_t & limits =
*(SCSI::Structures::RAO::udsLimitsPage_t *) dataBuff;
return limits;
lims.maxSupported = SCSI::Structures::toU16(limitsSCSI.maxSupported);
lims.maxSize = SCSI::Structures::toU16(limitsSCSI.maxSize);
return lims;
}
void drive::DriveGeneric::generateRAO(std::list<SCSI::Structures::RAO::blockLims> &files,
......
......@@ -454,9 +454,9 @@ namespace drive {
/**
* Query the drive for the maximum number and size of User Data Segments (UDS)
* @return udsLimitsPage_t class. A pair of the above mentioned parameters
* @return udsLimits class. A pair of the above mentioned parameters
*/
virtual SCSI::Structures::RAO::udsLimitsPage_t getLimitUDS();
virtual SCSI::Structures::RAO::udsLimits getLimitUDS();
/**
* Query the drive for the Recommended Access Order (RAO)
......
......@@ -232,7 +232,7 @@ namespace drive {
virtual lbpToUse getLbpToUse() = 0;
virtual bool hasTapeInPlace() = 0;
virtual SCSI::Structures::RAO::udsLimitsPage_t getLimitUDS() = 0;
virtual SCSI::Structures::RAO::udsLimits getLimitUDS() = 0;
virtual void queryRAO(std::list<SCSI::Structures::RAO::blockLims> &files, int maxSupported) = 0;
/**
......
......@@ -298,9 +298,9 @@ bool castor::tape::tapeserver::drive::FakeDrive::hasTapeInPlace() {
return true;
}
castor::tape::SCSI::Structures::RAO::udsLimitsPage_t
castor::tape::SCSI::Structures::RAO::udsLimits
castor::tape::tapeserver::drive::FakeDrive::getLimitUDS() {
castor::tape::SCSI::Structures::RAO::udsLimitsPage_t lims;
castor::tape::SCSI::Structures::RAO::udsLimits lims;
lims.maxSize = 30000;
lims.maxSupported = 30;
return lims;
......
......@@ -109,7 +109,7 @@ namespace drive {
virtual bool isTapeBlank();
virtual lbpToUse getLbpToUse();
virtual bool hasTapeInPlace();
virtual castor::tape::SCSI::Structures::RAO::udsLimitsPage_t getLimitUDS();
virtual castor::tape::SCSI::Structures::RAO::udsLimits getLimitUDS();
virtual void queryRAO(std::list<SCSI::Structures::RAO::blockLims> &files, int maxSupported);
};
......
......@@ -259,7 +259,7 @@ int main (int argc, char *argv[])
else {
throw -1;
}
castor::tape::SCSI::Structures::RAO::udsLimitsPage_t limits = drive->getLimitUDS();
castor::tape::SCSI::Structures::RAO::udsLimits limits = drive->getLimitUDS();
drive->queryRAO(files, limits.maxSupported);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment