in turbonfs/src/config.cpp [268:498]
bool aznfsc_cfg::set_defaults_and_sanitize()
{
#ifdef ENABLE_PRESSURE_POINTS
const char *err_prob = ::getenv("AZNFSC_INJECT_ERROR_PERCENT");
if (err_prob) {
inject_err_prob_pct_def = ::atof(err_prob);
if (inject_err_prob_pct_def < 0) {
AZLogWarn("Capping AZNFSC_INJECT_ERROR_PERCENT ({}) to 0",
err_prob);
inject_err_prob_pct_def = 0;
} else if (inject_err_prob_pct_def > 100) {
AZLogWarn("Capping AZNFSC_INJECT_ERROR_PERCENT ({}) to 100",
err_prob);
inject_err_prob_pct_def = 100;
}
}
#endif
if (port == -1)
port = 2048;
if (nconnect == -1)
nconnect = 1;
if (rsize == -1)
rsize = 1048576;
if (wsize == -1)
wsize = 1048576;
if (retrans == -1)
retrans = 3;
if (timeo == -1)
timeo = 600;
if (acregmin == -1)
acregmin = 3;
if (acregmax == -1)
acregmax = 60;
if (acdirmin == -1)
acdirmin = 30;
if (acdirmax == -1)
acdirmax = 60;
if (actimeo != -1) {
acregmin = acregmax = acdirmin = acdirmax = actimeo;
} else {
/*
* This is used only by nfs_client::reply_entry() for setting the
* timeout of negative lookup result.
* Rest everywhere we will use ac{reg|dir}{min|max}.
*/
actimeo = AZNFSCFG_ACTIMEO_MIN;
}
if (acregmin > acregmax)
acregmin = acregmax;
if (acdirmin > acdirmax)
acdirmin = acdirmax;
if (lookupcache) {
if (std::string(lookupcache) == "all") {
lookupcache_int = AZNFSCFG_LOOKUPCACHE_ALL;
} else if (std::string(lookupcache) == "none") {
lookupcache_int = AZNFSCFG_LOOKUPCACHE_NONE;
} else if (std::string(lookupcache) == "pos" ||
std::string(lookupcache) == "positive") {
lookupcache_int = AZNFSCFG_LOOKUPCACHE_POS;
} else {
// We should not come here with an invalid value.
assert(0);
lookupcache_int = AZNFSCFG_LOOKUPCACHE_DEF;
}
} else {
lookupcache = "";
lookupcache_int = AZNFSCFG_LOOKUPCACHE_DEF;
}
if (readdir_maxcount == -1)
readdir_maxcount = 1048576;
if (readahead_kb == -1)
readahead_kb = AZNFSCFG_READAHEAD_KB_DEF;
if (cache.data.user.enable) {
if (cache.data.user.max_size_mb < 0) {
/*
* 60% of the total RAM, and capped at 16GiB.
*/
cache.data.user.max_size_mb =
(AZNFSCFG_CACHE_MAX_MB_PERCENT_DEF / 100.0) *
(get_total_ram() / (1024 * 1024));
if (cache.data.user.max_size_mb > 16384) {
cache.data.user.max_size_mb = 16384;
}
}
}
if (cache.readdir.user.enable) {
/*
* If not set from config, set to default value of 4GB.
*/
if (cache.readdir.user.max_size_mb == -1) {
cache.readdir.user.max_size_mb = 4096;
}
assert(cache.readdir.user.max_size_mb > 0);
}
if (filecache.enable) {
if (filecache.max_size_gb == -1)
filecache.max_size_gb = AZNFSCFG_FILECACHE_MAX_GB_DEF;
}
if (consistency) {
if (std::string(consistency) == "solowriter") {
consistency_int = consistency_t::SOLOWRITER;
consistency_solowriter = true;
/*
* Set actimeo to the max value. and lookupcache for caching positive
* and negative lookup responses.
*/
actimeo = AZNFSCFG_ACTIMEO_MAX;
lookupcache_int = AZNFSCFG_LOOKUPCACHE_ALL;
} else if (std::string(consistency) == "standardnfs") {
consistency_int = consistency_t::STANDARDNFS;
consistency_standardnfs = true;
} else if (std::string(consistency) == "azurempa") {
consistency_int = consistency_t::AZUREMPA;
consistency_azurempa = true;
} else {
// We should not come here with an invalid value.
assert(0);
consistency_int = consistency_t::STANDARDNFS;
consistency_standardnfs = true;
}
} else {
consistency = "";
consistency_int = consistency_t::STANDARDNFS;
consistency_standardnfs = true;
}
/*
* One and only one consistency mode boolean must be set.
*/
assert(((int) consistency_solowriter +
(int) consistency_standardnfs +
(int) consistency_azurempa) == 1);
/*
* If user has not provided cloud_suffix, try to make a good guess.
*/
if (cloud_suffix == nullptr) {
struct addrinfo *ai = NULL;
AZLogDebug("cloud_suffix not specified, trying to guess it!");
AZLogDebug("trying blob.core.windows.net ...");
std::string try_server = std::string(account) + ".blob.core.windows.net";
if (::getaddrinfo(try_server.c_str(), NULL, NULL, &ai) == 0) {
cloud_suffix = ::strdup("blob.core.windows.net");
goto done_cloud_suffix;
}
AZLogDebug("it is not blob.core.windows.net!");
AZLogDebug("trying blob.preprod.core.windows.net ...");
try_server = std::string(account) + ".blob.preprod.core.windows.net";
if (::getaddrinfo(try_server.c_str(), NULL, NULL, &ai) == 0) {
cloud_suffix = ::strdup("blob.preprod.core.windows.net");
goto done_cloud_suffix;
}
AZLogDebug("it is not blob.preprod.core.windows.net!");
AZLogError("Failed to find a valid endpoint, make sure you provided "
"a valid account ({}) else provide a valid cloud_suffix!",
account);
return false;
done_cloud_suffix:
AZLogDebug("it is {}!", cloud_suffix);
assert(ai);
::freeaddrinfo(ai);
}
if (xprtsec == nullptr)
xprtsec = ::strdup("none");
assert(account != nullptr);
assert(container != nullptr);
// Set aggregates.
server = std::string(account) + "." + std::string(cloud_suffix);
export_path = "/" + std::string(account) + "/" + std::string(container);
// Dump the final config values for debugging.
AZLogDebug("===== config start =====");
#ifdef ENABLE_PRESSURE_POINTS
AZLogDebug("inject_err_prob_pct_def = {}", inject_err_prob_pct_def);
#endif
AZLogDebug("auth = {}", auth);
AZLogDebug("port = {}", port);
AZLogDebug("nconnect = {}", nconnect);
AZLogDebug("rsize = {}", rsize);
AZLogDebug("wsize = {}", wsize);
AZLogDebug("retrans = {}", retrans);
AZLogDebug("xprtsec = {}", xprtsec);
AZLogDebug("oom_kill_disable = {}", oom_kill_disable);
AZLogDebug("timeo = {}", timeo);
AZLogDebug("acregmin = {}", acregmin);
AZLogDebug("acregmax = {}", acregmax);
AZLogDebug("acdirmin = {}", acdirmin);
AZLogDebug("acdirmax = {}", acdirmax);
AZLogDebug("actimeo = {}", actimeo);
AZLogDebug("lookupcache = <{}> ({})", lookupcache, lookupcache_int);
AZLogDebug("consistency = <{}> ({})", consistency, (int) consistency_int);
AZLogDebug("readdir_maxcount = {}", readdir_maxcount);
AZLogDebug("readahead_kb = {}", readahead_kb);
AZLogDebug("fuse_max_background = {}", fuse_max_background);
AZLogDebug("fuse_max_threads = {}", fuse_max_threads);
AZLogDebug("fuse_max_idle_threads = {}", fuse_max_idle_threads);
AZLogDebug("cache.attr.user.enable = {}", cache.attr.user.enable);
AZLogDebug("cache.readdir.kernel.enable = {}", cache.readdir.kernel.enable);
AZLogDebug("cache.readdir.user.enable = {}", cache.readdir.user.enable);
AZLogDebug("cache.readdir.user.max_size_mb = {}", cache.readdir.user.max_size_mb);
AZLogDebug("cache.data.kernel.enable = {}", cache.data.kernel.enable);
AZLogDebug("cache.data.user.enable = {}", cache.data.user.enable);
AZLogDebug("cache.data.user.max_size_mb = {}", cache.data.user.max_size_mb);
AZLogDebug("filecache.enable = {}", filecache.enable);
AZLogDebug("filecache.cachedir = {}", filecache.cachedir ? filecache.cachedir : "");
AZLogDebug("filecache.max_size_gb = {}", filecache.max_size_gb);
AZLogDebug("sys.force_stable_writes = {}", sys.force_stable_writes);
AZLogDebug("sys.resolve_before_reconnect = {}", sys.resolve_before_reconnect);
AZLogDebug("sys.nodrc.remove_noent_as_success = {}", sys.nodrc.remove_noent_as_success);
AZLogDebug("sys.nodrc.create_exist_as_success = {}", sys.nodrc.create_exist_as_success);
AZLogDebug("sys.nodrc.rename_noent_as_success = {}", sys.nodrc.rename_noent_as_success);
AZLogDebug("account = {}", account);
AZLogDebug("container = {}", container);
AZLogDebug("cloud_suffix = {}", cloud_suffix);
AZLogDebug("mountpoint = {}", mountpoint);
AZLogDebug("===== config end =====");
return true;
}