Commit 7163576b authored by Mihai Patrascoiu's avatar Mihai Patrascoiu

FUSEX: Replace only non-system extended attributes in FuseServer::HandleMD

parent f4607cde
Pipeline #746763 passed with stages
in 83 minutes and 18 seconds
......@@ -30,6 +30,8 @@
#include "mgm/Quota.hh"
#include "mgm/Recycle.hh"
#include "namespace/interface/IView.hh"
#include "namespace/interface/IFileMD.hh"
#include "namespace/interface/IContainerMD.hh"
#include "namespace/interface/ContainerIterators.hh"
#include "namespace/Prefetcher.hh"
#include <thread>
......@@ -3511,7 +3513,7 @@ FuseServer::HandleMD(const std::string& id,
mtime.tv_nsec = md.mtime_ns();
fmd->setCTime(ctime);
fmd->setMTime(mtime);
fmd->clearAttributes();
replaceNonSysAttributes(fmd, md);
struct timespec pt_mtime;
if (op != UPDATE) {
......@@ -3523,10 +3525,6 @@ FuseServer::HandleMD(const std::string& id,
pt_mtime.tv_sec = pt_mtime.tv_nsec = 0 ;
}
for (auto map = md.attr().begin(); map != md.attr().end(); ++map) {
fmd->setAttribute(map->first, map->second);
}
// store the birth time as an extended attribute
char btime[256];
snprintf(btime, sizeof(btime), "%lu.%lu", md.btime(), md.btime_ns());
......@@ -3657,7 +3655,7 @@ FuseServer::HandleMD(const std::string& id,
mtime.tv_nsec = md.mtime_ns();
fmd->setCTime(ctime);
fmd->setMTime(mtime);
fmd->clearAttributes();
replaceNonSysAttributes(fmd, md);
if (op == CREATE) {
// store the birth time as an extended attribute
......@@ -4064,4 +4062,29 @@ FuseServer::HandleMD(const std::string& id,
return 0;
}
//----------------------------------------------------------------------------
// Replaces the file's non-system attributes with client-supplied ones.
//----------------------------------------------------------------------------
void
FuseServer::replaceNonSysAttributes(const std::shared_ptr<eos::IFileMD>& fmd,
const eos::fusex::md& md) {
eos::IFileMD::XAttrMap xattrs = fmd->getAttributes();
// Remove all non-system attributes
for (const auto& attr : xattrs) {
if ((attr.first.substr(0, 3) != "sys") ||
(attr.first == "sys.eos.btime")) {
fmd->removeAttribute(attr.first);
}
}
// Register non-system client-supplied attributes
for (const auto& attr : md.attr()) {
if ((attr.first.substr(0, 3) != "sys") ||
(attr.first == "sys.eos.btime")) {
fmd->setAttribute(attr.first, attr.second);
}
}
}
EOSMGMNAMESPACE_END
......@@ -36,6 +36,7 @@
#include "common/Mapping.hh"
#include "common/Timing.hh"
#include "common/Logging.hh"
#include "namespace/interface/IFileMD.hh"
#include "XrdSys/XrdSysPthread.hh"
#include <google/protobuf/util/json_util.h>
......@@ -637,6 +638,15 @@ protected:
private:
std::atomic<bool> terminate_;
//----------------------------------------------------------------------------
//! Replaces the file's non-system attributes with client-supplied ones.
//!
//! @param fmd file metadata object
//! @param md client supplied metadata
//----------------------------------------------------------------------------
void replaceNonSysAttributes(const std::shared_ptr<eos::IFileMD>& fmd,
const eos::fusex::md& md);
};
......
Markdown is supported
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