diff --git a/docs/admin/env_variables.md b/docs/admin/env_variables.md index 3de0a079203..008a83ca4a5 100644 --- a/docs/admin/env_variables.md +++ b/docs/admin/env_variables.md @@ -54,7 +54,7 @@ Environment variables in this section only apply to the server side. |DAOS\_DTX\_RPC\_HELPER\_THD|DTX RPC helper threshold. The valid range is [18, unlimited). The default value is 513.| |DAOS\_DTX\_BATCHED\_ULT\_MAX|The max count of DTX batched commit ULTs. The valid range is [0, unlimited). 0 means to commit DTX synchronously. The default value is 32.| |DAOS\_FORWARD\_NEIGHBOR|Set to enable I/O forwarding on neighbor xstream in the absence of helper threads.| -|DAOS\_POOL\_RF|Redundancy factor for the pool. The valid range is [1, 4]. The default value is 2.| +|DAOS\_POOL\_RF|Redundancy factor for the pool. The valid range is [0, 4]. The default value is 2.| ## Server and Client environment variables diff --git a/src/pool/srv.c b/src/pool/srv.c index 7e5548e8508..9c9611c04ef 100644 --- a/src/pool/srv.c +++ b/src/pool/srv.c @@ -1,5 +1,5 @@ /** - * (C) Copyright 2016-2022 Intel Corporation. + * (C) Copyright 2016-2024 Intel Corporation. * * SPDX-License-Identifier: BSD-2-Clause-Patent */ @@ -21,10 +21,29 @@ #include "srv_layout.h" bool ec_agg_disabled; -uint32_t pw_rf; /* pool wise RF */ -#define PW_RF_DEFAULT (2) -#define PW_RF_MIN (1) -#define PW_RF_MAX (4) +uint32_t pw_rf = -1; /* pool wise redundancy factor */ +#define PW_RF_DEFAULT (2) +#define PW_RF_MIN (0) +#define PW_RF_MAX (4) + +static inline bool +check_pool_redundancy_factor(const char *variable) +{ + d_getenv_uint32_t(variable, &pw_rf); + if (pw_rf == -1) + return false; + + D_INFO("Checked threshold %s=%d\n", variable, pw_rf); + + if (pw_rf <= PW_RF_MAX) + return true; + + D_INFO("pw_rf %d is out of range [%d, %d], take default %d\n", pw_rf, PW_RF_MIN, PW_RF_MAX, + PW_RF_DEFAULT); + pw_rf = PW_RF_DEFAULT; + + return true; +} static int init(void) @@ -52,14 +71,10 @@ init(void) if (unlikely(ec_agg_disabled)) D_WARN("EC aggregation is disabled.\n"); - pw_rf = PW_RF_DEFAULT; - d_getenv_uint32_t("DAOS_POOL_RF", &pw_rf); - if (pw_rf < PW_RF_MIN || pw_rf > PW_RF_MAX) { - D_INFO("pw_rf %d is out of range [%d, %d], take default %d\n", - pw_rf, PW_RF_MIN, PW_RF_MAX, PW_RF_DEFAULT); + pw_rf = -1; + if (!check_pool_redundancy_factor("DAOS_POOL_RF")) pw_rf = PW_RF_DEFAULT; - } - D_INFO("pool wise RF %d\n", pw_rf); + D_INFO("pool redundancy factor %d\n", pw_rf); ds_pool_rsvc_class_register();