Commit 7a924217 authored by Steven Murray's avatar Steven Murray
Browse files

setProcessCapabilities() now called at start of DataTransferSession::execute()

parent b4013289
......@@ -69,6 +69,27 @@ castor::tape::tapeserver::daemon::DataTransferSession::DataTransferSession(
{
}
//------------------------------------------------------------------------------
// setProcessCapabilities
//------------------------------------------------------------------------------
/**
* This function will try to set the cap_sys_rawio capability that is needed
* for by tape thread to access /dev/nst
*/
void castor::tape::tapeserver::daemon::DataTransferSession::setProcessCapabilities(
const std::string &capabilities){
cta::log::LogContext lc(m_log);
try {
m_capUtils.setProcText(capabilities);
cta::log::LogContext::ScopedParam sp(lc,
cta::log::Param("capabilities", m_capUtils.getProcText()));
lc.log(cta::log::INFO, "Set process capabilities for using tape");
} catch(const cta::exception::Exception &ne) {
lc.log(cta::log::ERR,
"Failed to set process capabilities for using the tape ");
}
}
//------------------------------------------------------------------------------
//DataTransferSession::execute
//------------------------------------------------------------------------------
......@@ -87,6 +108,8 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
// Create a sticky thread name, which will be overridden by the other threads
lc.pushOrReplace(cta::log::Param("thread", "MainThread"));
lc.pushOrReplace(cta::log::Param("unitName", m_driveConfig.unitName));
setProcessCapabilities("cap_sys_rawio+ep");
// 2a) Determine if we want to mount at all (for now)
// This variable will allow us to see if we switched from down to up and start a
......
......@@ -88,6 +88,13 @@ namespace daemon {
*/
EndOfSessionAction execute();
/**
* Sets the capabilities of the process and logs the result.
*
* @param capabilities The string representation of the capabilities.
*/
void setProcessCapabilities(const std::string &capabilities);
/** Temporary method used for debugging while building the session class */
std::string getVid() { return m_volInfo.vid; }
......
......@@ -205,12 +205,8 @@ const char *castor::tape::tapeserver::daemon::TapeReadSingleThread::
void castor::tape::tapeserver::daemon::TapeReadSingleThread::run() {
m_logContext.pushOrReplace(cta::log::Param("thread", "TapeRead"));
cta::utils::Timer timer, totalTimer;
std::string currentErrorToCount = "Error_setCapabilities";
std::string currentErrorToCount = "Error_tapeMountForRead";
try{
// Set capabilities allowing rawio (and hence arbitrary SCSI commands)
// through the st driver file descriptor.
setCapabilities();
// Report the parameters of the session to the main thread
typedef cta::log::Param Param;
m_watchdog.addParameter(Param("TPVID", m_volInfo.vid));
......@@ -227,7 +223,6 @@ void castor::tape::tapeserver::daemon::TapeReadSingleThread::run() {
// will also take care of the TapeServerReporter and of RecallTaskInjector
TapeCleaning tapeCleaner(*this, timer);
// Before anything, the tape should be mounted
currentErrorToCount = "Error_tapeMountForRead";
m_rrp.reportDriveStatus(cta::common::dataStructures::DriveStatus::Mounting);
mountTapeReadOnly();
currentErrorToCount = "Error_tapeLoad";
......
......@@ -95,22 +95,6 @@ protected:
/** Encryption helper object */
EncryptionControl m_encryptionControl;
/**
* This function will try to set the cap_sys_rawio capability that is needed
* for by tape thread to access /dev/nst
*/
void setCapabilities(){
try {
m_capUtils.setProcText("cap_sys_rawio+ep");
cta::log::LogContext::ScopedParam sp(m_logContext,
cta::log::Param("capabilities", m_capUtils.getProcText()));
m_logContext.log(cta::log::INFO, "Set process capabilities for using tape");
} catch(const cta::exception::Exception &ne) {
m_logContext.log(cta::log::ERR,
"Failed to set process capabilities for using the tape ");
}
}
/**
* Try to mount the tape for read-only access, get an exception if it fails
*/
......
......@@ -272,13 +272,9 @@ void castor::tape::tapeserver::daemon::TapeWriteSingleThread::run() {
// process we're in, and to count the error if it occurs.
// We will not record errors for an empty string. This will allow us to
// prevent counting where error happened upstream.
std::string currentErrorToCount = "Error_setCapabilities";
std::string currentErrorToCount = "Error_tapeMountForWrite";
try
{
// Set capabilities allowing rawio (and hence arbitrary SCSI commands)
// through the st driver file descriptor.
setCapabilities();
// Report the parameters of the session to the main thread
typedef cta::log::Param Param;
m_watchdog.addParameter(Param("TPVID", m_volInfo.vid));
......@@ -298,7 +294,6 @@ void castor::tape::tapeserver::daemon::TapeWriteSingleThread::run() {
// will also take care of the TapeServerReporter
//
TapeCleaning cleaner(*this, timer);
currentErrorToCount = "Error_tapeMountForWrite";
m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Mounting, m_logContext);
// Before anything, the tape should be mounted
// This call does the logging of the mount
......
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