diff --git a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp index 0392653e670978365dfde5d5b285eb91c535f88e..a912740c7a971b8347722bdeead988766c2b03ec 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp @@ -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 diff --git a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.hpp b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.hpp index 0a3b99a1903b780ee5a2b54ba1cd96a109fc6b73..f8f4956472d58ac5b725ed323cc58391e063637a 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.hpp @@ -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; } diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp index 7365ca34f74afe2f2c8f94983d0fa95ad72747b1..7c5f91e6eb2aff8efb4683e183c8ab48651a8300 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp @@ -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"; diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeSingleThreadInterface.hpp b/tapeserver/castor/tape/tapeserver/daemon/TapeSingleThreadInterface.hpp index 276bcb21282969d1796467576f287dbd27e61754..7ccc635b1f64056447045d9f8c82a59e336a9ec3 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeSingleThreadInterface.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeSingleThreadInterface.hpp @@ -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 */ diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp index 00a949be0f4050db763c8ce452ca0d97659bd6e8..edffd1605f986f0bac6f1bf0a0a4fe7eb8681e25 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp @@ -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