Commit 56b606b9 authored by Steven Murray's avatar Steven Murray
Browse files

Merge branch 'rao_branch' into 'master'

Rao branch

See merge request !3
parents e6381e74 b53490fc
......@@ -740,10 +740,6 @@ namespace SCSI {
*/
const unsigned char controlDataProtectionModePageLengthAddition = 4;
class modeRAO {
public:
static const uint16_t DEFAULT_RRAO_ALLOCATION = 64000;
};
} // namespace SCSI
} // namespace tape
} // namespace castor
......@@ -85,7 +85,16 @@ namespace SCSI {
template <typename T>
void setDataBuffer(T * dataBuff) { dxferp = dataBuff; dxfer_len = sizeof (T); }
// If dataBuff is a pointer to a variable length array, sizeof will return
// the size of one element. This function allows to manually set the buffer size
template <typename T>
void setDataBuffer(T * dataBuff, unsigned int dataBuffSize)
{
dxferp = dataBuff;
dxfer_len = dataBuffSize;
}
sg_io_hdr_t * operator & () { return (sg_io_hdr_t *) this; }
};
......@@ -1217,8 +1226,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;
};
/**
......@@ -1252,9 +1267,9 @@ namespace SCSI {
};
class udsDescriptor {
class udsDescriptor_t {
public:
udsDescriptor() {
udsDescriptor_t() {
zeroStruct(this);
setU16(descriptorLength, 0x1e);
}
......@@ -1269,9 +1284,9 @@ namespace SCSI {
/**
* RAO list struct
*/
class raoList {
class raoList_t {
public:
raoList() {
raoList_t() {
zeroStruct(this);
}
unsigned char raoProcess :3;
......@@ -1284,7 +1299,7 @@ namespace SCSI {
unsigned char raoDescriptorListLength[4];
udsDescriptor udsDescriptors[2000];
udsDescriptor_t udsDescriptors[1];
};
......@@ -1297,8 +1312,8 @@ namespace SCSI {
zeroStruct(this);
}
unsigned char res[4];
unsigned char additionalData[4];
udsDescriptor userDataSegmentDescriptors[2000];
unsigned char udsListLength[4];
udsDescriptor_t udsDescriptors[1];
};
/**
......
......@@ -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,19 +754,20 @@ 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;
SCSI::Structures::setU32(cdb.allocationLength, SCSI::modeRAO::DEFAULT_RRAO_ALLOCATION);
SCSI::Structures::setU32(cdb.allocationLength, sizeof(SCSI::Structures::RAO::udsLimitsPage_t));
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,
......@@ -789,7 +790,7 @@ void drive::DriveGeneric::generateRAO(std::list<SCSI::Structures::RAO::blockLims
int udSize = std::min((int) files.size(), maxSupported);
std::unique_ptr<SCSI::Structures::RAO::udsDescriptor[]> ud (new SCSI::Structures::RAO::udsDescriptor[udSize]());
std::unique_ptr<SCSI::Structures::RAO::udsDescriptor_t[]> ud (new SCSI::Structures::RAO::udsDescriptor_t[udSize]());
auto it = files.begin();
for (int i = 0; i < udSize; ++i) {
......@@ -800,18 +801,20 @@ void drive::DriveGeneric::generateRAO(std::list<SCSI::Structures::RAO::blockLims
}
SCSI::Structures::RAO::generateRAOParams_t params;
int real_params_len = sizeof(params) - (2000 - udSize) *
sizeof(SCSI::Structures::RAO::udsDescriptor);
int real_params_len = sizeof(params) - (udSize - 1) *
sizeof(SCSI::Structures::RAO::udsDescriptor_t);
std::unique_ptr<unsigned char[]> dataBuff (new unsigned char[real_params_len]());
cdb.serviceAction = 0x1d;
SCSI::Structures::setU32(cdb.paramsListLength, real_params_len);
SCSI::Structures::setU32(params.additionalData, udSize * sizeof(*(ud.get())));
memcpy(&params.userDataSegmentDescriptors, ud.get(), udSize * sizeof(*(ud.get())));
SCSI::Structures::setU32(params.udsListLength, udSize * sizeof(SCSI::Structures::RAO::udsDescriptor_t));
memcpy(dataBuff.get(), &params, 8); // copy first 2 fields
memcpy(dataBuff.get() + 8, ud.get(), udSize * sizeof(SCSI::Structures::RAO::udsDescriptor_t));
sgh.setCDB(&cdb);
sgh.setSenseBuffer(&senseBuff);
sgh.setDataBuffer(&params);
sgh.setDataBuffer(dataBuff.get(), real_params_len);
sgh.dxfer_direction = SG_DXFER_TO_DEV;
/* Manage both system error and SCSI errors. */
......@@ -821,22 +824,26 @@ void drive::DriveGeneric::generateRAO(std::list<SCSI::Structures::RAO::blockLims
SCSI::ExceptionLauncher(sgh, "SCSI error in DriveGeneric::requestRAO");
}
void drive::DriveGeneric::receiveRAO(std::list<SCSI::Structures::RAO::blockLims> &files,
int offset, int allocationLength) {
void drive::DriveGeneric::receiveRAO(std::list<SCSI::Structures::RAO::blockLims> &files) {
SCSI::Structures::LinuxSGIO_t sgh;
SCSI::Structures::RAO::recieveRAO_t cdb;
SCSI::Structures::senseData_t<255> senseBuff;
unsigned char dataBuff[sizeof(SCSI::Structures::RAO::raoList)];
SCSI::Structures::RAO::raoList_t *params;
int udSize = files.size();
int real_params_len = sizeof(SCSI::Structures::RAO::raoList_t) + (udSize - 1) *
sizeof(SCSI::Structures::RAO::udsDescriptor_t);
std::unique_ptr<unsigned char[]> dataBuff (new unsigned char[real_params_len]());
memset(dataBuff.get(), 0, real_params_len);
cdb.udsLimits = 0;
cdb.serviceAction = 0x1d;
SCSI::Structures::setU32(cdb.allocationLength, allocationLength);
SCSI::Structures::setU32(cdb.raoListOffset, offset);
SCSI::Structures::setU32(cdb.allocationLength, real_params_len);
sgh.setCDB(&cdb);
sgh.setSenseBuffer(&senseBuff);
sgh.setDataBuffer(&dataBuff);
sgh.setDataBuffer(dataBuff.get(), real_params_len);
sgh.dxfer_direction = SG_DXFER_FROM_DEV;
/* Manage both system error and SCSI errors. */
......@@ -845,24 +852,27 @@ void drive::DriveGeneric::receiveRAO(std::list<SCSI::Structures::RAO::blockLims>
"Failed SG_IO ioctl in DriveGeneric::getRAO");
SCSI::ExceptionLauncher(sgh, "SCSI error in DriveGeneric::getRAO");
SCSI::Structures::RAO::raoList & params =
*(SCSI::Structures::RAO::raoList *) dataBuff;
params = (SCSI::Structures::RAO::raoList_t *) dataBuff.get();
uint32_t desc_list_len = SCSI::Structures::toU32(params.raoDescriptorListLength);
for (uint32_t i = 0;i < desc_list_len / sizeof(SCSI::Structures::RAO::udsDescriptor);++i) {
files.clear();
uint32_t desc_list_len = SCSI::Structures::toU32(params->raoDescriptorListLength);
int files_no = desc_list_len / sizeof(SCSI::Structures::RAO::udsDescriptor_t);
SCSI::Structures::RAO::udsDescriptor_t *ud = params->udsDescriptors;
while (files_no > 0) {
SCSI::Structures::RAO::blockLims bl;
strncpy((char*)bl.fseq, (char*)params.udsDescriptors[i].udsName, 10);
bl.begin = SCSI::Structures::toU64(params.udsDescriptors[i].beginLogicalObjID);
bl.end = SCSI::Structures::toU64(params.udsDescriptors[i].endLogicalObjID);
strncpy((char*)bl.fseq, (char*)ud->udsName, 10);
bl.begin = SCSI::Structures::toU64(ud->beginLogicalObjID);
bl.end = SCSI::Structures::toU64(ud->endLogicalObjID);
files.emplace_back(bl);
ud++;
files_no--;
}
}
void drive::DriveGeneric::queryRAO(std::list<SCSI::Structures::RAO::blockLims> &files,
int maxSupported) {
generateRAO(files, maxSupported);
files.clear();
receiveRAO(files, 0, SCSI::modeRAO::DEFAULT_RRAO_ALLOCATION);
receiveRAO(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)
......@@ -514,8 +514,7 @@ namespace drive {
* @param offset
* @param allocationLength
*/
virtual void receiveRAO(std::list<SCSI::Structures::RAO::blockLims> &files,
int offset, int allocationLength);
virtual void receiveRAO(std::list<SCSI::Structures::RAO::blockLims> &files);
};
class DriveT10000 : public DriveGeneric {
......
......@@ -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);
}
}
......
......@@ -1051,6 +1051,7 @@ int DriveHandler::runChild() {
dataTransferConfig.nbBufs = m_tapedConfig.bufferCount.value();
dataTransferConfig.nbDiskThreads = m_tapedConfig.nbDiskThreads.value();
dataTransferConfig.useLbp = true;
dataTransferConfig.useRAO = m_tapedConfig.useRAO.value() == "yes" ? true : false;
dataTransferConfig.xrootPrivateKey = "";
// Before launching, and if this is the first session since daemon start, we will
......
......@@ -51,6 +51,7 @@ TapedConfiguration TapedConfiguration::createFromCtaConf(
ret.mountCriteria.setFromConfigurationFile(cf, generalConfigPath);
// Disk file access parameters
ret.nbDiskThreads.setFromConfigurationFile(cf, generalConfigPath);
ret.useRAO.setFromConfigurationFile(cf, generalConfigPath);
// Watchdog: parameters for timeouts in various situations.
ret.wdIdleSessionTimer.setFromConfigurationFile(cf, generalConfigPath);
ret.wdMountMaxSecs.setFromConfigurationFile(cf, generalConfigPath);
......@@ -76,6 +77,7 @@ TapedConfiguration TapedConfiguration::createFromCtaConf(
ret.mountCriteria.log(log);
ret.nbDiskThreads.log(log);
ret.useRAO.log(log);
ret.wdIdleSessionTimer.log(log);
ret.wdMountMaxSecs.log(log);
......
......@@ -87,6 +87,12 @@ struct TapedConfiguration {
SourcedParameter<uint64_t> nbDiskThreads{
"taped", "NbDiskThreads", 10, "Compile time default"};
//----------------------------------------------------------------------------
// Recommended Access Order usage
//----------------------------------------------------------------------------
/// Usage of Recommended Access Order for file recall
SourcedParameter<std::string> useRAO{
"taped", "UseRAO", "no", "Compile time default"};
//----------------------------------------------------------------------------
// Watchdog: parameters for timeouts in various situations.
//----------------------------------------------------------------------------
/// Maximum time allowed to complete a single mount scheduling.
......
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