Skip to content

Commit

Permalink
MGM: refactor conversion tag file creation
Browse files Browse the repository at this point in the history
  • Loading branch information
apeters1971 committed Jan 7, 2025
1 parent 882fde9 commit 3abcccd
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 37 deletions.
11 changes: 2 additions & 9 deletions mgm/LRU.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "mgm/Stat.hh"
#include "mgm/XrdMgmOfs.hh"
#include "mgm/convert/ConverterDriver.hh"
#include "mgm/convert/ConversionTag.hh"
#include "namespace/interface/IView.hh"
#include "namespace/interface/ContainerIterators.hh"
#include "namespace/Prefetcher.hh"
Expand Down Expand Up @@ -775,15 +776,7 @@ LRU::ConvertMatch(const char* dir,
space = cenv.Get("eos.space");
}

snprintf(conversiontagfile, sizeof(conversiontagfile) - 1,
"%s/%016llx:%s#%s%s",
gOFS->MgmProcConversionPath.c_str(), it->first, space.c_str(),
conversion.c_str(), plctplcy.c_str());
std::string conv_tag = conversiontagfile;
conv_tag.erase(0, gOFS->MgmProcConversionPath.length() + 1);
// For the new converted we need to tell it explicitly that we want the
// ctime to be updated since this doesn't happen by default
conv_tag += eos::mgm::ConversionInfo::UPDATE_CTIME;
std::string conv_tag = ConversionTag::Get(it->first, space.c_str(), conversion, plctplcy);

if (gOFS->mConverterDriver->ScheduleJob(fid, conv_tag)) {
eos_static_info("msg=\"LRU scheduled conversion job\" tag=\"%s\"",
Expand Down
64 changes: 64 additions & 0 deletions mgm/convert/ConversionTag.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//------------------------------------------------------------------------------
// File: ConversionInfo.hh
// Author: Andreas-Joachim Peters - CERN
//------------------------------------------------------------------------------

/************************************************************************
* EOS - the CERN Disk Storage System *
* Copyright (C) 2025 CERN/Switzerland *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
************************************************************************/

#pragma once
#include "mgm/Namespace.hh"
#include "mgm/XrdMgmOfs.hh"
#include "mgm/convert/ConverterDriver.hh"

#include <string>

EOSMGMNAMESPACE_BEGIN

class ConversionTag {
public:
static std::string
Get(unsigned long long fid, std::string space, unsigned int layoutid,
std::string plctplcy, bool ctime_update = true)
{
char conversion[1024];
snprintf(conversion,sizeof(conversion)-1,"%08lx", layoutid);
return Get(fid, space, conversion, plctplcy, ctime_update);
}

static std::string
Get(unsigned long long fid, std::string space, std::string conversion,
std::string plctplcy, bool ctime_update = true)
{
char conversiontagfile[4096];
if (plctplcy.length()) {
// requires a ~ separator
plctplcy.insert(0, "~");
}
snprintf(conversiontagfile, sizeof(conversiontagfile) - 1,
"%016llx:%s#%s%s", fid,
space.c_str(), conversion.c_str(), plctplcy.c_str());
std::string conv_tag = conversiontagfile;
if (ctime_update) {
conv_tag += eos::mgm::ConversionInfo::UPDATE_CTIME;
}
return conv_tag;
}
};

EOSMGMNAMESPACE_END
35 changes: 7 additions & 28 deletions mgm/proc/user/File.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "mgm/Policy.hh"
#include "mgm/Stat.hh"
#include "mgm/convert/ConverterDriver.hh"
#include "mgm/convert/ConversionTag.hh"
#include "mgm/XattrLock.hh"
#include "common/Utils.hh"
#include "common/Path.hh"
Expand Down Expand Up @@ -1137,7 +1138,7 @@ ProcCommand::File()
stdErr += spath.c_str();
retc = errno;
} else {
char conversiontagfile[1024];
std::string conversiontag;

if (option == "rewrite") {
if (layout.length() == 0) {
Expand Down Expand Up @@ -1177,14 +1178,8 @@ ProcCommand::File()
}

if (eos::common::StringConversion::IsHexNumber(layout.c_str(), "%08x")) {
// we hand over as an conversion layout ID
snprintf(conversiontagfile,
sizeof(conversiontagfile) - 1,
"%s/%016llx:%s#%s",
gOFS->MgmProcConversionPath.c_str(),
fileid,
space.c_str(),
layout.c_str());

conversiontag = ConversionTag::Get(fileid, space.c_str(), layout.c_str(), std::string(""), false);
stdOut += "info: conversion based on hexadecimal layout id\n";
} else {
unsigned long layout_type = 0;
Expand Down Expand Up @@ -1228,34 +1223,18 @@ ProcCommand::File()
eos::common::LayoutId::k4M,
eos::common::LayoutId::kCRC32C,
eos::common::LayoutId::GetRedundancyStripeNumber(layoutid));
snprintf(conversiontagfile,
sizeof(conversiontagfile) - 1,
"%s/%016llx:%s#%08lx%s",
gOFS->MgmProcConversionPath.c_str(),
fileid,
space.c_str(),
(unsigned long) layoutid,
plctplcy.c_str());
conversiontag = ConversionTag::Get(fileid, space.c_str(), layoutid, plctplcy.c_str(), false);

stdOut += "info: conversion based layout+stripe arguments\n";
} else {
// assume this is the name of an attribute
snprintf(conversiontagfile,
sizeof(conversiontagfile) - 1,
"%s/%016llx:%s#%s%s",
gOFS->MgmProcConversionPath.c_str(),
fileid,
space.c_str(),
layout.c_str(),
plctplcy.c_str());
conversiontag = ConversionTag::Get(fileid, space.c_str(), layout.c_str(), plctplcy.c_str(), false);
stdOut += "info: conversion based conversion attribute name\n";
}
}

eos::common::VirtualIdentity rootvid = eos::common::VirtualIdentity::Root();
// Push conversion job to QuarkDB
std::string conversiontag = conversiontagfile;
conversiontag.erase(0, gOFS->MgmProcConversionPath.length() + 1);

if (gOFS->mConverterDriver->ScheduleJob(fmd->getId(), conversiontag)) {
stdOut += "success: pushed conversion job '";
stdOut += conversiontag.c_str();
Expand Down

0 comments on commit 3abcccd

Please sign in to comment.