Commit fc0de7b6 authored by Victor Kotlyar's avatar Victor Kotlyar
Browse files

Ported commits from castor/master:

3a67b08bd5b0e0cf4ef03de8185630fb0bcc5e80
  CASTOR-5275 RFE: Log the tapeserverd tape-file descriptor if it
  becomes bad whilst waiting for a tape drive to become ready

  Fixed.

b5d562503b6f954cfc6be09ef742474c685e6d60
  CASTOR-5275 RFE: Log the tapeserverd tape-file descriptor if it becomes
  bad whilst waiting for a tape drive to become ready

  Differentiated the log messages, and added the file descriptor
  logging in  all instances of the Could not read drive status errors.
parent 56c4c332
......@@ -29,6 +29,8 @@
#include "common/CRC.hpp"
#include "common/exception/MemException.hpp"
#include <errno.h>
namespace castor {
namespace tape {
namespace tapeserver {
......@@ -2187,9 +2189,18 @@ void drive::DriveGeneric::waitUntilReady(const uint32_t timeoutSecond) {
struct mtget mtInfo;
/* Read drive status */
cta::exception::Errnum::throwOnMinusOne(
m_sysWrapper.ioctl(m_tapeFD, MTIOCGET, &mtInfo),
std::string("Could not read drive status: ") + m_SCSIInfo.nst_dev);
{
const int ioctl_rc = m_sysWrapper.ioctl(m_tapeFD, MTIOCGET, &mtInfo);
const int ioctl_errno = errno;
if(-1 == ioctl_rc) {
std::ostringstream errMsg;
errMsg << "Could not read drive status in waitUntilReady: " << m_SCSIInfo.nst_dev;
if(EBADF == ioctl_errno) {
errMsg << " tapeFD=" << m_tapeFD;
}
throw cta::exception::Errnum(ioctl_errno, errMsg.str());
}
}
if(GMT_ONLINE(mtInfo.mt_gstat)==0) {
cta::exception::TimeOut ex;
......
......@@ -213,47 +213,66 @@ namespace drive {
virtual void waitUntilReady(const uint32_t timeoutSecond);
virtual bool hasTapeInPlace() {
struct mtget mtInfo;
/* Read drive status */
cta::exception::Errnum::throwOnMinusOne(
m_sysWrapper.ioctl(m_tapeFD, MTIOCGET, &mtInfo),
std::string("Could not read drive status: ") + m_SCSIInfo.nst_dev);
const int ioctl_rc = m_sysWrapper.ioctl(m_tapeFD, MTIOCGET, &mtInfo);
const int ioctl_errno = errno;
if(-1 == ioctl_rc) {
std::ostringstream errMsg;
errMsg << "Could not read drive status in hasTapeInPlace: " << m_SCSIInfo.nst_dev;
if(EBADF == ioctl_errno) {
errMsg << " tapeFD=" << m_tapeFD;
}
throw cta::exception::Errnum(ioctl_errno, errMsg.str());
}
return GMT_DR_OPEN(mtInfo.mt_gstat) == 0;
}
virtual bool isWriteProtected() {
struct mtget mtInfo;
/* Read drive status */
cta::exception::Errnum::throwOnMinusOne(
m_sysWrapper.ioctl(m_tapeFD, MTIOCGET, &mtInfo),
std::string("Could not read drive status: ") + m_SCSIInfo.nst_dev);
const int ioctl_rc = m_sysWrapper.ioctl(m_tapeFD, MTIOCGET, &mtInfo);
const int ioctl_errno = errno;
if(-1 == ioctl_rc) {
std::ostringstream errMsg;
errMsg << "Could not read drive status in isWriteProtected: " << m_SCSIInfo.nst_dev;
if(EBADF == ioctl_errno) {
errMsg << " tapeFD=" << m_tapeFD;
}
throw cta::exception::Errnum(ioctl_errno, errMsg.str());
}
return GMT_WR_PROT(mtInfo.mt_gstat)!=0;
}
virtual bool isAtBOT() {
struct mtget mtInfo;
/* Read drive status */
cta::exception::Errnum::throwOnMinusOne(
m_sysWrapper.ioctl(m_tapeFD, MTIOCGET, &mtInfo),
std::string("Could not read drive status: ") + m_SCSIInfo.nst_dev);
const int ioctl_rc = m_sysWrapper.ioctl(m_tapeFD, MTIOCGET, &mtInfo);
const int ioctl_errno = errno;
if(-1 == ioctl_rc) {
std::ostringstream errMsg;
errMsg << "Could not read drive status in isAtBOT: " << m_SCSIInfo.nst_dev;
if(EBADF == ioctl_errno) {
errMsg << " tapeFD=" << m_tapeFD;
}
throw cta::exception::Errnum(ioctl_errno, errMsg.str());
}
return GMT_BOT(mtInfo.mt_gstat)!=0;
}
virtual bool isAtEOD() {
struct mtget mtInfo;
/* Read drive status */
cta::exception::Errnum::throwOnMinusOne(
m_sysWrapper.ioctl(m_tapeFD, MTIOCGET, &mtInfo),
std::string("Could not read drive status: ") + m_SCSIInfo.nst_dev);
const int ioctl_rc = m_sysWrapper.ioctl(m_tapeFD, MTIOCGET, &mtInfo);
const int ioctl_errno = errno;
if(-1 == ioctl_rc) {
std::ostringstream errMsg;
errMsg << "Could not read drive status in isAtEOD: " << m_SCSIInfo.nst_dev;
if(EBADF == ioctl_errno) {
errMsg << " tapeFD=" << m_tapeFD;
}
throw cta::exception::Errnum(ioctl_errno, errMsg.str());
}
return GMT_EOD(mtInfo.mt_gstat)!=0;
}
......
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