|
|
d84cf8 |
From 866a4c49ad9c5a9125814a9f843d4c7fd967ab2b Mon Sep 17 00:00:00 2001
|
|
|
d84cf8 |
From: Kotresh HR <khiremat@redhat.com>
|
|
|
d84cf8 |
Date: Mon, 3 Feb 2020 18:10:17 +0530
|
|
|
d84cf8 |
Subject: [PATCH 446/449] bitrot: Make number of signer threads configurable
|
|
|
d84cf8 |
|
|
|
d84cf8 |
The number of signing process threads (glfs_brpobj)
|
|
|
d84cf8 |
is set to 4 by default. The recommendation is to set
|
|
|
d84cf8 |
it to number of cores available. This patch makes it
|
|
|
d84cf8 |
configurable as follows
|
|
|
d84cf8 |
|
|
|
d84cf8 |
gluster vol bitrot <volname> signer-threads <count>
|
|
|
d84cf8 |
|
|
|
d84cf8 |
> fixes: bz#1797869
|
|
|
d84cf8 |
> Change-Id: Ia883b3e5e34e0bc8d095243508d320c9c9c58adc
|
|
|
d84cf8 |
> Signed-off-by: Kotresh HR <khiremat@redhat.com>
|
|
|
d84cf8 |
> (Cherry pick from commit 8fad76650bd85463708f59d2518f5b764ae4c702)
|
|
|
d84cf8 |
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/24091/)
|
|
|
d84cf8 |
|
|
|
d84cf8 |
BUG: 1790336
|
|
|
d84cf8 |
Change-Id: Ia883b3e5e34e0bc8d095243508d320c9c9c58adc
|
|
|
d84cf8 |
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
d84cf8 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/202780
|
|
|
d84cf8 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
d84cf8 |
---
|
|
|
d84cf8 |
cli/src/cli-cmd-parser.c | 29 +++++++-
|
|
|
d84cf8 |
cli/src/cli-cmd-volume.c | 12 +++
|
|
|
d84cf8 |
doc/gluster.8 | 6 ++
|
|
|
d84cf8 |
libglusterfs/src/glusterfs/common-utils.h | 1 +
|
|
|
d84cf8 |
rpc/xdr/src/cli1-xdr.x | 1 +
|
|
|
d84cf8 |
tests/bitrot/br-signer-threads-config-1797869.t | 73 +++++++++++++++++++
|
|
|
d84cf8 |
xlators/features/bit-rot/src/bitd/bit-rot.c | 45 +++++++++---
|
|
|
d84cf8 |
xlators/features/bit-rot/src/bitd/bit-rot.h | 20 ++---
|
|
|
d84cf8 |
.../bit-rot/src/stub/bit-rot-stub-mem-types.h | 1 +
|
|
|
d84cf8 |
xlators/mgmt/glusterd/src/glusterd-bitrot.c | 85 ++++++++++++++++++++++
|
|
|
d84cf8 |
xlators/mgmt/glusterd/src/glusterd-volgen.c | 16 ++--
|
|
|
d84cf8 |
xlators/mgmt/glusterd/src/glusterd-volume-set.c | 9 +++
|
|
|
d84cf8 |
12 files changed, 270 insertions(+), 28 deletions(-)
|
|
|
d84cf8 |
create mode 100644 tests/bitrot/br-signer-threads-config-1797869.t
|
|
|
d84cf8 |
|
|
|
d84cf8 |
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
|
|
|
d84cf8 |
index 7446b95..5fd05f4 100644
|
|
|
d84cf8 |
--- a/cli/src/cli-cmd-parser.c
|
|
|
d84cf8 |
+++ b/cli/src/cli-cmd-parser.c
|
|
|
d84cf8 |
@@ -5661,7 +5661,7 @@ cli_cmd_bitrot_parse(const char **words, int wordcount, dict_t **options)
|
|
|
d84cf8 |
char *volname = NULL;
|
|
|
d84cf8 |
char *opwords[] = {
|
|
|
d84cf8 |
"enable", "disable", "scrub-throttle", "scrub-frequency", "scrub",
|
|
|
d84cf8 |
- "signing-time", NULL};
|
|
|
d84cf8 |
+ "signing-time", "signer-threads", NULL};
|
|
|
d84cf8 |
char *scrub_throt_values[] = {"lazy", "normal", "aggressive", NULL};
|
|
|
d84cf8 |
char *scrub_freq_values[] = {"hourly", "daily", "weekly", "biweekly",
|
|
|
d84cf8 |
"monthly", "minute", NULL};
|
|
|
d84cf8 |
@@ -5669,6 +5669,7 @@ cli_cmd_bitrot_parse(const char **words, int wordcount, dict_t **options)
|
|
|
d84cf8 |
dict_t *dict = NULL;
|
|
|
d84cf8 |
gf_bitrot_type type = GF_BITROT_OPTION_TYPE_NONE;
|
|
|
d84cf8 |
int32_t expiry_time = 0;
|
|
|
d84cf8 |
+ int32_t signer_th_count = 0;
|
|
|
d84cf8 |
|
|
|
d84cf8 |
GF_ASSERT(words);
|
|
|
d84cf8 |
GF_ASSERT(options);
|
|
|
d84cf8 |
@@ -5849,6 +5850,31 @@ cli_cmd_bitrot_parse(const char **words, int wordcount, dict_t **options)
|
|
|
d84cf8 |
}
|
|
|
d84cf8 |
goto set_type;
|
|
|
d84cf8 |
}
|
|
|
d84cf8 |
+ } else if (!strcmp(words[3], "signer-threads")) {
|
|
|
d84cf8 |
+ if (!words[4]) {
|
|
|
d84cf8 |
+ cli_err(
|
|
|
d84cf8 |
+ "Missing signer-thread value for bitrot "
|
|
|
d84cf8 |
+ "option");
|
|
|
d84cf8 |
+ ret = -1;
|
|
|
d84cf8 |
+ goto out;
|
|
|
d84cf8 |
+ } else {
|
|
|
d84cf8 |
+ type = GF_BITROT_OPTION_TYPE_SIGNER_THREADS;
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+ signer_th_count = strtol(words[4], NULL, 0);
|
|
|
d84cf8 |
+ if (signer_th_count < 1) {
|
|
|
d84cf8 |
+ cli_err("signer-thread count should not be less than 1");
|
|
|
d84cf8 |
+ ret = -1;
|
|
|
d84cf8 |
+ goto out;
|
|
|
d84cf8 |
+ }
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+ ret = dict_set_uint32(dict, "signer-threads",
|
|
|
d84cf8 |
+ (unsigned int)signer_th_count);
|
|
|
d84cf8 |
+ if (ret) {
|
|
|
d84cf8 |
+ cli_out("Failed to set dict for bitrot");
|
|
|
d84cf8 |
+ goto out;
|
|
|
d84cf8 |
+ }
|
|
|
d84cf8 |
+ goto set_type;
|
|
|
d84cf8 |
+ }
|
|
|
d84cf8 |
} else {
|
|
|
d84cf8 |
cli_err(
|
|
|
d84cf8 |
"Invalid option %s for bitrot. Please enter valid "
|
|
|
d84cf8 |
@@ -5857,7 +5883,6 @@ cli_cmd_bitrot_parse(const char **words, int wordcount, dict_t **options)
|
|
|
d84cf8 |
ret = -1;
|
|
|
d84cf8 |
goto out;
|
|
|
d84cf8 |
}
|
|
|
d84cf8 |
-
|
|
|
d84cf8 |
set_type:
|
|
|
d84cf8 |
ret = dict_set_int32(dict, "type", type);
|
|
|
d84cf8 |
if (ret < 0)
|
|
|
d84cf8 |
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
|
|
|
d84cf8 |
index f33fc99..72504ca 100644
|
|
|
d84cf8 |
--- a/cli/src/cli-cmd-volume.c
|
|
|
d84cf8 |
+++ b/cli/src/cli-cmd-volume.c
|
|
|
d84cf8 |
@@ -3236,6 +3236,16 @@ struct cli_cmd bitrot_cmds[] = {
|
|
|
d84cf8 |
{"volume bitrot <VOLNAME> {enable|disable}", NULL, /*cli_cmd_bitrot_cbk,*/
|
|
|
d84cf8 |
"Enable/disable bitrot for volume <VOLNAME>"},
|
|
|
d84cf8 |
|
|
|
d84cf8 |
+ {"volume bitrot <VOLNAME> signing-time <time-in-secs>",
|
|
|
d84cf8 |
+ NULL, /*cli_cmd_bitrot_cbk,*/
|
|
|
d84cf8 |
+ "Waiting time for an object after last fd is closed to start signing "
|
|
|
d84cf8 |
+ "process"},
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+ {"volume bitrot <VOLNAME> signer-threads <count>",
|
|
|
d84cf8 |
+ NULL, /*cli_cmd_bitrot_cbk,*/
|
|
|
d84cf8 |
+ "Number of signing process threads. Usually set to number of available "
|
|
|
d84cf8 |
+ "cores"},
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
{"volume bitrot <VOLNAME> scrub-throttle {lazy|normal|aggressive}",
|
|
|
d84cf8 |
NULL, /*cli_cmd_bitrot_cbk,*/
|
|
|
d84cf8 |
"Set the speed of the scrubber for volume <VOLNAME>"},
|
|
|
d84cf8 |
@@ -3251,6 +3261,8 @@ struct cli_cmd bitrot_cmds[] = {
|
|
|
d84cf8 |
"the scrubber. ondemand starts the scrubber immediately."},
|
|
|
d84cf8 |
|
|
|
d84cf8 |
{"volume bitrot <VOLNAME> {enable|disable}\n"
|
|
|
d84cf8 |
+ "volume bitrot <VOLNAME> signing-time <time-in-secs>\n"
|
|
|
d84cf8 |
+ "volume bitrot <VOLNAME> signer-threads <count>\n"
|
|
|
d84cf8 |
"volume bitrot <volname> scrub-throttle {lazy|normal|aggressive}\n"
|
|
|
d84cf8 |
"volume bitrot <volname> scrub-frequency {hourly|daily|weekly|biweekly"
|
|
|
d84cf8 |
"|monthly}\n"
|
|
|
d84cf8 |
diff --git a/doc/gluster.8 b/doc/gluster.8
|
|
|
d84cf8 |
index 66bdb48..084346d 100644
|
|
|
d84cf8 |
--- a/doc/gluster.8
|
|
|
d84cf8 |
+++ b/doc/gluster.8
|
|
|
d84cf8 |
@@ -244,6 +244,12 @@ Use "!<OPTION>" to reset option <OPTION> to default value.
|
|
|
d84cf8 |
\fB\ volume bitrot <VOLNAME> {enable|disable} \fR
|
|
|
d84cf8 |
Enable/disable bitrot for volume <VOLNAME>
|
|
|
d84cf8 |
.TP
|
|
|
d84cf8 |
+\fB\ volume bitrot <VOLNAME> signing-time <time-in-secs> \fR
|
|
|
d84cf8 |
+Waiting time for an object after last fd is closed to start signing process.
|
|
|
d84cf8 |
+.TP
|
|
|
d84cf8 |
+\fB\ volume bitrot <VOLNAME> signer-threads <count> \fR
|
|
|
d84cf8 |
+Number of signing process threads. Usually set to number of available cores.
|
|
|
d84cf8 |
+.TP
|
|
|
d84cf8 |
\fB\ volume bitrot <VOLNAME> scrub-throttle {lazy|normal|aggressive} \fR
|
|
|
d84cf8 |
Scrub-throttle value is a measure of how fast or slow the scrubber scrubs the filesystem for volume <VOLNAME>
|
|
|
d84cf8 |
.TP
|
|
|
d84cf8 |
diff --git a/libglusterfs/src/glusterfs/common-utils.h b/libglusterfs/src/glusterfs/common-utils.h
|
|
|
d84cf8 |
index 0e2ecc7..f0a0a41 100644
|
|
|
d84cf8 |
--- a/libglusterfs/src/glusterfs/common-utils.h
|
|
|
d84cf8 |
+++ b/libglusterfs/src/glusterfs/common-utils.h
|
|
|
d84cf8 |
@@ -126,6 +126,7 @@ trap(void);
|
|
|
d84cf8 |
|
|
|
d84cf8 |
/* Default value of signing waiting time to sign a file for bitrot */
|
|
|
d84cf8 |
#define SIGNING_TIMEOUT "120"
|
|
|
d84cf8 |
+#define BR_WORKERS "4"
|
|
|
d84cf8 |
|
|
|
d84cf8 |
/* xxhash */
|
|
|
d84cf8 |
#define GF_XXH64_DIGEST_LENGTH 8
|
|
|
d84cf8 |
diff --git a/rpc/xdr/src/cli1-xdr.x b/rpc/xdr/src/cli1-xdr.x
|
|
|
d84cf8 |
index a32c864..777cb00 100644
|
|
|
d84cf8 |
--- a/rpc/xdr/src/cli1-xdr.x
|
|
|
d84cf8 |
+++ b/rpc/xdr/src/cli1-xdr.x
|
|
|
d84cf8 |
@@ -68,6 +68,7 @@ enum gf_bitrot_type {
|
|
|
d84cf8 |
GF_BITROT_OPTION_TYPE_EXPIRY_TIME,
|
|
|
d84cf8 |
GF_BITROT_CMD_SCRUB_STATUS,
|
|
|
d84cf8 |
GF_BITROT_CMD_SCRUB_ONDEMAND,
|
|
|
d84cf8 |
+ GF_BITROT_OPTION_TYPE_SIGNER_THREADS,
|
|
|
d84cf8 |
GF_BITROT_OPTION_TYPE_MAX
|
|
|
d84cf8 |
};
|
|
|
d84cf8 |
|
|
|
d84cf8 |
diff --git a/tests/bitrot/br-signer-threads-config-1797869.t b/tests/bitrot/br-signer-threads-config-1797869.t
|
|
|
d84cf8 |
new file mode 100644
|
|
|
d84cf8 |
index 0000000..657ef3e
|
|
|
d84cf8 |
--- /dev/null
|
|
|
d84cf8 |
+++ b/tests/bitrot/br-signer-threads-config-1797869.t
|
|
|
d84cf8 |
@@ -0,0 +1,73 @@
|
|
|
d84cf8 |
+#!/bin/bash
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+. $(dirname $0)/../include.rc
|
|
|
d84cf8 |
+. $(dirname $0)/../volume.rc
|
|
|
d84cf8 |
+. $(dirname $0)/../cluster.rc
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+function get_bitd_count_1 {
|
|
|
d84cf8 |
+ ps auxww | grep glusterfs | grep bitd.pid | grep -v grep | grep $H1 | wc -l
|
|
|
d84cf8 |
+}
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+function get_bitd_count_2 {
|
|
|
d84cf8 |
+ ps auxww | grep glusterfs | grep bitd.pid | grep -v grep | grep $H2 | wc -l
|
|
|
d84cf8 |
+}
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+function get_bitd_pid_1 {
|
|
|
d84cf8 |
+ ps auxww | grep glusterfs | grep bitd.pid | grep -v grep | grep $H1 | awk '{print $2}'
|
|
|
d84cf8 |
+}
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+function get_bitd_pid_2 {
|
|
|
d84cf8 |
+ ps auxww | grep glusterfs | grep bitd.pid | grep -v grep | grep $H2 | awk '{print $2}'
|
|
|
d84cf8 |
+}
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+function get_signer_th_count_1 {
|
|
|
d84cf8 |
+ ps -eL | grep $(get_bitd_pid_1) | grep glfs_brpobj | wc -l
|
|
|
d84cf8 |
+}
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+function get_signer_th_count_2 {
|
|
|
d84cf8 |
+ ps -eL | grep $(get_bitd_pid_2) | grep glfs_brpobj | wc -l
|
|
|
d84cf8 |
+}
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+cleanup;
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+TEST launch_cluster 2
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+TEST $CLI_1 peer probe $H2;
|
|
|
d84cf8 |
+EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count;
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+TEST $CLI_1 volume create $V0 $H1:$B1
|
|
|
d84cf8 |
+TEST $CLI_1 volume create $V1 $H2:$B2
|
|
|
d84cf8 |
+EXPECT 'Created' volinfo_field_1 $V0 'Status';
|
|
|
d84cf8 |
+EXPECT 'Created' volinfo_field_1 $V1 'Status';
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+TEST $CLI_1 volume start $V0
|
|
|
d84cf8 |
+TEST $CLI_1 volume start $V1
|
|
|
d84cf8 |
+EXPECT 'Started' volinfo_field_1 $V0 'Status';
|
|
|
d84cf8 |
+EXPECT 'Started' volinfo_field_1 $V1 'Status';
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+#Enable bitrot
|
|
|
d84cf8 |
+TEST $CLI_1 volume bitrot $V0 enable
|
|
|
d84cf8 |
+TEST $CLI_1 volume bitrot $V1 enable
|
|
|
d84cf8 |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count_1
|
|
|
d84cf8 |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count_2
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "4" get_signer_th_count_1
|
|
|
d84cf8 |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "4" get_signer_th_count_2
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+old_bitd_pid_1=$(get_bitd_pid_1)
|
|
|
d84cf8 |
+old_bitd_pid_2=$(get_bitd_pid_2)
|
|
|
d84cf8 |
+TEST $CLI_1 volume bitrot $V0 signer-threads 1
|
|
|
d84cf8 |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_signer_th_count_1
|
|
|
d84cf8 |
+EXPECT_NOT "$old_bitd_pid_1" get_bitd_pid_1;
|
|
|
d84cf8 |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "4" get_signer_th_count_2
|
|
|
d84cf8 |
+EXPECT "$old_bitd_pid_2" get_bitd_pid_2;
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+old_bitd_pid_1=$(get_bitd_pid_1)
|
|
|
d84cf8 |
+old_bitd_pid_2=$(get_bitd_pid_2)
|
|
|
d84cf8 |
+TEST $CLI_1 volume bitrot $V1 signer-threads 2
|
|
|
d84cf8 |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "2" get_signer_th_count_2
|
|
|
d84cf8 |
+EXPECT_NOT "$old_bitd_pid_2" get_bitd_pid_2;
|
|
|
d84cf8 |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_signer_th_count_1
|
|
|
d84cf8 |
+EXPECT "$old_bitd_pid_1" get_bitd_pid_1;
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+cleanup;
|
|
|
d84cf8 |
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c
|
|
|
d84cf8 |
index 7b1c5dc..b8feef7 100644
|
|
|
d84cf8 |
--- a/xlators/features/bit-rot/src/bitd/bit-rot.c
|
|
|
d84cf8 |
+++ b/xlators/features/bit-rot/src/bitd/bit-rot.c
|
|
|
d84cf8 |
@@ -1734,22 +1734,26 @@ out:
|
|
|
d84cf8 |
return 0;
|
|
|
d84cf8 |
}
|
|
|
d84cf8 |
|
|
|
d84cf8 |
-/**
|
|
|
d84cf8 |
- * Initialize signer specific structures, spawn worker threads.
|
|
|
d84cf8 |
- */
|
|
|
d84cf8 |
-
|
|
|
d84cf8 |
static void
|
|
|
d84cf8 |
br_fini_signer(xlator_t *this, br_private_t *priv)
|
|
|
d84cf8 |
{
|
|
|
d84cf8 |
int i = 0;
|
|
|
d84cf8 |
|
|
|
d84cf8 |
- for (; i < BR_WORKERS; i++) {
|
|
|
d84cf8 |
+ if (priv == NULL)
|
|
|
d84cf8 |
+ return;
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+ for (; i < priv->signer_th_count; i++) {
|
|
|
d84cf8 |
(void)gf_thread_cleanup_xint(priv->obj_queue->workers[i]);
|
|
|
d84cf8 |
}
|
|
|
d84cf8 |
+ GF_FREE(priv->obj_queue->workers);
|
|
|
d84cf8 |
|
|
|
d84cf8 |
pthread_cond_destroy(&priv->object_cond);
|
|
|
d84cf8 |
}
|
|
|
d84cf8 |
|
|
|
d84cf8 |
+/**
|
|
|
d84cf8 |
+ * Initialize signer specific structures, spawn worker threads.
|
|
|
d84cf8 |
+ */
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
static int32_t
|
|
|
d84cf8 |
br_init_signer(xlator_t *this, br_private_t *priv)
|
|
|
d84cf8 |
{
|
|
|
d84cf8 |
@@ -1769,7 +1773,12 @@ br_init_signer(xlator_t *this, br_private_t *priv)
|
|
|
d84cf8 |
goto cleanup_cond;
|
|
|
d84cf8 |
INIT_LIST_HEAD(&priv->obj_queue->objects);
|
|
|
d84cf8 |
|
|
|
d84cf8 |
- for (i = 0; i < BR_WORKERS; i++) {
|
|
|
d84cf8 |
+ priv->obj_queue->workers = GF_CALLOC(
|
|
|
d84cf8 |
+ priv->signer_th_count, sizeof(pthread_t), gf_br_mt_br_worker_t);
|
|
|
d84cf8 |
+ if (!priv->obj_queue->workers)
|
|
|
d84cf8 |
+ goto cleanup_obj_queue;
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+ for (i = 0; i < priv->signer_th_count; i++) {
|
|
|
d84cf8 |
ret = gf_thread_create(&priv->obj_queue->workers[i], NULL,
|
|
|
d84cf8 |
br_process_object, this, "brpobj");
|
|
|
d84cf8 |
if (ret != 0) {
|
|
|
d84cf8 |
@@ -1787,7 +1796,9 @@ cleanup_threads:
|
|
|
d84cf8 |
for (i--; i >= 0; i--) {
|
|
|
d84cf8 |
(void)gf_thread_cleanup_xint(priv->obj_queue->workers[i]);
|
|
|
d84cf8 |
}
|
|
|
d84cf8 |
+ GF_FREE(priv->obj_queue->workers);
|
|
|
d84cf8 |
|
|
|
d84cf8 |
+cleanup_obj_queue:
|
|
|
d84cf8 |
GF_FREE(priv->obj_queue);
|
|
|
d84cf8 |
|
|
|
d84cf8 |
cleanup_cond:
|
|
|
d84cf8 |
@@ -1840,7 +1851,7 @@ br_rate_limit_signer(xlator_t *this, int child_count, int numbricks)
|
|
|
d84cf8 |
if (contribution == 0)
|
|
|
d84cf8 |
contribution = 1;
|
|
|
d84cf8 |
spec.rate = BR_HASH_CALC_READ_SIZE * contribution;
|
|
|
d84cf8 |
- spec.maxlimit = BR_WORKERS * BR_HASH_CALC_READ_SIZE;
|
|
|
d84cf8 |
+ spec.maxlimit = priv->signer_th_count * BR_HASH_CALC_READ_SIZE;
|
|
|
d84cf8 |
|
|
|
d84cf8 |
#endif
|
|
|
d84cf8 |
|
|
|
d84cf8 |
@@ -1860,11 +1871,16 @@ br_rate_limit_signer(xlator_t *this, int child_count, int numbricks)
|
|
|
d84cf8 |
static int32_t
|
|
|
d84cf8 |
br_signer_handle_options(xlator_t *this, br_private_t *priv, dict_t *options)
|
|
|
d84cf8 |
{
|
|
|
d84cf8 |
- if (options)
|
|
|
d84cf8 |
+ if (options) {
|
|
|
d84cf8 |
GF_OPTION_RECONF("expiry-time", priv->expiry_time, options, uint32,
|
|
|
d84cf8 |
error_return);
|
|
|
d84cf8 |
- else
|
|
|
d84cf8 |
+ GF_OPTION_RECONF("signer-threads", priv->signer_th_count, options,
|
|
|
d84cf8 |
+ uint32, error_return);
|
|
|
d84cf8 |
+ } else {
|
|
|
d84cf8 |
GF_OPTION_INIT("expiry-time", priv->expiry_time, uint32, error_return);
|
|
|
d84cf8 |
+ GF_OPTION_INIT("signer-threads", priv->signer_th_count, uint32,
|
|
|
d84cf8 |
+ error_return);
|
|
|
d84cf8 |
+ }
|
|
|
d84cf8 |
|
|
|
d84cf8 |
return 0;
|
|
|
d84cf8 |
|
|
|
d84cf8 |
@@ -1880,6 +1896,8 @@ br_signer_init(xlator_t *this, br_private_t *priv)
|
|
|
d84cf8 |
|
|
|
d84cf8 |
GF_OPTION_INIT("expiry-time", priv->expiry_time, uint32, error_return);
|
|
|
d84cf8 |
GF_OPTION_INIT("brick-count", numbricks, int32, error_return);
|
|
|
d84cf8 |
+ GF_OPTION_INIT("signer-threads", priv->signer_th_count, uint32,
|
|
|
d84cf8 |
+ error_return);
|
|
|
d84cf8 |
|
|
|
d84cf8 |
ret = br_rate_limit_signer(this, priv->child_count, numbricks);
|
|
|
d84cf8 |
if (ret)
|
|
|
d84cf8 |
@@ -2210,6 +2228,15 @@ struct volume_options options[] = {
|
|
|
d84cf8 |
.description = "Pause/Resume scrub. Upon resume, scrubber "
|
|
|
d84cf8 |
"continues from where it left off.",
|
|
|
d84cf8 |
},
|
|
|
d84cf8 |
+ {
|
|
|
d84cf8 |
+ .key = {"signer-threads"},
|
|
|
d84cf8 |
+ .type = GF_OPTION_TYPE_INT,
|
|
|
d84cf8 |
+ .default_value = BR_WORKERS,
|
|
|
d84cf8 |
+ .op_version = {GD_OP_VERSION_7_0},
|
|
|
d84cf8 |
+ .flags = OPT_FLAG_SETTABLE,
|
|
|
d84cf8 |
+ .description = "Number of signing process threads. As a best "
|
|
|
d84cf8 |
+ "practice, set this to the number of processor cores",
|
|
|
d84cf8 |
+ },
|
|
|
d84cf8 |
{.key = {NULL}},
|
|
|
d84cf8 |
};
|
|
|
d84cf8 |
|
|
|
d84cf8 |
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.h b/xlators/features/bit-rot/src/bitd/bit-rot.h
|
|
|
d84cf8 |
index a4d4fd7..8ac7dcd 100644
|
|
|
d84cf8 |
--- a/xlators/features/bit-rot/src/bitd/bit-rot.h
|
|
|
d84cf8 |
+++ b/xlators/features/bit-rot/src/bitd/bit-rot.h
|
|
|
d84cf8 |
@@ -30,12 +30,6 @@
|
|
|
d84cf8 |
|
|
|
d84cf8 |
#include <openssl/sha.h>
|
|
|
d84cf8 |
|
|
|
d84cf8 |
-/**
|
|
|
d84cf8 |
- * TODO: make this configurable. As a best practice, set this to the
|
|
|
d84cf8 |
- * number of processor cores.
|
|
|
d84cf8 |
- */
|
|
|
d84cf8 |
-#define BR_WORKERS 4
|
|
|
d84cf8 |
-
|
|
|
d84cf8 |
typedef enum scrub_throttle {
|
|
|
d84cf8 |
BR_SCRUB_THROTTLE_VOID = -1,
|
|
|
d84cf8 |
BR_SCRUB_THROTTLE_LAZY = 0,
|
|
|
d84cf8 |
@@ -108,12 +102,12 @@ struct br_child {
|
|
|
d84cf8 |
typedef struct br_child br_child_t;
|
|
|
d84cf8 |
|
|
|
d84cf8 |
struct br_obj_n_workers {
|
|
|
d84cf8 |
- struct list_head objects; /* queue of objects expired from the
|
|
|
d84cf8 |
- timer wheel and ready to be picked
|
|
|
d84cf8 |
- up for signing */
|
|
|
d84cf8 |
- pthread_t workers[BR_WORKERS]; /* Threads which pick up the objects
|
|
|
d84cf8 |
- from the above queue and start
|
|
|
d84cf8 |
- signing each object */
|
|
|
d84cf8 |
+ struct list_head objects; /* queue of objects expired from the
|
|
|
d84cf8 |
+ timer wheel and ready to be picked
|
|
|
d84cf8 |
+ up for signing */
|
|
|
d84cf8 |
+ pthread_t *workers; /* Threads which pick up the objects
|
|
|
d84cf8 |
+ from the above queue and start
|
|
|
d84cf8 |
+ signing each object */
|
|
|
d84cf8 |
};
|
|
|
d84cf8 |
|
|
|
d84cf8 |
struct br_scrubber {
|
|
|
d84cf8 |
@@ -209,6 +203,8 @@ struct br_private {
|
|
|
d84cf8 |
|
|
|
d84cf8 |
uint32_t expiry_time; /* objects "wait" time */
|
|
|
d84cf8 |
|
|
|
d84cf8 |
+ uint32_t signer_th_count; /* Number of signing process threads */
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
tbf_t *tbf; /* token bucket filter */
|
|
|
d84cf8 |
|
|
|
d84cf8 |
gf_boolean_t iamscrubber; /* function as a fs scrubber */
|
|
|
d84cf8 |
diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h b/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h
|
|
|
d84cf8 |
index 40bcda1..9d93caf 100644
|
|
|
d84cf8 |
--- a/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h
|
|
|
d84cf8 |
+++ b/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h
|
|
|
d84cf8 |
@@ -29,6 +29,7 @@ enum br_mem_types {
|
|
|
d84cf8 |
gf_br_stub_mt_sigstub_t,
|
|
|
d84cf8 |
gf_br_mt_br_child_event_t,
|
|
|
d84cf8 |
gf_br_stub_mt_misc,
|
|
|
d84cf8 |
+ gf_br_mt_br_worker_t,
|
|
|
d84cf8 |
gf_br_stub_mt_end,
|
|
|
d84cf8 |
};
|
|
|
d84cf8 |
|
|
|
d84cf8 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-bitrot.c b/xlators/mgmt/glusterd/src/glusterd-bitrot.c
|
|
|
d84cf8 |
index c653249..f79af2d 100644
|
|
|
d84cf8 |
--- a/xlators/mgmt/glusterd/src/glusterd-bitrot.c
|
|
|
d84cf8 |
+++ b/xlators/mgmt/glusterd/src/glusterd-bitrot.c
|
|
|
d84cf8 |
@@ -34,6 +34,7 @@ const char *gd_bitrot_op_list[GF_BITROT_OPTION_TYPE_MAX] = {
|
|
|
d84cf8 |
[GF_BITROT_OPTION_TYPE_SCRUB_FREQ] = "scrub-frequency",
|
|
|
d84cf8 |
[GF_BITROT_OPTION_TYPE_SCRUB] = "scrub",
|
|
|
d84cf8 |
[GF_BITROT_OPTION_TYPE_EXPIRY_TIME] = "expiry-time",
|
|
|
d84cf8 |
+ [GF_BITROT_OPTION_TYPE_SIGNER_THREADS] = "signer-threads",
|
|
|
d84cf8 |
};
|
|
|
d84cf8 |
|
|
|
d84cf8 |
int
|
|
|
d84cf8 |
@@ -354,6 +355,81 @@ out:
|
|
|
d84cf8 |
return ret;
|
|
|
d84cf8 |
}
|
|
|
d84cf8 |
|
|
|
d84cf8 |
+static gf_boolean_t
|
|
|
d84cf8 |
+is_bitd_configure_noop(xlator_t *this, glusterd_volinfo_t *volinfo)
|
|
|
d84cf8 |
+{
|
|
|
d84cf8 |
+ gf_boolean_t noop = _gf_true;
|
|
|
d84cf8 |
+ glusterd_brickinfo_t *brickinfo = NULL;
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+ if (!glusterd_is_bitrot_enabled(volinfo))
|
|
|
d84cf8 |
+ goto out;
|
|
|
d84cf8 |
+ else if (volinfo->status != GLUSTERD_STATUS_STARTED)
|
|
|
d84cf8 |
+ goto out;
|
|
|
d84cf8 |
+ else {
|
|
|
d84cf8 |
+ cds_list_for_each_entry(brickinfo, &volinfo->bricks, brick_list)
|
|
|
d84cf8 |
+ {
|
|
|
d84cf8 |
+ if (!glusterd_is_local_brick(this, volinfo, brickinfo))
|
|
|
d84cf8 |
+ continue;
|
|
|
d84cf8 |
+ noop = _gf_false;
|
|
|
d84cf8 |
+ return noop;
|
|
|
d84cf8 |
+ }
|
|
|
d84cf8 |
+ }
|
|
|
d84cf8 |
+out:
|
|
|
d84cf8 |
+ return noop;
|
|
|
d84cf8 |
+}
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+static int
|
|
|
d84cf8 |
+glusterd_bitrot_signer_threads(glusterd_volinfo_t *volinfo, dict_t *dict,
|
|
|
d84cf8 |
+ char *key, char **op_errstr)
|
|
|
d84cf8 |
+{
|
|
|
d84cf8 |
+ int32_t ret = -1;
|
|
|
d84cf8 |
+ uint32_t signer_th_count = 0;
|
|
|
d84cf8 |
+ uint32_t existing_th_count = 0;
|
|
|
d84cf8 |
+ xlator_t *this = NULL;
|
|
|
d84cf8 |
+ glusterd_conf_t *priv = NULL;
|
|
|
d84cf8 |
+ char dkey[32] = {
|
|
|
d84cf8 |
+ 0,
|
|
|
d84cf8 |
+ };
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+ this = THIS;
|
|
|
d84cf8 |
+ GF_ASSERT(this);
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+ priv = this->private;
|
|
|
d84cf8 |
+ GF_VALIDATE_OR_GOTO(this->name, priv, out);
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+ ret = dict_get_uint32(dict, "signer-threads", &signer_th_count);
|
|
|
d84cf8 |
+ if (ret) {
|
|
|
d84cf8 |
+ gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_GET_FAILED,
|
|
|
d84cf8 |
+ "Unable to get bitrot signer thread count.");
|
|
|
d84cf8 |
+ goto out;
|
|
|
d84cf8 |
+ }
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+ ret = dict_get_uint32(volinfo->dict, key, &existing_th_count);
|
|
|
d84cf8 |
+ if (ret == 0 && signer_th_count == existing_th_count) {
|
|
|
d84cf8 |
+ goto out;
|
|
|
d84cf8 |
+ }
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+ snprintf(dkey, sizeof(dkey), "%d", signer_th_count);
|
|
|
d84cf8 |
+ ret = dict_set_dynstr_with_alloc(volinfo->dict, key, dkey);
|
|
|
d84cf8 |
+ if (ret) {
|
|
|
d84cf8 |
+ gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
|
|
|
d84cf8 |
+ "Failed to set option %s", key);
|
|
|
d84cf8 |
+ goto out;
|
|
|
d84cf8 |
+ }
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+ if (!is_bitd_configure_noop(this, volinfo)) {
|
|
|
d84cf8 |
+ ret = priv->bitd_svc.manager(&(priv->bitd_svc), NULL,
|
|
|
d84cf8 |
+ PROC_START_NO_WAIT);
|
|
|
d84cf8 |
+ if (ret) {
|
|
|
d84cf8 |
+ gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_BITDSVC_RECONF_FAIL,
|
|
|
d84cf8 |
+ "Failed to reconfigure bitrot services");
|
|
|
d84cf8 |
+ goto out;
|
|
|
d84cf8 |
+ }
|
|
|
d84cf8 |
+ }
|
|
|
d84cf8 |
+out:
|
|
|
d84cf8 |
+ return ret;
|
|
|
d84cf8 |
+}
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
static int
|
|
|
d84cf8 |
glusterd_bitrot_enable(glusterd_volinfo_t *volinfo, char **op_errstr)
|
|
|
d84cf8 |
{
|
|
|
d84cf8 |
@@ -594,6 +670,15 @@ glusterd_op_bitrot(dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|
|
d84cf8 |
volinfo, dict, "features.expiry-time", op_errstr);
|
|
|
d84cf8 |
if (ret)
|
|
|
d84cf8 |
goto out;
|
|
|
d84cf8 |
+ break;
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
+ case GF_BITROT_OPTION_TYPE_SIGNER_THREADS:
|
|
|
d84cf8 |
+ ret = glusterd_bitrot_signer_threads(
|
|
|
d84cf8 |
+ volinfo, dict, "features.signer-threads", op_errstr);
|
|
|
d84cf8 |
+ if (ret)
|
|
|
d84cf8 |
+ goto out;
|
|
|
d84cf8 |
+ break;
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
case GF_BITROT_CMD_SCRUB_STATUS:
|
|
|
d84cf8 |
case GF_BITROT_CMD_SCRUB_ONDEMAND:
|
|
|
d84cf8 |
break;
|
|
|
d84cf8 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
|
|
|
d84cf8 |
index 13f84ea..094a71f 100644
|
|
|
d84cf8 |
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
|
|
|
d84cf8 |
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
|
|
|
d84cf8 |
@@ -4658,6 +4658,12 @@ bitrot_option_handler(volgen_graph_t *graph, struct volopt_map_entry *vme,
|
|
|
d84cf8 |
return -1;
|
|
|
d84cf8 |
}
|
|
|
d84cf8 |
|
|
|
d84cf8 |
+ if (!strcmp(vme->option, "signer-threads")) {
|
|
|
d84cf8 |
+ ret = xlator_set_fixed_option(xl, "signer-threads", vme->value);
|
|
|
d84cf8 |
+ if (ret)
|
|
|
d84cf8 |
+ return -1;
|
|
|
d84cf8 |
+ }
|
|
|
d84cf8 |
+
|
|
|
d84cf8 |
return ret;
|
|
|
d84cf8 |
}
|
|
|
d84cf8 |
|
|
|
d84cf8 |
@@ -4940,18 +4946,18 @@ glusterd_prepare_shd_volume_options_for_tier(glusterd_volinfo_t *volinfo,
|
|
|
d84cf8 |
dict_t *set_dict)
|
|
|
d84cf8 |
{
|
|
|
d84cf8 |
int ret = -1;
|
|
|
d84cf8 |
- char *key = NULL;
|
|
|
d84cf8 |
+ char *key = NULL;
|
|
|
d84cf8 |
|
|
|
d84cf8 |
- key = volgen_get_shd_key (volinfo->tier_info.cold_type);
|
|
|
d84cf8 |
+ key = volgen_get_shd_key(volinfo->tier_info.cold_type);
|
|
|
d84cf8 |
if (key) {
|
|
|
d84cf8 |
- ret = dict_set_str (set_dict, key, "enable");
|
|
|
d84cf8 |
+ ret = dict_set_str(set_dict, key, "enable");
|
|
|
d84cf8 |
if (ret)
|
|
|
d84cf8 |
goto out;
|
|
|
d84cf8 |
}
|
|
|
d84cf8 |
|
|
|
d84cf8 |
- key = volgen_get_shd_key (volinfo->tier_info.hot_type);
|
|
|
d84cf8 |
+ key = volgen_get_shd_key(volinfo->tier_info.hot_type);
|
|
|
d84cf8 |
if (key) {
|
|
|
d84cf8 |
- ret = dict_set_str (set_dict, key, "enable");
|
|
|
d84cf8 |
+ ret = dict_set_str(set_dict, key, "enable");
|
|
|
d84cf8 |
if (ret)
|
|
|
d84cf8 |
goto out;
|
|
|
d84cf8 |
}
|
|
|
d84cf8 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
|
|
|
d84cf8 |
index 9001b88..62acadf 100644
|
|
|
d84cf8 |
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
|
|
|
d84cf8 |
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
|
|
|
d84cf8 |
@@ -3379,6 +3379,15 @@ struct volopt_map_entry glusterd_volopt_map[] = {
|
|
|
d84cf8 |
.op_version = GD_OP_VERSION_3_7_0,
|
|
|
d84cf8 |
.type = NO_DOC,
|
|
|
d84cf8 |
},
|
|
|
d84cf8 |
+ {
|
|
|
d84cf8 |
+ .key = "features.signer-threads",
|
|
|
d84cf8 |
+ .voltype = "features/bit-rot",
|
|
|
d84cf8 |
+ .value = BR_WORKERS,
|
|
|
d84cf8 |
+ .option = "signer-threads",
|
|
|
d84cf8 |
+ .op_version = GD_OP_VERSION_7_0,
|
|
|
d84cf8 |
+ .type = NO_DOC,
|
|
|
d84cf8 |
+ },
|
|
|
d84cf8 |
+ /* Upcall translator options */
|
|
|
d84cf8 |
/* Upcall translator options */
|
|
|
d84cf8 |
{
|
|
|
d84cf8 |
.key = "features.cache-invalidation",
|
|
|
d84cf8 |
--
|
|
|
d84cf8 |
1.8.3.1
|
|
|
d84cf8 |
|