16#include "XrdVersion.hh"
66bool Cache::cfg2bytes(
const std::string &str,
long long &store,
long long totalSpace,
const char *name)
const
69 snprintf(errStr, 1024,
"ConfigParameters() Error parsing parameter %s", name);
71 if (::isalpha(*(str.rbegin())))
82 double frac = strtod(str.c_str(), &eP);
83 if (errno || eP == str.c_str())
85 m_log.Emsg(errStr, str.c_str());
89 store =
static_cast<long long>(totalSpace * frac + 0.5);
92 if (store < 0 || store > totalSpace)
94 snprintf(errStr, 1024,
"ConfigParameters() Error: parameter %s should be between 0 and total available disk space (%lld) - it is %lld (given as %s)",
95 name, totalSpace, store, str.c_str());
96 m_log.Emsg(errStr,
"");
104 long long &val,
long long min,
long long max)
const
106 if (
XrdOuca2x::a2sz(m_log,
"Error parsing block-size", str, &val, min, max))
112 m_log.Emsg(from,
"blocksize must be a multiple of 4 kB. Rounded up.");
119 int &val,
int min,
int max)
const
121 if (
XrdOuca2x::a2i(m_log,
"Error parsing prefetch block count", str, &val, min, max))
148 const char *val, *val2;
149 struct cschkopts {
const char *opname;
int opval;} csopts[] =
156 int i, numopts =
sizeof(csopts)/
sizeof(
struct cschkopts);
159 if (! (val =
Config.GetWord()))
160 {m_log.Emsg(
"Config",
"cschk parameter not specified");
return false; }
164 if ((
isNo = strncmp(val,
"no", 2) == 0))
168 for (i = 0; i < numopts; i++)
170 if (!strcmp(val2, csopts[i].opname))
173 m_configuration.m_cs_Chk &= ~csopts[i].opval;
174 else if (csopts[i].opval)
175 m_configuration.m_cs_Chk |= csopts[i].opval;
177 m_configuration.m_cs_Chk = csopts[i].opval;
183 if (strcmp(val,
"uvkeep"))
185 m_log.Emsg(
"Config",
"invalid cschk option -", val);
188 if (!(val =
Config.GetWord()))
190 m_log.Emsg(
"Config",
"cschk uvkeep value not specified");
193 if (!strcmp(val,
"lru"))
194 m_configuration.m_cs_UVKeep = -1;
200 m_configuration.m_cs_UVKeep = uvkeep;
206 m_configuration.m_cs_ChkTLS = m_configuration.m_cs_Chk &
CSChk_TLS;
207 m_configuration.m_cs_Chk &= ~CSChk_TLS;
209 m_env->Put(
"psx.CSNet", m_configuration.is_cschk_net() ? (m_configuration.m_cs_ChkTLS ?
"2" :
"1") :
"0");
225bool Cache::xdlib(XrdOucStream &Config)
230 if (! (val =
Config.GetWord()) || ! val[0])
232 TRACE(Info,
" Cache::Config() decisionlib not specified; always caching files");
242 Config.GetRest(params, 4096);
246 XrdOucPinLoader* myLib =
new XrdOucPinLoader(&m_log, 0,
"decisionlib",
249 Decision *(*ep)(XrdSysError&);
250 ep = (Decision *(*)(XrdSysError&))myLib->
Resolve(
"XrdPfcGetDecision");
251 if (! ep) {myLib->
Unload(
true);
return false; }
253 Decision * d = ep(m_log);
256 TRACE(
Error,
"Config() decisionlib was not able to create a decision object");
262 m_decisionpoints.push_back(d);
276bool Cache::xplib(XrdOucStream &Config)
281 if (! (val =
Config.GetWord()) || ! val[0])
283 TRACE(Info,
" Cache::Config() purgelib not specified; will use LRU for purging files");
293 Config.GetRest(params, 4096);
297 XrdOucPinLoader* myLib =
new XrdOucPinLoader(&m_log, 0,
"purgelib",
300 PurgePin *(*ep)(XrdSysError&);
301 ep = (PurgePin *(*)(XrdSysError&))myLib->
Resolve(
"XrdPfcGetPurgePin");
302 if (! ep) {myLib->
Unload(
true);
return false; }
304 PurgePin * dp = ep(m_log);
307 TRACE(
Error,
"Config() purgelib was not able to create a Purge Plugin object?");
324bool Cache::xtrace(XrdOucStream &Config)
327 static struct traceopts {
const char *opname;
int opval; } tropts[] =
337 int numopts =
sizeof(tropts)/
sizeof(
struct traceopts);
339 if (! (val =
Config.GetWord()))
340 {m_log.Emsg(
"Config",
"trace option not specified");
return 1; }
342 for (
int i = 0; i < numopts; i++)
344 if (! strcmp(val, tropts[i].opname))
346 m_trace->What = tropts[i].opval;
350 m_log.Emsg(
"Config",
"invalid trace option -", val);
355bool Cache::test_oss_basics_and_features()
357 static const char *epfx =
"test_oss_basics_and_features()";
359 const auto &conf = m_configuration;
360 const char *user = conf.m_username.c_str();
363 auto check_space = [&](
const char *space,
bool &has_xattr)
365 std::string fname(
"__prerun_test_pfc_");
368 env.
Put(
"oss.cgroup", space);
370 int res = m_oss->Create(user, fname.c_str(), 0600, env,
XRDOSS_mkpath);
372 m_log.Emsg(epfx,
"Can not create a file on space", space);
375 XrdOssDF *oss_file = m_oss->newFile(user);
376 res = oss_file->
Open(fname.c_str(), O_RDWR, 0600, env);
378 m_log.Emsg(epfx,
"Can not open a file on space", space);
381 res = oss_file->
Write(fname.data(), 0, fname.length());
382 if (res != (
int) fname.length()) {
383 m_log.Emsg(epfx,
"Can not write into a file on space", space);
388 long long fsize = fname.length();
391 m_log.Emsg(epfx,
"Can not write xattr to a file on space", space);
399 m_oss->Lfn2Pfn(fname.c_str(), pfn, 4096);
402 if (res !=
sizeof(
long long) || fsize != (
long long) fname.length())
404 m_log.Emsg(epfx,
"Can not read xattr from a file on space", space);
409 res = m_oss->Unlink(fname.c_str());
411 m_log.Emsg(epfx,
"Can not unlink a file on space", space);
419 aOK &= check_space(conf.m_data_space.c_str(), m_dataXattr);
420 aOK &= check_space(conf.m_meta_space.c_str(), m_metaXattr);
434 const char *theINS = getenv(
"XRDINSTANCE");
435 m_isClient = (theINS != 0 && strncmp(
"*client ", theINS, 8) == 0);
441 XrdOucEnv *myEnv = env ? env : &emptyEnv;
445 if (! config_filename || ! *config_filename)
447 TRACE(
Error,
"Config() configuration file not specified.");
452 if ( (fd =
open(config_filename, O_RDONLY, 0)) < 0)
454 TRACE(
Error,
"Config() can't open configuration file " << config_filename);
459 static const char *cvec[] = {
"*** pfc plugin config:", 0 };
465 if (! ofsCfg)
return false;
474 m_configuration.m_bufferSize = 128 * 1024;
475 m_configuration.m_wqueue_blocks = 8;
476 m_configuration.m_wqueue_threads = 1;
480 if (m_configuration.is_cschk_net()) m_env->Put(
"psx.CSNet", m_configuration.m_cs_ChkTLS ?
"2" :
"1");
483 bool retval =
true, aOK =
true;
485 while ((var =
Config.GetMyFirstWord()))
487 if (! strcmp(var,
"pfc.osslib"))
491 else if (! strcmp(var,
"pfc.cschk"))
495 else if (! strcmp(var,
"pfc.decisionlib"))
499 else if (! strcmp(var,
"pfc.purgelib"))
503 else if (! strcmp(var,
"pfc.trace"))
507 else if (! strcmp(var,
"pfc.allow_xrdpfc_command"))
509 m_configuration.m_allow_xrdpfc_command =
true;
511 else if (! strncmp(var,
"pfc.", 4))
513 retval = ConfigParameters(std::string(var+4),
Config, tmpc);
526 auto orig_runmode = myEnv->
Get(
"oss.runmode");
527 myEnv->
Put(
"oss.runmode",
"pfc");
528 if (m_configuration.is_cschk_cache())
531 if (snprintf(csi_conf, 128,
"space=%s nofill", m_configuration.m_meta_space.c_str()) < 128)
535 TRACE(
Error,
"Config() buffer too small for libXrdOssCsi params.");
545 TRACE(
Error,
"Config() Unable to create an OSS object");
548 if (orig_runmode) myEnv->
Put(
"oss.runmode", orig_runmode);
549 else myEnv->
Put(
"oss.runmode",
"");
552 aOK &= test_oss_basics_and_features();
557 if (m_configuration.m_meta_space != m_configuration.m_data_space &&
558 m_oss->StatVS(&sP, m_configuration.m_meta_space.c_str(), 1) < 0)
560 m_log.Emsg(
"ConfigParameters()",
"error obtaining stat info for meta space ", m_configuration.m_meta_space.c_str());
563 if (m_configuration.m_meta_space != m_configuration.m_data_space && sP.
Total < 10ll << 20)
565 m_log.Emsg(
"ConfigParameters()",
"available data space is less than 10 MB (can be due to a mistake in oss.localroot directive) for space ",
566 m_configuration.m_meta_space.c_str());
569 if (m_oss->StatVS(&sP, m_configuration.m_data_space.c_str(), 1) < 0)
571 m_log.Emsg(
"ConfigParameters()",
"error obtaining stat info for data space ", m_configuration.m_data_space.c_str());
574 if (sP.
Total < 10ll << 20)
576 m_log.Emsg(
"ConfigParameters()",
"available data space is less than 10 MB (can be due to a mistake in oss.localroot directive) for space ",
577 m_configuration.m_data_space.c_str());
581 m_configuration.m_diskTotalSpace = sP.
Total;
583 if (cfg2bytes(tmpc.
m_diskUsageLWM, m_configuration.m_diskUsageLWM, sP.
Total,
"lowWatermark") &&
586 if (m_configuration.m_diskUsageLWM >= m_configuration.m_diskUsageHWM) {
587 m_log.Emsg(
"ConfigParameters()",
"pfc.diskusage should have lowWatermark < highWatermark.");
599 if (m_configuration.m_fileUsageBaseline >= m_configuration.m_fileUsageNominal ||
600 m_configuration.m_fileUsageBaseline >= m_configuration.m_fileUsageMax ||
601 m_configuration.m_fileUsageNominal >= m_configuration.m_fileUsageMax)
603 m_log.Emsg(
"ConfigParameters()",
"pfc.diskusage files should have baseline < nominal < max.");
608 if (aOK && m_configuration.m_fileUsageMax >= m_configuration.m_diskUsageLWM)
610 m_log.Emsg(
"ConfigParameters()",
"pfc.diskusage files values must be below lowWatermark");
624 &m_configuration.m_flushCnt,
625 100 * m_configuration.m_bufferSize , 100000 * m_configuration.m_bufferSize))
629 m_configuration.m_flushCnt /= m_configuration.m_bufferSize;
634 &m_configuration.m_flushCnt, 100, 100000))
642 if (m_configuration.m_RamAbsAvailable == 0)
644 m_configuration.m_RamAbsAvailable = m_isClient ? 256ll * 1024 * 1024 : 1024ll * 1024 * 1024;
646 snprintf(buff,
sizeof(buff),
"RAM usage pfc.ram is not specified. Default value %s is used.", m_isClient ?
"256m" :
"1g");
647 m_log.Say(
"Config info: ", buff);
650 m_configuration.m_RamKeepStdBlocks = (m_configuration.m_RamAbsAvailable / m_configuration.m_bufferSize + 1) * 5 / 100;
653 char* cenv = getenv(
"XRDDEBUG");
654 if (cenv && ! strcmp(cenv,
"1") && m_trace->What < 4) m_trace->What = 4;
659 const char *csc[] = {
"off",
"cache nonet",
"nocache net notls",
663 "off",
"cache nonet",
"nocache net tls",
667 if (m_configuration.m_cs_UVKeep < 0)
670 sprintf(uvk,
"%lld", (
long long) m_configuration.m_cs_UVKeep);
671 float ram_gb = (m_configuration.m_RamAbsAvailable) /
float(1024*1024*1024);
673 char urlcgi_blks[64] =
"ignore", urlcgi_npref[32] =
"ignore";
675 snprintf(urlcgi_blks,
sizeof(urlcgi_blks),
"%lldk %lldk",
678 snprintf(urlcgi_npref,
sizeof(urlcgi_npref),
"%d %d",
683 loff = snprintf(buff,
sizeof(buff),
"Config effective %s pfc configuration:\n"
684 " pfc.cschk %s uvkeep %s\n"
685 " pfc.blocksize %lldk\n"
687 " pfc.urlcgi blocksize %s prefetch %s\n"
689 " pfc.writequeue %d %d\n"
690 " # Total available disk: %lld\n"
691 " pfc.diskusage %lld %lld files %lld %lld %lld purgeinterval %d purgecoldfiles %d\n"
692 " pfc.spaces %s %s\n"
695 " pfc.acchistorysize %d\n"
696 " pfc.onlyIfCachedMinBytes %lld\n"
697 " pfc.onlyIfCachedMinFrac %.2f\n",
699 csc[
int(m_configuration.m_cs_Chk)], uvk,
700 m_configuration.m_bufferSize >> 10,
701 m_configuration.m_prefetch_max_blocks,
702 urlcgi_blks, urlcgi_npref,
704 m_configuration.m_wqueue_blocks, m_configuration.m_wqueue_threads,
706 m_configuration.m_diskUsageLWM, m_configuration.m_diskUsageHWM,
707 m_configuration.m_fileUsageBaseline, m_configuration.m_fileUsageNominal, m_configuration.m_fileUsageMax,
708 m_configuration.m_purgeInterval, m_configuration.m_purgeColdFilesAge,
709 m_configuration.m_data_space.c_str(),
710 m_configuration.m_meta_space.c_str(),
712 m_configuration.m_flushCnt,
713 m_configuration.m_accHistorySize,
714 m_configuration.m_onlyIfCachedMinSize,
715 m_configuration.m_onlyIfCachedMinFrac);
717 if (m_configuration.is_dir_stat_reporting_on())
719 loff += snprintf(buff + loff,
sizeof(buff) - loff,
720 " pfc.dirstats interval %d maxdepth %d (internal: size_of_dirlist %d, size_of_globlist %d)\n",
721 m_configuration.m_dirStatsInterval, m_configuration.m_dirStatsStoreDepth,
722 (
int) m_configuration.m_dirStatsDirs.size(), (
int) m_configuration.m_dirStatsDirGlobs.size());
723 loff += snprintf(buff + loff,
sizeof(buff) - loff,
" dirlist:\n");
724 for (std::set<std::string>::iterator i = m_configuration.m_dirStatsDirs.begin(); i != m_configuration.m_dirStatsDirs.end(); ++i)
725 loff += snprintf(buff + loff,
sizeof(buff) - loff,
" %s\n", i->c_str());
726 loff += snprintf(buff + loff,
sizeof(buff) - loff,
" globlist:\n");
727 for (std::set<std::string>::iterator i = m_configuration.m_dirStatsDirGlobs.begin(); i != m_configuration.m_dirStatsDirGlobs.end(); ++i)
728 loff += snprintf(buff + loff,
sizeof(buff) - loff,
" %s/*\n", i->c_str());
731 if (m_configuration.m_hdfsmode)
733 loff += snprintf(buff + loff,
sizeof(buff) - loff,
" pfc.hdfsmode hdfsbsize %lld\n", m_configuration.m_hdfsbsize);
736 if (m_configuration.m_username.empty())
740 m_configuration.m_username = unameBuff;
744 loff += snprintf(buff + loff,
sizeof(buff) - loff,
" pfc.user %s\n", m_configuration.m_username.c_str());
749 m_env->Put(
"XRDPFC.SEGSIZE", std::to_string(m_configuration.m_bufferSize).c_str());
758 m_log.Say(
" pfc g-stream has", m_gstream ?
"" :
" NOT",
" been configured via xrootd.monitor directive\n");
764 m_res_mon->init_before_main();
767 m_log.Say(
"=====> Proxy file cache configuration parsing ", aOK ?
"completed" :
"failed");
769 if (ofsCfg)
delete ofsCfg;
773#ifdef XRDPFC_CKSUM_TEST
775 int xxx = m_configuration.m_cs_Chk;
777 for (m_configuration.m_cs_Chk =
CSChk_None; m_configuration.m_cs_Chk <=
CSChk_Both; ++m_configuration.m_cs_Chk)
779 Info::TestCksumStuff();
782 m_configuration.m_cs_Chk = xxx;
793 struct ConfWordGetter
798 ConfWordGetter(
XrdOucStream& c) : m_config(c), m_last_word((char*)1) {}
800 const char* GetWord() {
if (HasLast()) m_last_word = m_config.
GetWord();
return HasLast() ? m_last_word :
""; }
801 bool HasLast() {
return (m_last_word != 0); }
804 ConfWordGetter cwg(config);
806 Configuration &CFG = m_configuration;
808 if ( part ==
"user" )
810 m_configuration.m_username = cwg.GetWord();
811 if ( ! cwg.HasLast())
813 m_log.Emsg(
"Config",
"Error: pfc.user requires a parameter.");
817 else if ( part ==
"diskusage" )
824 m_log.Emsg(
"Config",
"Error: pfc.diskusage parameter requires at least two arguments.");
829 while ((p = cwg.GetWord()) && cwg.HasLast())
831 if (strcmp(p,
"files") == 0)
837 if ( ! cwg.HasLast())
839 m_log.Emsg(
"Config",
"Error: pfc.diskusage files directive requires three arguments.");
843 else if (strcmp(p,
"sleep") == 0 || strcmp(p,
"purgeinterval") == 0)
845 if (strcmp(p,
"sleep") == 0) m_log.Emsg(
"Config",
"warning sleep directive is deprecated in pfc.diskusage. Please use purgeinterval instead.");
847 if (
XrdOuca2x::a2tm(m_log,
"Error getting purgeinterval", cwg.GetWord(), &m_configuration.m_purgeInterval, 60, 3600))
852 else if (strcmp(p,
"purgecoldfiles") == 0)
854 if (
XrdOuca2x::a2tm(m_log,
"Error getting purgecoldfiles age", cwg.GetWord(), &m_configuration.m_purgeColdFilesAge, 3600, 3600*24*360))
858 if (
XrdOuca2x::a2i(m_log,
"Error getting purgecoldfiles period", cwg.GetWord(), &m_configuration.m_purgeAgeBasedPeriod, 1, 1000))
865 m_log.Emsg(
"Config",
"Error: diskusage stanza contains unknown directive", p);
869 else if ( part ==
"acchistorysize" )
871 if (
XrdOuca2x::a2i(m_log,
"Error getting access-history-size", cwg.GetWord(), &m_configuration.m_accHistorySize, 20, 200))
876 else if ( part ==
"dirstats" )
879 while ((p = cwg.GetWord()) && cwg.HasLast())
881 if (strcmp(p,
"interval") == 0)
883 int validIntervals[] = {60, 120, 300, 600, 900, 1200, 1800, 3600};
884 int size =
sizeof(validIntervals) /
sizeof(
int);
886 if (
XrdOuca2x::a2tm(m_log,
"Error getting dirstsat interval", cwg.GetWord(),
887 &m_configuration.m_dirStatsInterval, validIntervals[0], validIntervals[size - 1]))
891 bool match =
false, round_down =
false;
892 for (
int i = 0; i < size; i++) {
893 if (validIntervals[i] == m_configuration.m_dirStatsInterval) {
897 if (i > 0 && m_configuration.m_dirStatsInterval < validIntervals[i]) {
898 m_configuration.m_dirStatsInterval = validIntervals[i - 1];
903 if ( ! match && ! round_down) {
904 m_log.Emsg(
"Config",
"Error: dirstat interval parsing failed.");
908 m_log.Emsg(
"Config",
"Info: dirstat interval was rounded down to the nearest valid value.");
912 else if (strcmp(p,
"maxdepth") == 0)
914 if (
XrdOuca2x::a2i(m_log,
"Error getting maxdepth value", cwg.GetWord(),
915 &m_configuration.m_dirStatsStoreDepth, 0, 16))
920 else if (strcmp(p,
"dir") == 0)
923 if (p && p[0] ==
'/')
927 char d[1024]; d[0] = 0;
935 if (*(pd - 1) ==
'/')
947 if (*pd ==
'/' && pd != d) *pd = 0;
950 if (ld >= 2 && d[ld-1] ==
'*' && d[ld-2] ==
'/')
954 m_configuration.m_dirStatsDirGlobs.insert(d);
955 printf(
"Glob %s -> %s -- depth = %d\n", p, d, depth);
959 m_configuration.m_dirStatsDirs.insert(d);
960 printf(
"Dir %s -> %s -- depth = %d\n", p, d, depth);
963 m_configuration.m_dirStatsStoreDepth = std::max(m_configuration.m_dirStatsStoreDepth, depth);
967 m_log.Emsg(
"Config",
"Error: dirstats dir parameter requires a directory argument starting with a '/'.");
973 m_log.Emsg(
"Config",
"Error: dirstats stanza contains unknown directive '", p,
"'");
978 else if ( part ==
"blocksize" )
984 else if ( part ==
"prefetch" || part ==
"nramprefetch" )
986 if (part ==
"nramprefetch")
988 m_log.Emsg(
"Config",
"pfc.nramprefetch is deprecated, please use pfc.prefetch instead. Replacing the directive internally.");
995 else if ( part ==
"urlcgi" )
999 while ((p = cwg.GetWord()) && cwg.HasLast())
1001 if (strcmp(p,
"blocksize") == 0)
1003 std::string bmin = cwg.GetWord();
1004 if (bmin ==
"ignore")
1006 std::string bmax = cwg.GetWord();
1007 if ( ! cwg.HasLast()) {
1008 m_log.Emsg(
"Config",
"Error: pfc.urlcgi blocksize parameter requires two arguments.");
1018 m_log.Emsg(
"Config",
"Error: pfc.urlcgi blocksize second argument must be larger or equal to the first one.");
1023 else if (strcmp(p,
"prefetch") == 0)
1025 std::string bmin = cwg.GetWord();
1026 if (bmin ==
"ignore")
1028 std::string bmax = cwg.GetWord();
1029 if ( ! cwg.HasLast()) {
1030 m_log.Emsg(
"Config",
"Error: pfc.urlcgi blocksize parameter requires two arguments.");
1040 m_log.Emsg(
"Config",
"Error: pfc.urlcgi prefetch second argument must be larger or equal to the first one.");
1047 m_log.Emsg(
"Config",
"Error: urlcgi stanza contains unknown directive '", p,
"'");
1052 else if ( part ==
"nramread" )
1054 m_log.Emsg(
"Config",
"pfc.nramread is deprecated, please use pfc.ram instead. Ignoring this directive.");
1057 else if ( part ==
"ram" )
1059 long long minRAM = m_isClient ? 256 * 1024 * 1024 : 1024 * 1024 * 1024;
1060 long long maxRAM = 256 * minRAM;
1061 if (
XrdOuca2x::a2sz(m_log,
"get RAM available", cwg.GetWord(), &m_configuration.m_RamAbsAvailable, minRAM, maxRAM))
1066 else if ( part ==
"writequeue")
1068 if (
XrdOuca2x::a2i(m_log,
"Error getting pfc.writequeue num-blocks", cwg.GetWord(), &m_configuration.m_wqueue_blocks, 1, 1024))
1072 if (
XrdOuca2x::a2i(m_log,
"Error getting pfc.writequeue num-threads", cwg.GetWord(), &m_configuration.m_wqueue_threads, 1, 64))
1077 else if ( part ==
"spaces" )
1079 m_configuration.m_data_space = cwg.GetWord();
1080 m_configuration.m_meta_space = cwg.GetWord();
1081 if ( ! cwg.HasLast())
1083 m_log.Emsg(
"Config",
"spacenames requires two parameters: <data-space> <metadata-space>.");
1087 else if ( part ==
"hdfsmode" )
1089 m_log.Emsg(
"Config",
"pfc.hdfsmode is currently unsupported.");
1092 m_configuration.m_hdfsmode =
true;
1094 const char* params = cwg.GetWord();
1097 if (! strncmp(
"hdfsbsize", params, 9))
1099 long long minBlSize = 32 * 1024;
1100 long long maxBlSize = 128 * 1024 * 1024;
1101 if (
XrdOuca2x::a2sz(m_log,
"Error getting file fragment size", cwg.GetWord(), &m_configuration.m_hdfsbsize, minBlSize, maxBlSize))
1108 m_log.Emsg(
"Config",
"Error setting the fragment size parameter name");
1113 else if ( part ==
"flush" )
1116 if ( ! cwg.HasLast())
1118 m_log.Emsg(
"Config",
"Error: pfc.flush requires a parameter.");
1122 else if ( part ==
"onlyifcached" )
1125 while ((p = cwg.GetWord()) && cwg.HasLast())
1127 if (strcmp(p,
"minsize") == 0)
1129 std::string minBytes = cwg.GetWord();
1130 long long minBytesTop = 1024 * 1024 * 1024;
1131 if (::isalpha(*(minBytes.rbegin())))
1133 if (
XrdOuca2x::a2sz(m_log,
"Error in parsing minsize value for onlyifcached parameter", minBytes.c_str(), &m_configuration.m_onlyIfCachedMinSize, 0, minBytesTop))
1140 if (
XrdOuca2x::a2ll(m_log,
"Error in parsing numeric minsize value for onlyifcached parameter", minBytes.c_str(),&m_configuration.m_onlyIfCachedMinSize, 0, minBytesTop))
1146 if (strcmp(p,
"minfrac") == 0)
1148 std::string minFrac = cwg.GetWord();
1151 double frac = strtod(minFrac.c_str(), &eP);
1152 if (errno || eP == minFrac.c_str())
1154 m_log.Emsg(
"Config",
"Error setting fraction for only-if-cached directive");
1157 m_configuration.m_onlyIfCachedMinFrac = frac;
1161 m_log.Emsg(
"Config",
"Error: onlyifcached stanza contains unknown directive", p);
1167 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
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_diskUsageLWM
std::string m_diskUsageHWM
std::string m_fileUsageBaseline
std::string m_fileUsageNominal
std::string m_fileUsageMax