Commit 95fc2af2 authored by Eric Cano's avatar Eric Cano
Browse files

Ported: CASTOR-5430: Recalls should set the checksum as an extended file...

Ported: CASTOR-5430: Recalls should set the checksum as an extended file attribute for rados striper

    A new method setChecksum() has been added to the DiskWriteFile interface (and it is called in the DiskWriteTask).
    The implementation is actually empty except for RadosStriperWriteFile.
parent d569cd27
......@@ -115,6 +115,9 @@ bool DiskWriteTask::execute(RecallReportPacker& reporter,cta::log::LogContext&
//A close is done in WriteFile's destructor, but it may lead to some
//silent data loss
currentErrorToCount = "Error_diskCloseAfterWrite";
// Set the checksum on the server (actually needed only for Rados striper
// noop in other cases).
writeFile->setChecksum(checksum);
writeFile->close();
m_stats.closingTime +=localTime.secs(cta::utils::Timer::resetCounter);
m_stats.filesCount++;
......
......@@ -278,6 +278,10 @@ void LocalWriteFile::write(const void *data, const size_t size) {
::write(m_fd, (void *)data, size);
}
void LocalWriteFile::setChecksum(uint32_t checksum) {
// Noop: this is only implemented for rados striper
}
void LocalWriteFile::close() {
// Multiple close protection
if (m_closeTried) return;
......@@ -493,6 +497,10 @@ void XrootBaseWriteFile::write(const void *data, const size_t size) {
m_writePosition += size;
}
void XrootBaseWriteFile::setChecksum(uint32_t checksum) {
// Noop: this is only implemented for rados striper
}
void XrootBaseWriteFile::close() {
// Multiple close protection
if (m_closeTried) return;
......@@ -647,6 +655,29 @@ void RadosStriperWriteFile::write(const void *data, const size_t size) {
m_writePosition += size;
}
void RadosStriperWriteFile::setChecksum(uint32_t checksum) {
// Set the checksum type (hardcoded)
int rc;
std::string checksumType("ADLER32");
::ceph::bufferlist blType;
blType.append(checksumType.c_str(), checksumType.size());
rc = m_striper->setxattr(m_osd, "user.castor.checksum.type", blType);
if (rc) {
throw cta::exception::Errnum(-rc, "In RadosStriperWriteFile::setChecksum(): "
"failed to striper->setxattr(user.castor.checksum.type): ");
}
// Turn the numeric checksum into a string and set it as checksum value
std::stringstream checksumStr;
checksumStr << std::hex << std::nouppercase << checksum;
::ceph::bufferlist blChecksum;
blChecksum.append(checksumStr.str().c_str(), checksumStr.str().size());
rc = m_striper->setxattr(m_osd, "user.castor.checksum.value", blChecksum);
if (rc) {
throw cta::exception::Errnum(-rc, "In RadosStriperWriteFile::setChecksum(): "
"failed to striper->setxattr(user.castor.checksum.value): ");
}
}
void RadosStriperWriteFile::close() {
// Nothing to do as writes are synchronous
}
......
......@@ -124,6 +124,11 @@ namespace castor {
*/
virtual void write(const void *data, const size_t size) = 0;
/**
* Set the checksum as an extended attribute (only needed for Ceph storage).
*/
virtual void setChecksum(uint32_t checksum) = 0;
/**
* Closes the corresponding file descriptor, which may throw an exception.
*/
......
......@@ -55,6 +55,7 @@ namespace castor {
public:
LocalWriteFile(const std::string &path);
virtual void write(const void *data, const size_t size);
virtual void setChecksum(uint32_t checksum);
virtual void close();
virtual ~LocalWriteFile() throw();
private:
......@@ -110,6 +111,7 @@ namespace castor {
public:
XrootBaseWriteFile(uint16_t timeout): m_writePosition(0), m_timeout(timeout), m_closeTried(false) {}
virtual void write(const void *data, const size_t size);
virtual void setChecksum(uint32_t checksum);
virtual void close();
virtual ~XrootBaseWriteFile() throw();
protected:
......@@ -161,6 +163,7 @@ namespace castor {
public:
EosWriteFile(const std::string &eosUrl, uint16_t timeout = 0);
virtual void write(const void *data, const size_t size);
virtual void setChecksum(uint32_t checksum);
virtual void close();
virtual ~EosWriteFile() throw();
protected:
......@@ -199,6 +202,7 @@ namespace castor {
libradosstriper::RadosStriper * striper,
const std::string &osd);
virtual void write(const void *data, const size_t size);
virtual void setChecksum(uint32_t checksum);
virtual void close();
virtual ~RadosStriperWriteFile() throw();
private:
......
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