glusterfs
glusterfs copied to clipboard
libglusterfs, dht, glusterd: unify rebalance thread counting
Introduce gf_rebalance_thread_count()
and use it
both in DHT and glusterd, related cleanups as usual.
Signed-off-by: Dmitry Antipov [email protected] Updates: #1000
CLANG-FORMAT FAILURE: Before merging the patch, this diff needs to be considered for passing clang-format
index e4f1c2093..c1d0a07f8 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -4288,7 +4288,7 @@ gf_set_nofile(rlim_t high, rlim_t low)
{
int n, ret = -1;
struct rlimit lim;
- rlim_t r[2] = { high, low };
+ rlim_t r[2] = {high, low};
for (n = 0; n < 2; n++)
if (r[n] != 0) {
@@ -4340,15 +4340,19 @@ gf_rebalance_thread_count(char *str, char **errmsg)
if (count > 0 && count <= lim)
return count;
else {
- if (gf_asprintf(errmsg, "number of rebalance threads should be "
- "in range from 1 to %d, not %d", lim, count) < 0)
+ if (gf_asprintf(errmsg,
+ "number of rebalance threads should be "
+ "in range from 1 to %d, not %d",
+ lim, count) < 0)
*errmsg = NULL;
return -1;
}
}
- if (gf_asprintf(errmsg, "number of rebalance threads should "
+ if (gf_asprintf(errmsg,
+ "number of rebalance threads should "
"be {lazy|normal|aggressive} or a number in "
- "range from 1 to %d, not %s", lim, str) < 0)
+ "range from 1 to %d, not %s",
+ lim, str) < 0)
*errmsg = NULL;
return -1;
}
diff --git a/libglusterfs/src/glusterfs/common-utils.h b/libglusterfs/src/glusterfs/common-utils.h
index 3c397b873..0385c59f4 100644
--- a/libglusterfs/src/glusterfs/common-utils.h
+++ b/libglusterfs/src/glusterfs/common-utils.h
@@ -209,7 +209,9 @@ gf_set_nofile(rlim_t high, rlim_t low);
#else /* Darwin */
-#define gf_set_nofile(low, high) do { } while (0)
+#define gf_set_nofile(low, high) \
+ do { \
+ } while (0)
#endif /* not GF_DARWIN_HOST_OS */
diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c
index 8f2c4b5d4..85d3fa6aa 100644
--- a/xlators/cluster/dht/src/dht-shared.c
+++ b/xlators/cluster/dht/src/dht-shared.c
@@ -367,8 +367,10 @@ dht_configure_throttle(xlator_t *this, dht_conf_t *conf, char *temp_str)
pthread_mutex_lock(&conf->defrag->dfq_mutex);
conf->defrag->recon_thread_count = count;
pthread_mutex_unlock(&conf->defrag->dfq_mutex);
- gf_msg(this->name, GF_LOG_INFO, 0, 0, "rebalance "
- "thread count configured to %d", count);
+ gf_msg(this->name, GF_LOG_INFO, 0, 0,
+ "rebalance "
+ "thread count configured to %d",
+ count);
ret = 0;
} else {
gf_msg(this->name, GF_LOG_ERROR, 0, DHT_MSG_INVALID_OPTION, "%s",
/run regression
CLANG-FORMAT FAILURE: Before merging the patch, this diff needs to be considered for passing clang-format
index e4f1c2093..c1d0a07f8 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -4288,7 +4288,7 @@ gf_set_nofile(rlim_t high, rlim_t low)
{
int n, ret = -1;
struct rlimit lim;
- rlim_t r[2] = { high, low };
+ rlim_t r[2] = {high, low};
for (n = 0; n < 2; n++)
if (r[n] != 0) {
@@ -4340,15 +4340,19 @@ gf_rebalance_thread_count(char *str, char **errmsg)
if (count > 0 && count <= lim)
return count;
else {
- if (gf_asprintf(errmsg, "number of rebalance threads should be "
- "in range from 1 to %d, not %d", lim, count) < 0)
+ if (gf_asprintf(errmsg,
+ "number of rebalance threads should be "
+ "in range from 1 to %d, not %d",
+ lim, count) < 0)
*errmsg = NULL;
return -1;
}
}
- if (gf_asprintf(errmsg, "number of rebalance threads should "
+ if (gf_asprintf(errmsg,
+ "number of rebalance threads should "
"be {lazy|normal|aggressive} or a number in "
- "range from 1 to %d, not %s", lim, str) < 0)
+ "range from 1 to %d, not %s",
+ lim, str) < 0)
*errmsg = NULL;
return -1;
}
diff --git a/libglusterfs/src/glusterfs/common-utils.h b/libglusterfs/src/glusterfs/common-utils.h
index 3c397b873..0385c59f4 100644
--- a/libglusterfs/src/glusterfs/common-utils.h
+++ b/libglusterfs/src/glusterfs/common-utils.h
@@ -209,7 +209,9 @@ gf_set_nofile(rlim_t high, rlim_t low);
#else /* Darwin */
-#define gf_set_nofile(low, high) do { } while (0)
+#define gf_set_nofile(low, high) \
+ do { \
+ } while (0)
#endif /* not GF_DARWIN_HOST_OS */
diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c
index 024930639..6bc4c2228 100644
--- a/xlators/cluster/dht/src/dht-shared.c
+++ b/xlators/cluster/dht/src/dht-shared.c
@@ -367,8 +367,10 @@ dht_configure_throttle(xlator_t *this, dht_conf_t *conf, char *temp_str)
pthread_mutex_lock(&conf->defrag->dfq_mutex);
conf->defrag->recon_thread_count = count;
pthread_mutex_unlock(&conf->defrag->dfq_mutex);
- gf_msg(this->name, GF_LOG_INFO, 0, 0, "rebalance "
- "thread count configured to %d", count);
+ gf_msg(this->name, GF_LOG_INFO, 0, 0,
+ "rebalance "
+ "thread count configured to %d",
+ count);
ret = 0;
} else {
gf_msg(this->name, GF_LOG_ERROR, 0, DHT_MSG_INVALID_OPTION, "%s",
/run regression