16#include "XrdVersion.hh"
67bool Cache::cfg2bytes(
const std::string &str,
long long &store,
long long totalSpace,
const char *name)
const
70 snprintf(errStr, 1024,
"ConfigParameters() Error parsing parameter %s", name);
72 if (::isalpha(*(str.rbegin())))
83 double frac = strtod(str.c_str(), &eP);
84 if (errno || eP == str.c_str())
86 m_log.Emsg(errStr, str.c_str());
90 store =
static_cast<long long>(totalSpace * frac + 0.5);
93 if (store < 0 || store > totalSpace)
95 snprintf(errStr, 1024,
"ConfigParameters() Error: parameter %s should be between 0 and total available disk space (%lld) - it is %lld (given as %s)",
96 name, totalSpace, store, str.c_str());
97 m_log.Emsg(errStr,
"");
105 long long &val,
long long min,
long long max)
const
107 if (
XrdOuca2x::a2sz(m_log,
"Error parsing block-size", str, &val, min, max))
113 m_log.Emsg(from,
"blocksize must be a multiple of 4 kB. Rounded up.");
120 int &val,
int min,
int max)
const
122 if (
XrdOuca2x::a2i(m_log,
"Error parsing prefetch block count", str, &val, min, max))
149 const char *val, *val2;
150 struct cschkopts {
const char *opname;
int opval;} csopts[] =
157 int i, numopts =
sizeof(csopts)/
sizeof(
struct cschkopts);
160 if (! (val =
Config.GetWord()))
161 {m_log.Emsg(
"Config",
"cschk parameter not specified");
return false; }
165 if ((
isNo = strncmp(val,
"no", 2) == 0))
169 for (i = 0; i < numopts; i++)
171 if (!strcmp(val2, csopts[i].opname))
174 m_configuration.m_cs_Chk &= ~csopts[i].opval;
175 else if (csopts[i].opval)
176 m_configuration.m_cs_Chk |= csopts[i].opval;
178 m_configuration.m_cs_Chk = csopts[i].opval;
184 if (strcmp(val,
"uvkeep"))
186 m_log.Emsg(
"Config",
"invalid cschk option -", val);
189 if (!(val =
Config.GetWord()))
191 m_log.Emsg(
"Config",
"cschk uvkeep value not specified");
194 if (!strcmp(val,
"lru"))
195 m_configuration.m_cs_UVKeep = -1;
201 m_configuration.m_cs_UVKeep = uvkeep;
207 m_configuration.m_cs_ChkTLS = m_configuration.m_cs_Chk &
CSChk_TLS;
208 m_configuration.m_cs_Chk &= ~CSChk_TLS;
210 m_env->Put(
"psx.CSNet", m_configuration.is_cschk_net() ? (m_configuration.m_cs_ChkTLS ?
"2" :
"1") :
"0");
226bool Cache::xdlib(XrdOucStream &Config)
231 if (! (val =
Config.GetWord()) || ! val[0])
233 TRACE(Info,
" Cache::Config() decisionlib not specified; always caching files");
243 Config.GetRest(params, 4096);
247 XrdOucPinLoader* myLib =
new XrdOucPinLoader(&m_log, 0,
"decisionlib",
250 Decision *(*ep)(XrdSysError&);
251 ep = (Decision *(*)(XrdSysError&))myLib->
Resolve(
"XrdPfcGetDecision");
252 if (! ep) {myLib->
Unload(
true);
return false; }
254 Decision * d = ep(m_log);
257 TRACE(
Error,
"Config() decisionlib was not able to create a decision object");
263 m_decisionpoints.push_back(d);
277bool Cache::xplib(XrdOucStream &Config)
282 if (! (val =
Config.GetWord()) || ! val[0])
284 TRACE(Info,
" Cache::Config() purgelib not specified; will use LRU for purging files");
294 Config.GetRest(params, 4096);
298 XrdOucPinLoader* myLib =
new XrdOucPinLoader(&m_log, 0,
"purgelib",
301 PurgePin *(*ep)(XrdSysError&);
302 ep = (PurgePin *(*)(XrdSysError&))myLib->
Resolve(
"XrdPfcGetPurgePin");
303 if (! ep) {myLib->
Unload(
true);
return false; }
305 PurgePin * dp = ep(m_log);
308 TRACE(
Error,
"Config() purgelib was not able to create a Purge Plugin object?");
325bool Cache::xtrace(XrdOucStream &Config)
328 static struct traceopts {
const char *opname;
int opval; } tropts[] =
338 int numopts =
sizeof(tropts)/
sizeof(
struct traceopts);
340 if (! (val =
Config.GetWord()))
341 {m_log.Emsg(
"Config",
"trace option not specified");
return 1; }
343 for (
int i = 0; i < numopts; i++)
345 if (! strcmp(val, tropts[i].opname))
347 m_trace->What = tropts[i].opval;
351 m_log.Emsg(
"Config",
"invalid trace option -", val);
356bool Cache::test_oss_basics_and_features()
358 static const char *epfx =
"test_oss_basics_and_features()";
360 const auto &conf = m_configuration;
361 const char *user = conf.m_username.c_str();
364 auto check_space = [&](
const char *space,
bool &has_xattr)
366 std::string fname(
"__prerun_test_pfc_");
369 env.
Put(
"oss.cgroup", space);
371 int res = m_oss->Create(user, fname.c_str(), 0600, env,
XRDOSS_mkpath);
373 m_log.Emsg(epfx,
"Can not create a file on space", space);
376 XrdOssDF *oss_file = m_oss->newFile(user);
377 res = oss_file->
Open(fname.c_str(), O_RDWR, 0600, env);
379 m_log.Emsg(epfx,
"Can not open a file on space", space);
382 res = oss_file->
Write(fname.data(), 0, fname.length());
383 if (res != (
int) fname.length()) {
384 m_log.Emsg(epfx,
"Can not write into a file on space", space);
389 long long fsize = fname.length();
392 m_log.Emsg(epfx,
"Can not write xattr to a file on space", space);
400 m_oss->Lfn2Pfn(fname.c_str(), pfn, 4096);
403 if (res !=
sizeof(
long long) || fsize != (
long long) fname.length())
405 m_log.Emsg(epfx,
"Can not read xattr from a file on space", space);
410 res = m_oss->Unlink(fname.c_str());
412 m_log.Emsg(epfx,
"Can not unlink a file on space", space);
420 aOK &= check_space(conf.m_data_space.c_str(), m_dataXattr);
421 aOK &= check_space(conf.m_meta_space.c_str(), m_metaXattr);
435 const char *theINS = getenv(
"XRDINSTANCE");
436 m_isClient = (theINS != 0 && strncmp(
"*client ", theINS, 8) == 0);
442 XrdOucEnv *myEnv = env ? env : &emptyEnv;
446 if (! config_filename || ! *config_filename)
448 TRACE(
Error,
"Config() configuration file not specified.");
453 if ( (fd =
open(config_filename, O_RDONLY, 0)) < 0)
455 TRACE(
Error,
"Config() can't open configuration file " << config_filename);
460 static const char *cvec[] = {
"*** pfc plugin config:", 0 };
466 if (! ofsCfg)
return false;
475 m_configuration.m_bufferSize = 128 * 1024;
476 m_configuration.m_wqueue_blocks = 8;
477 m_configuration.m_wqueue_threads = 1;
481 if (m_configuration.is_cschk_net()) m_env->Put(
"psx.CSNet", m_configuration.m_cs_ChkTLS ?
"2" :
"1");
484 bool retval =
true, aOK =
true;
486 while ((var =
Config.GetMyFirstWord()))
488 if (! strcmp(var,
"pfc.osslib"))
492 else if (! strcmp(var,
"pfc.cschk"))
496 else if (! strcmp(var,
"pfc.decisionlib"))
500 else if (! strcmp(var,
"pfc.purgelib"))
504 else if (! strcmp(var,
"pfc.trace"))
508 else if (! strcmp(var,
"pfc.allow_xrdpfc_command"))
510 m_configuration.m_allow_xrdpfc_command =
true;
512 else if (! strncmp(var,
"pfc.", 4))
514 retval = ConfigParameters(std::string(var+4),
Config, tmpc);
527 auto orig_runmode = myEnv->
Get(
"oss.runmode");
528 myEnv->
Put(
"oss.runmode",
"pfc");
529 if (m_configuration.is_cschk_cache())
532 if (snprintf(csi_conf, 128,
"space=%s nofill", m_configuration.m_meta_space.c_str()) < 128)
536 TRACE(
Error,
"Config() buffer too small for libXrdOssCsi params.");
546 TRACE(
Error,
"Config() Unable to create an OSS object");
549 if (orig_runmode) myEnv->
Put(
"oss.runmode", orig_runmode);
550 else myEnv->
Put(
"oss.runmode",
"");
553 aOK &= test_oss_basics_and_features();
558 if (m_configuration.m_meta_space != m_configuration.m_data_space &&
559 m_oss->StatVS(&sP, m_configuration.m_meta_space.c_str(), 1) < 0)
561 m_log.Emsg(
"ConfigParameters()",
"error obtaining stat info for meta space ", m_configuration.m_meta_space.c_str());
564 if (m_configuration.m_meta_space != m_configuration.m_data_space && sP.
Total < 10ll << 20)
566 m_log.Emsg(
"ConfigParameters()",
"available data space is less than 10 MB (can be due to a mistake in oss.localroot directive) for space ",
567 m_configuration.m_meta_space.c_str());
570 if (m_oss->StatVS(&sP, m_configuration.m_data_space.c_str(), 1) < 0)
572 m_log.Emsg(
"ConfigParameters()",
"error obtaining stat info for data space ", m_configuration.m_data_space.c_str());
575 if (sP.
Total < 10ll << 20)
577 m_log.Emsg(
"ConfigParameters()",
"available data space is less than 10 MB (can be due to a mistake in oss.localroot directive) for space ",
578 m_configuration.m_data_space.c_str());
582 m_configuration.m_diskTotalSpace = sP.
Total;
584 if (cfg2bytes(tmpc.
m_diskUsageLWM, m_configuration.m_diskUsageLWM, sP.
Total,
"lowWatermark") &&
587 if (m_configuration.m_diskUsageLWM >= m_configuration.m_diskUsageHWM) {
588 m_log.Emsg(
"ConfigParameters()",
"pfc.diskusage should have lowWatermark < highWatermark.");
600 if (m_configuration.m_fileUsageBaseline >= m_configuration.m_fileUsageNominal ||
601 m_configuration.m_fileUsageBaseline >= m_configuration.m_fileUsageMax ||
602 m_configuration.m_fileUsageNominal >= m_configuration.m_fileUsageMax)
604 m_log.Emsg(
"ConfigParameters()",
"pfc.diskusage files should have baseline < nominal < max.");
609 if (aOK && m_configuration.m_fileUsageMax >= m_configuration.m_diskUsageLWM)
611 m_log.Emsg(
"ConfigParameters()",
"pfc.diskusage files values must be below lowWatermark");
625 &m_configuration.m_flushCnt,
626 100 * m_configuration.m_bufferSize , 100000 * m_configuration.m_bufferSize))
630 m_configuration.m_flushCnt /= m_configuration.m_bufferSize;
635 &m_configuration.m_flushCnt, 100, 100000))
647 m_configuration.m_write_through =
true;
651 m_log.Emsg(
"ConfigParameters()",
"Unknown value for pfc.writemode (valid values are `writethrough` or `off`): %s",
658 if (m_configuration.m_RamAbsAvailable == 0)
660 m_configuration.m_RamAbsAvailable = m_isClient ? 256ll * 1024 * 1024 : 1024ll * 1024 * 1024;
662 snprintf(buff,
sizeof(buff),
"RAM usage pfc.ram is not specified. Default value %s is used.", m_isClient ?
"256m" :
"1g");
663 m_log.Say(
"Config info: ", buff);
666 m_configuration.m_RamKeepStdBlocks = (m_configuration.m_RamAbsAvailable / m_configuration.m_bufferSize + 1) * 5 / 100;
669 char* cenv = getenv(
"XRDDEBUG");
670 if (cenv && ! strcmp(cenv,
"1") && m_trace->What < 4) m_trace->What = 4;
675 const char *csc[] = {
"off",
"cache nonet",
"nocache net notls",
679 "off",
"cache nonet",
"nocache net tls",
683 if (m_configuration.m_cs_UVKeep < 0)
686 sprintf(uvk,
"%lld", (
long long) m_configuration.m_cs_UVKeep);
687 float ram_gb = (m_configuration.m_RamAbsAvailable) /
float(1024*1024*1024);
689 char urlcgi_blks[64] =
"ignore", urlcgi_npref[32] =
"ignore";
691 snprintf(urlcgi_blks,
sizeof(urlcgi_blks),
"%lldk %lldk",
694 snprintf(urlcgi_npref,
sizeof(urlcgi_npref),
"%d %d",
699 loff = snprintf(buff,
sizeof(buff),
"Config effective %s pfc configuration:\n"
700 " pfc.cschk %s uvkeep %s\n"
701 " pfc.blocksize %lldk\n"
703 " pfc.urlcgi blocksize %s prefetch %s\n"
705 " pfc.writequeue %d %d\n"
706 " # Total available disk: %lld\n"
707 " pfc.diskusage %lld %lld files %lld %lld %lld purgeinterval %d purgecoldfiles %d\n"
708 " pfc.spaces %s %s\n"
711 " pfc.acchistorysize %d\n"
712 " pfc.onlyIfCachedMinBytes %lld\n"
713 " pfc.onlyIfCachedMinFrac %.2f\n",
715 csc[
int(m_configuration.m_cs_Chk)], uvk,
716 m_configuration.m_bufferSize >> 10,
717 m_configuration.m_prefetch_max_blocks,
718 urlcgi_blks, urlcgi_npref,
720 m_configuration.m_wqueue_blocks, m_configuration.m_wqueue_threads,
722 m_configuration.m_diskUsageLWM, m_configuration.m_diskUsageHWM,
723 m_configuration.m_fileUsageBaseline, m_configuration.m_fileUsageNominal, m_configuration.m_fileUsageMax,
724 m_configuration.m_purgeInterval, m_configuration.m_purgeColdFilesAge,
725 m_configuration.m_data_space.c_str(),
726 m_configuration.m_meta_space.c_str(),
728 m_configuration.m_flushCnt,
729 m_configuration.m_accHistorySize,
730 m_configuration.m_onlyIfCachedMinSize,
731 m_configuration.m_onlyIfCachedMinFrac);
733 if (m_configuration.is_dir_stat_reporting_on())
735 loff += snprintf(buff + loff,
sizeof(buff) - loff,
736 " pfc.dirstats interval %d maxdepth %d (internal: size_of_dirlist %d, size_of_globlist %d)\n",
737 m_configuration.m_dirStatsInterval, m_configuration.m_dirStatsStoreDepth,
738 (
int) m_configuration.m_dirStatsDirs.size(), (
int) m_configuration.m_dirStatsDirGlobs.size());
739 loff += snprintf(buff + loff,
sizeof(buff) - loff,
" dirlist:\n");
740 for (std::set<std::string>::iterator i = m_configuration.m_dirStatsDirs.begin(); i != m_configuration.m_dirStatsDirs.end(); ++i)
741 loff += snprintf(buff + loff,
sizeof(buff) - loff,
" %s\n", i->c_str());
742 loff += snprintf(buff + loff,
sizeof(buff) - loff,
" globlist:\n");
743 for (std::set<std::string>::iterator i = m_configuration.m_dirStatsDirGlobs.begin(); i != m_configuration.m_dirStatsDirGlobs.end(); ++i)
744 loff += snprintf(buff + loff,
sizeof(buff) - loff,
" %s/*\n", i->c_str());
747 if (m_configuration.m_hdfsmode)
749 loff += snprintf(buff + loff,
sizeof(buff) - loff,
" pfc.hdfsmode hdfsbsize %lld\n", m_configuration.m_hdfsbsize);
751 loff += snprintf(buff + loff,
sizeof(buff) - loff,
" pfc.writemode %s\n", m_configuration.m_write_through ?
"writethrough" :
"off");
753 if (m_configuration.m_username.empty())
757 m_configuration.m_username = unameBuff;
761 loff += snprintf(buff + loff,
sizeof(buff) - loff,
" pfc.user %s\n", m_configuration.m_username.c_str());
766 m_env->Put(
"XRDPFC.SEGSIZE", std::to_string(m_configuration.m_bufferSize).c_str());
775 m_log.Say(
" pfc g-stream has", m_gstream ?
"" :
" NOT",
" been configured via xrootd.monitor directive\n");
781 m_res_mon->init_before_main();
784 m_log.Say(
"=====> Proxy file cache configuration parsing ", aOK ?
"completed" :
"failed");
786 if (ofsCfg)
delete ofsCfg;
790#ifdef XRDPFC_CKSUM_TEST
792 int xxx = m_configuration.m_cs_Chk;
794 for (m_configuration.m_cs_Chk =
CSChk_None; m_configuration.m_cs_Chk <=
CSChk_Both; ++m_configuration.m_cs_Chk)
796 Info::TestCksumStuff();
799 m_configuration.m_cs_Chk = xxx;
810 struct ConfWordGetter
815 ConfWordGetter(
XrdOucStream& c) : m_config(c), m_last_word((char*)1) {}
817 const char* GetWord() {
if (HasLast()) m_last_word = m_config.
GetWord();
return HasLast() ? m_last_word :
""; }
818 bool HasLast() {
return (m_last_word != 0); }
821 ConfWordGetter cwg(config);
823 Configuration &CFG = m_configuration;
825 if ( part ==
"user" )
827 m_configuration.m_username = cwg.GetWord();
828 if ( ! cwg.HasLast())
830 m_log.Emsg(
"Config",
"Error: pfc.user requires a parameter.");
834 else if ( part ==
"diskusage" )
841 m_log.Emsg(
"Config",
"Error: pfc.diskusage parameter requires at least two arguments.");
846 while ((p = cwg.GetWord()) && cwg.HasLast())
848 if (strcmp(p,
"files") == 0)
854 if ( ! cwg.HasLast())
856 m_log.Emsg(
"Config",
"Error: pfc.diskusage files directive requires three arguments.");
860 else if (strcmp(p,
"sleep") == 0 || strcmp(p,
"purgeinterval") == 0)
862 if (strcmp(p,
"sleep") == 0) m_log.Emsg(
"Config",
"warning sleep directive is deprecated in pfc.diskusage. Please use purgeinterval instead.");
864 if (
XrdOuca2x::a2tm(m_log,
"Error getting purgeinterval", cwg.GetWord(), &m_configuration.m_purgeInterval, 60, 3600))
869 else if (strcmp(p,
"purgecoldfiles") == 0)
871 if (
XrdOuca2x::a2tm(m_log,
"Error getting purgecoldfiles age", cwg.GetWord(), &m_configuration.m_purgeColdFilesAge, 3600, 3600*24*360))
875 if (
XrdOuca2x::a2i(m_log,
"Error getting purgecoldfiles period", cwg.GetWord(), &m_configuration.m_purgeAgeBasedPeriod, 1, 1000))
882 m_log.Emsg(
"Config",
"Error: diskusage stanza contains unknown directive", p);
886 else if ( part ==
"acchistorysize" )
888 if (
XrdOuca2x::a2i(m_log,
"Error getting access-history-size", cwg.GetWord(), &m_configuration.m_accHistorySize, 20, 200))
893 else if ( part ==
"dirstats" )
896 while ((p = cwg.GetWord()) && cwg.HasLast())
898 if (strcmp(p,
"interval") == 0)
900 int validIntervals[] = {60, 120, 300, 600, 900, 1200, 1800, 3600};
901 int size =
sizeof(validIntervals) /
sizeof(
int);
903 if (
XrdOuca2x::a2tm(m_log,
"Error getting dirstsat interval", cwg.GetWord(),
904 &m_configuration.m_dirStatsInterval, validIntervals[0], validIntervals[size - 1]))
908 bool match =
false, round_down =
false;
909 for (
int i = 0; i < size; i++) {
910 if (validIntervals[i] == m_configuration.m_dirStatsInterval) {
914 if (i > 0 && m_configuration.m_dirStatsInterval < validIntervals[i]) {
915 m_configuration.m_dirStatsInterval = validIntervals[i - 1];
920 if ( ! match && ! round_down) {
921 m_log.Emsg(
"Config",
"Error: dirstat interval parsing failed.");
925 m_log.Emsg(
"Config",
"Info: dirstat interval was rounded down to the nearest valid value.");
929 else if (strcmp(p,
"maxdepth") == 0)
931 if (
XrdOuca2x::a2i(m_log,
"Error getting maxdepth value", cwg.GetWord(),
932 &m_configuration.m_dirStatsStoreDepth, 0, 16))
937 else if (strcmp(p,
"dir") == 0)
940 if (p && p[0] ==
'/')
944 char d[1024]; d[0] = 0;
952 if (*(pd - 1) ==
'/')
964 if (*pd ==
'/' && pd != d) *pd = 0;
967 if (ld >= 2 && d[ld-1] ==
'*' && d[ld-2] ==
'/')
971 m_configuration.m_dirStatsDirGlobs.insert(d);
972 printf(
"Glob %s -> %s -- depth = %d\n", p, d, depth);
976 m_configuration.m_dirStatsDirs.insert(d);
977 printf(
"Dir %s -> %s -- depth = %d\n", p, d, depth);
980 m_configuration.m_dirStatsStoreDepth = std::max(m_configuration.m_dirStatsStoreDepth, depth);
984 m_log.Emsg(
"Config",
"Error: dirstats dir parameter requires a directory argument starting with a '/'.");
990 m_log.Emsg(
"Config",
"Error: dirstats stanza contains unknown directive '", p,
"'");
995 else if ( part ==
"blocksize" )
1001 else if ( part ==
"prefetch" || part ==
"nramprefetch" )
1003 if (part ==
"nramprefetch")
1005 m_log.Emsg(
"Config",
"pfc.nramprefetch is deprecated, please use pfc.prefetch instead. Replacing the directive internally.");
1012 else if ( part ==
"urlcgi" )
1016 while ((p = cwg.GetWord()) && cwg.HasLast())
1018 if (strcmp(p,
"blocksize") == 0)
1020 std::string bmin = cwg.GetWord();
1021 if (bmin ==
"ignore")
1023 std::string bmax = cwg.GetWord();
1024 if ( ! cwg.HasLast()) {
1025 m_log.Emsg(
"Config",
"Error: pfc.urlcgi blocksize parameter requires two arguments.");
1035 m_log.Emsg(
"Config",
"Error: pfc.urlcgi blocksize second argument must be larger or equal to the first one.");
1040 else if (strcmp(p,
"prefetch") == 0)
1042 std::string bmin = cwg.GetWord();
1043 if (bmin ==
"ignore")
1045 std::string bmax = cwg.GetWord();
1046 if ( ! cwg.HasLast()) {
1047 m_log.Emsg(
"Config",
"Error: pfc.urlcgi blocksize parameter requires two arguments.");
1057 m_log.Emsg(
"Config",
"Error: pfc.urlcgi prefetch second argument must be larger or equal to the first one.");
1064 m_log.Emsg(
"Config",
"Error: urlcgi stanza contains unknown directive '", p,
"'");
1069 else if ( part ==
"nramread" )
1071 m_log.Emsg(
"Config",
"pfc.nramread is deprecated, please use pfc.ram instead. Ignoring this directive.");
1074 else if ( part ==
"ram" )
1076 long long minRAM = m_isClient ? 256 * 1024 * 1024 : 1024 * 1024 * 1024;
1077 long long maxRAM = 256 * minRAM;
1078 if (
XrdOuca2x::a2sz(m_log,
"get RAM available", cwg.GetWord(), &m_configuration.m_RamAbsAvailable, minRAM, maxRAM))
1083 else if ( part ==
"writequeue")
1085 if (
XrdOuca2x::a2i(m_log,
"Error getting pfc.writequeue num-blocks", cwg.GetWord(), &m_configuration.m_wqueue_blocks, 1, 1024))
1089 if (
XrdOuca2x::a2i(m_log,
"Error getting pfc.writequeue num-threads", cwg.GetWord(), &m_configuration.m_wqueue_threads, 1, 64))
1094 else if ( part ==
"spaces" )
1096 m_configuration.m_data_space = cwg.GetWord();
1097 m_configuration.m_meta_space = cwg.GetWord();
1098 if ( ! cwg.HasLast())
1100 m_log.Emsg(
"Config",
"spacenames requires two parameters: <data-space> <metadata-space>.");
1104 else if ( part ==
"hdfsmode" )
1106 m_log.Emsg(
"Config",
"pfc.hdfsmode is currently unsupported.");
1109 m_configuration.m_hdfsmode =
true;
1111 const char* params = cwg.GetWord();
1114 if (! strncmp(
"hdfsbsize", params, 9))
1116 long long minBlSize = 32 * 1024;
1117 long long maxBlSize = 128 * 1024 * 1024;
1118 if (
XrdOuca2x::a2sz(m_log,
"Error getting file fragment size", cwg.GetWord(), &m_configuration.m_hdfsbsize, minBlSize, maxBlSize))
1125 m_log.Emsg(
"Config",
"Error setting the fragment size parameter name");
1130 else if ( part ==
"writemode" )
1133 if ( ! cwg.HasLast())
1135 m_log.Emsg(
"Config",
"Error: pfc.writemode requires a parameter.");
1139 else if ( part ==
"flush" )
1142 if ( ! cwg.HasLast())
1144 m_log.Emsg(
"Config",
"Error: pfc.flush requires a parameter.");
1148 else if ( part ==
"onlyifcached" )
1151 while ((p = cwg.GetWord()) && cwg.HasLast())
1153 if (strcmp(p,
"minsize") == 0)
1155 std::string minBytes = cwg.GetWord();
1156 long long minBytesTop = 1024 * 1024 * 1024;
1157 if (::isalpha(*(minBytes.rbegin())))
1159 if (
XrdOuca2x::a2sz(m_log,
"Error in parsing minsize value for onlyifcached parameter", minBytes.c_str(), &m_configuration.m_onlyIfCachedMinSize, 0, minBytesTop))
1166 if (
XrdOuca2x::a2ll(m_log,
"Error in parsing numeric minsize value for onlyifcached parameter", minBytes.c_str(),&m_configuration.m_onlyIfCachedMinSize, 0, minBytesTop))
1172 if (strcmp(p,
"minfrac") == 0)
1174 std::string minFrac = cwg.GetWord();
1177 double frac = strtod(minFrac.c_str(), &eP);
1178 if (errno || eP == minFrac.c_str())
1180 m_log.Emsg(
"Config",
"Error setting fraction for only-if-cached directive");
1183 m_configuration.m_onlyIfCachedMinFrac = frac;
1187 m_log.Emsg(
"Config",
"Error: onlyifcached stanza contains unknown directive", p);
1193 m_log.Emsg(
"ConfigParameters() unmatched pfc parameter", part.c_str());
XrdVERSIONINFO(XrdOucGetCache, XrdPfc)
XrdSysXAttr * XrdSysXAttrActive
XrdOucCache * XrdOucGetCache(XrdSysLogger *logger, const char *config_filename, const char *parameters, XrdOucEnv *env)
int isNo(int dflt, const char *Msg1, const char *Msg2, const char *Msg3)
bool Plugin(XrdAccAuthorize *&piP)
Get Authorization plugin.
static XrdOfsConfigPI * New(const char *cfn, XrdOucStream *cfgP, XrdSysError *errP, XrdVersionInfo *verP=0, XrdSfsFileSystem *sfsP=0)
bool Load(int what, XrdOucEnv *envP=0)
bool Push(TheLib what, const char *plugP, const char *parmP=0)
virtual int Close(long long *retsz=0)=0
virtual int Open(const char *path, int Oflag, mode_t Mode, XrdOucEnv &env)
virtual ssize_t Write(const void *buffer, off_t offset, size_t size)
char * Get(const char *varname)
static int Export(const char *Var, const char *Val)
void Put(const char *varname, const char *value)
void * Resolve(const char *symbl, int mcnt=1)
void Unload(bool dodel=false)
char * GetWord(int lowcase=0)
static int UserName(uid_t uID, char *uName, int uNsz)
static int a2i(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
static int a2sz(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
static int a2ll(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
static int a2tm(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
bool blocksize_str2value(const char *from, const char *str, long long &val, long long min, long long max) const
bool Config(const char *config_filename, const char *parameters, XrdOucEnv *env)
Parse configuration file.
bool prefetch_str2value(const char *from, const char *str, int &val, int min, int max) const
virtual bool ConfigDecision(const char *params)
static size_t s_maxNumAccess
virtual bool ConfigPurgePin(const char *params)
virtual int Get(const char *Aname, void *Aval, int Avsz, const char *Path, int fd=-1)=0
virtual int Set(const char *Aname, const void *Aval, int Avsz, const char *Path, int fd=-1, int isNew=0)=0
const char * trace_what_strings[]
Contains parameters configurable from the xrootd config file.
long long m_hdfsbsize
used with m_hdfsmode, default 128MB
long long m_RamAbsAvailable
available from configuration
long long m_flushCnt
nuber of unsynced blcoks on disk before flush is called
long long m_cgi_max_bufferSize
max buffer size allowed in pfc.blocksize
int m_accHistorySize
max number of entries in access history part of cinfo file
int m_cgi_min_prefetch_max_blocks
min prefetch block count allowed in pfc.prefetch
bool m_cgi_prefetch_allowed
allow cgi setting of prefetch
int m_wqueue_threads
number of threads writing blocks to disk
bool m_write_through
flag indicating write-through mode is enabled
long long m_diskTotalSpace
total disk space on configured partition or oss space
long long m_fileUsageMax
cache purge - files usage maximum
long long m_fileUsageBaseline
cache purge - files usage baseline
int m_dirStatsStoreDepth
maximum depth for statistics write out
bool m_allow_xrdpfc_command
flag for enabling access to /xrdpfc-command/ functionality.
long long m_diskUsageHWM
cache purge - disk usage high water mark
static constexpr long long s_min_bufferSize
static constexpr long long s_max_bufferSize
int m_prefetch_max_blocks
default maximum number of blocks to prefetch per file
bool m_cs_ChkTLS
Allow TLS.
long long m_fileUsageNominal
cache purge - files usage nominal
int m_cs_Chk
Checksum check.
int m_purgeAgeBasedPeriod
peform cold file / uvkeep purge every this many purge cycles
bool m_hdfsmode
flag for enabling block-level operation
int m_purgeColdFilesAge
purge files older than this age
std::string m_data_space
oss space for data files
long long m_diskUsageLWM
cache purge - disk usage low water mark
int m_RamKeepStdBlocks
number of standard-sized blocks kept after release
long long m_bufferSize
cache block size, default 128 kB
long long m_cgi_min_bufferSize
min buffer size allowed in pfc.blocksize
int m_dirStatsInterval
time between resource monitor statistics dump in seconds
std::string m_meta_space
oss space for metadata files (cinfo)
int m_wqueue_blocks
maximum number of blocks written per write-queue loop
int m_cgi_max_prefetch_max_blocks
max prefetch block count allowed in pfc.prefetch
static constexpr int s_max_prefetch_max_blocks
bool m_cgi_blocksize_allowed
allow cgi setting of blocksize
double m_onlyIfCachedMinFrac
minimum fraction of downloaded file, used by only-if-cached CGI option
time_t m_cs_UVKeep
unverified checksum cache keep
int m_purgeInterval
sleep interval between cache purges
long long m_onlyIfCachedMinSize
minumum size of downloaded file, used by only-if-cached CGI option
std::string m_writemodeRaw
std::string m_diskUsageLWM
std::string m_diskUsageHWM
std::string m_fileUsageBaseline
std::string m_fileUsageNominal
std::string m_fileUsageMax