Commit ee211b54 authored by Steven Murray's avatar Steven Murray
Browse files

Made 1st readBlock of Read/Write sessions "exact"

Both tapeFile::ReadSession and tapeFile::WriteSession start by
reading VOL1 by calling Drive::readBlock() with a block of 84
bytes even though Logical Block Protection (LBP) is turned off
at this early stage of a session.  With LBP turned off, a drive
will only return the exact record being read and wil not add 4
CRC bytes at the end.  This means the drive will always return
80 bytes.

Both tapeFile::ReadSession and tapeFile::WriteSessioas called
Drive::readBlock() with a block of 84 bytes in order to work
with an "in-house" version of mhvtl that tried to support LBP.
Unfortunately the behaviour of this special version of mhvtl
was incorrect because it would 84 bytes when LBP was disabled.

The "in-house" version of mhvtl trying to support LBP is no
longer used with CASTOR.  This commit therefore simplfies the
CASTOR code by replacing Drive::readBlock() with
Drive::readExactBlock and by removing the conditional logic
that dealt with the existance of an 84 byte VOL1 label in the
presence of the "in-house" version of mhvtl.
parent 29ca9f8d
......@@ -70,14 +70,12 @@ namespace castor {
throw ex;
}
// this readBlock only for mhvtl workaround
m_drive.rewind();
m_drive.disableLogicalBlockProtection();
VOL1withCrc vol1WithCrc;
const ssize_t res = m_drive.readBlock((void * )&vol1WithCrc,
sizeof(vol1WithCrc));
if (res >= (ssize_t)(sizeof(VOL1withCrc) - sizeof(VOL1))) {
switch(vol1WithCrc.getLBPMethod()) {
{
VOL1 vol1;
m_drive.readExactBlock((void * )&vol1, sizeof(vol1), "[ReadSession::ReadSession()] - Reading VOL1");
switch(vol1.getLBPMethod()) {
case SCSI::logicBlockProtectionMethod::CRC32C:
m_detectedLbp = true;
if (m_useLbp) {
......@@ -94,21 +92,22 @@ namespace castor {
m_detectedLbp = false;
break;
default:
throw cta::exception::Exception("In ReadSession::ReadSession(): "
"unknown LBP method");
throw cta::exception::Exception("In ReadSession::ReadSession(): unknown LBP method");
}
}
// from this point the right LBP mode should be set or not set
m_drive.rewind();
VOL1 vol1;
m_drive.readExactBlock((void * )&vol1, sizeof(vol1), "[ReadSession::ReadSession()] - Reading VOL1");
try {
vol1.verify();
} catch (std::exception & e) {
throw TapeFormatError(e.what());
{
VOL1 vol1;
m_drive.readExactBlock((void *) &vol1, sizeof(vol1), "[ReadSession::ReadSession()] - Reading VOL1");
try {
vol1.verify();
} catch (std::exception &e) {
throw TapeFormatError(e.what());
}
HeaderChecker::checkVOL1(vol1, volInfo.vid); //after which we are at the end of VOL1 header (i.e. beginning of HDR1 of the first file) on success, or at BOT in case of exception
}
HeaderChecker::checkVOL1(vol1, volInfo.vid); //after which we are at the end of VOL1 header (i.e. beginning of HDR1 of the first file) on success, or at BOT in case of exception
}
void HeaderChecker::checkVOL1(const VOL1 &vol1, const std::string &volId) {
......@@ -403,14 +402,12 @@ namespace castor {
throw ex;
}
// this readBlock only for mhvtl workaround
m_drive.rewind();
m_drive.disableLogicalBlockProtection();
VOL1withCrc vol1WithCrc;
const ssize_t res = m_drive.readBlock((void * )&vol1WithCrc,
sizeof(vol1WithCrc));
if (res >= (ssize_t)(sizeof(VOL1withCrc) - sizeof(VOL1))) {
switch(vol1WithCrc.getLBPMethod()) {
{
VOL1 vol1;
m_drive.readExactBlock((void * )&vol1, sizeof(vol1), "[WriteSession::WriteSession()] - Reading VOL1");
switch(vol1.getLBPMethod()) {
case SCSI::logicBlockProtectionMethod::CRC32C:
m_detectedLbp = true;
if (m_useLbp) {
......@@ -431,21 +428,22 @@ namespace castor {
m_detectedLbp = false;
break;
default:
throw cta::exception::Exception("In WriteSession::WriteSession(): "
"unknown LBP method");
throw cta::exception::Exception("In WriteSession::WriteSession(): unknown LBP method");
}
}
// from this point the right LBP mode should be set or not set
m_drive.rewind();
VOL1 vol1;
m_drive.readExactBlock((void * )&vol1, sizeof(vol1), "[WriteSession::WriteSession()] - Reading VOL1");
try {
vol1.verify();
} catch (std::exception & e) {
throw TapeFormatError(e.what());
}
HeaderChecker::checkVOL1(vol1, m_vid); // now we know that we are going to write on the correct tape
{
VOL1 vol1;
m_drive.readExactBlock((void *) &vol1, sizeof(vol1), "[WriteSession::WriteSession()] - Reading VOL1");
try {
vol1.verify();
} catch (std::exception &e) {
throw TapeFormatError(e.what());
}
HeaderChecker::checkVOL1(vol1, m_vid); // now we know that we are going to write on the correct tape
}
//if the tape is not empty let's move to the last trailer
if(last_fSeq>0) {
uint32_t dst_filemark = last_fSeq*3-1; // 3 file marks per file but we want to read the last trailer (hence the -1)
......
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