|
|
9ae3f9 |
From 759c12fc016a6399bb179aa0f930602c87d1e0f8 Mon Sep 17 00:00:00 2001
|
|
|
9ae3f9 |
From: Barak Sason Rofman <bsasonro@redhat.com>
|
|
|
9ae3f9 |
Date: Tue, 24 Nov 2020 12:56:10 +0200
|
|
|
9ae3f9 |
Subject: [PATCH 480/480] DHT/Rebalance - Ensure Rebalance reports status only
|
|
|
9ae3f9 |
once upon stopping
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
Upon issuing rebalance stop command, the status of rebalance is being
|
|
|
9ae3f9 |
logged twice to the log file, which can sometime result in an
|
|
|
9ae3f9 |
inconsistent reports (one report states status stopped, while the other
|
|
|
9ae3f9 |
may report something else).
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
This fix ensures rebalance reports it's status only once and that the
|
|
|
9ae3f9 |
correct status is being reported.
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
Upstream:
|
|
|
9ae3f9 |
> Reviewed-on: https://github.com/gluster/glusterfs/pull/1783
|
|
|
9ae3f9 |
> fixes: #1782
|
|
|
9ae3f9 |
> Change-Id: Id3206edfad33b3db60e9df8e95a519928dc7cb37
|
|
|
9ae3f9 |
> Signed-off-by: Barak Sason Rofman bsasonro@redhat.com
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
BUG: 1286171
|
|
|
9ae3f9 |
Change-Id: Id3206edfad33b3db60e9df8e95a519928dc7cb37
|
|
|
9ae3f9 |
Signed-off-by: Barak Sason Rofman <bsasonro@redhat.com>
|
|
|
9ae3f9 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/218953
|
|
|
9ae3f9 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
9ae3f9 |
Reviewed-by: Csaba Henk <chenk@redhat.com>
|
|
|
9ae3f9 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
9ae3f9 |
---
|
|
|
9ae3f9 |
tests/bugs/distribute/bug-1286171.t | 75 +++++++++++++++++++++++++++++++++
|
|
|
9ae3f9 |
xlators/cluster/dht/src/dht-common.c | 2 +-
|
|
|
9ae3f9 |
xlators/cluster/dht/src/dht-common.h | 2 +-
|
|
|
9ae3f9 |
xlators/cluster/dht/src/dht-rebalance.c | 63 ++++++++++++++-------------
|
|
|
9ae3f9 |
4 files changed, 108 insertions(+), 34 deletions(-)
|
|
|
9ae3f9 |
create mode 100644 tests/bugs/distribute/bug-1286171.t
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
diff --git a/tests/bugs/distribute/bug-1286171.t b/tests/bugs/distribute/bug-1286171.t
|
|
|
9ae3f9 |
new file mode 100644
|
|
|
9ae3f9 |
index 0000000..a2ca36f
|
|
|
9ae3f9 |
--- /dev/null
|
|
|
9ae3f9 |
+++ b/tests/bugs/distribute/bug-1286171.t
|
|
|
9ae3f9 |
@@ -0,0 +1,75 @@
|
|
|
9ae3f9 |
+#!/bin/bash
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+. $(dirname $0)/../../include.rc
|
|
|
9ae3f9 |
+. $(dirname $0)/../../cluster.rc
|
|
|
9ae3f9 |
+. $(dirname $0)/../../volume.rc
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+# Initialize
|
|
|
9ae3f9 |
+#------------------------------------------------------------
|
|
|
9ae3f9 |
+cleanup;
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+volname=bug-1286171
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+# Start glusterd
|
|
|
9ae3f9 |
+TEST glusterd;
|
|
|
9ae3f9 |
+TEST pidof glusterd;
|
|
|
9ae3f9 |
+TEST $CLI volume info;
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+# Create a volume
|
|
|
9ae3f9 |
+TEST $CLI volume create $volname $H0:$B0/${volname}{1,2}
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+# Verify volume creation
|
|
|
9ae3f9 |
+EXPECT "$volname" volinfo_field $volname 'Volume Name';
|
|
|
9ae3f9 |
+EXPECT 'Created' volinfo_field $volname 'Status';
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+# Start volume and verify successful start
|
|
|
9ae3f9 |
+TEST $CLI volume start $volname;
|
|
|
9ae3f9 |
+EXPECT 'Started' volinfo_field $volname 'Status';
|
|
|
9ae3f9 |
+TEST glusterfs --volfile-id=$volname --volfile-server=$H0 --entry-timeout=0 $M0;
|
|
|
9ae3f9 |
+#------------------------------------------------------------
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+# Create a nested dir structure and some file under MP
|
|
|
9ae3f9 |
+cd $M0;
|
|
|
9ae3f9 |
+for i in {1..5}
|
|
|
9ae3f9 |
+do
|
|
|
9ae3f9 |
+ mkdir dir$i
|
|
|
9ae3f9 |
+ cd dir$i
|
|
|
9ae3f9 |
+ for j in {1..5}
|
|
|
9ae3f9 |
+ do
|
|
|
9ae3f9 |
+ mkdir dir$i$j
|
|
|
9ae3f9 |
+ cd dir$i$j
|
|
|
9ae3f9 |
+ for k in {1..5}
|
|
|
9ae3f9 |
+ do
|
|
|
9ae3f9 |
+ mkdir dir$i$j$k
|
|
|
9ae3f9 |
+ cd dir$i$j$k
|
|
|
9ae3f9 |
+ touch {1..300}
|
|
|
9ae3f9 |
+ cd ..
|
|
|
9ae3f9 |
+ done
|
|
|
9ae3f9 |
+ touch {1..300}
|
|
|
9ae3f9 |
+ cd ..
|
|
|
9ae3f9 |
+ done
|
|
|
9ae3f9 |
+ touch {1..300}
|
|
|
9ae3f9 |
+ cd ..
|
|
|
9ae3f9 |
+done
|
|
|
9ae3f9 |
+touch {1..300}
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+# Add-brick and start rebalance
|
|
|
9ae3f9 |
+TEST $CLI volume add-brick $volname $H0:$B0/${volname}4;
|
|
|
9ae3f9 |
+TEST $CLI volume rebalance $volname start;
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+# Let rebalance run for a while
|
|
|
9ae3f9 |
+sleep 5
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+# Stop rebalance
|
|
|
9ae3f9 |
+TEST $CLI volume rebalance $volname stop;
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+# Allow rebalance to stop
|
|
|
9ae3f9 |
+sleep 5
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+# Examine the logfile for errors
|
|
|
9ae3f9 |
+cd /var/log/glusterfs;
|
|
|
9ae3f9 |
+failures=`grep "failures:" ${volname}-rebalance.log | tail -1 | sed 's/.*failures: //; s/,.*//'`;
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+TEST [ $failures == 0 ];
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+cleanup;
|
|
|
9ae3f9 |
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
|
|
|
9ae3f9 |
index 23cc80c..4db89df 100644
|
|
|
9ae3f9 |
--- a/xlators/cluster/dht/src/dht-common.c
|
|
|
9ae3f9 |
+++ b/xlators/cluster/dht/src/dht-common.c
|
|
|
9ae3f9 |
@@ -10969,7 +10969,7 @@ dht_notify(xlator_t *this, int event, void *data, ...)
|
|
|
9ae3f9 |
if ((cmd == GF_DEFRAG_CMD_STATUS) ||
|
|
|
9ae3f9 |
(cmd == GF_DEFRAG_CMD_STATUS_TIER) ||
|
|
|
9ae3f9 |
(cmd == GF_DEFRAG_CMD_DETACH_STATUS))
|
|
|
9ae3f9 |
- gf_defrag_status_get(conf, output);
|
|
|
9ae3f9 |
+ gf_defrag_status_get(conf, output, _gf_false);
|
|
|
9ae3f9 |
else if (cmd == GF_DEFRAG_CMD_START_DETACH_TIER)
|
|
|
9ae3f9 |
gf_defrag_start_detach_tier(defrag);
|
|
|
9ae3f9 |
else if (cmd == GF_DEFRAG_CMD_DETACH_START)
|
|
|
9ae3f9 |
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
|
|
|
9ae3f9 |
index 9ec5b51..92f1b89 100644
|
|
|
9ae3f9 |
--- a/xlators/cluster/dht/src/dht-common.h
|
|
|
9ae3f9 |
+++ b/xlators/cluster/dht/src/dht-common.h
|
|
|
9ae3f9 |
@@ -1252,7 +1252,7 @@ dht_fxattrop_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
9ae3f9 |
int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata);
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
int
|
|
|
9ae3f9 |
-gf_defrag_status_get(dht_conf_t *conf, dict_t *dict);
|
|
|
9ae3f9 |
+gf_defrag_status_get(dht_conf_t *conf, dict_t *dict, gf_boolean_t log_status);
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
void
|
|
|
9ae3f9 |
gf_defrag_set_pause_state(gf_tier_conf_t *tier_conf, tier_pause_state_t state);
|
|
|
9ae3f9 |
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
9ae3f9 |
index d49a719..16ac16c 100644
|
|
|
9ae3f9 |
--- a/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
9ae3f9 |
+++ b/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
9ae3f9 |
@@ -2720,7 +2720,6 @@ gf_defrag_migrate_single_file(void *opaque)
|
|
|
9ae3f9 |
iatt_ptr = &entry->d_stat;
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
if (defrag->defrag_status != GF_DEFRAG_STATUS_STARTED) {
|
|
|
9ae3f9 |
- ret = -1;
|
|
|
9ae3f9 |
goto out;
|
|
|
9ae3f9 |
}
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
@@ -3833,7 +3832,6 @@ gf_defrag_fix_layout(xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
|
|
|
9ae3f9 |
list_for_each_entry_safe(entry, tmp, &entries.list, list)
|
|
|
9ae3f9 |
{
|
|
|
9ae3f9 |
if (defrag->defrag_status != GF_DEFRAG_STATUS_STARTED) {
|
|
|
9ae3f9 |
- ret = 1;
|
|
|
9ae3f9 |
goto out;
|
|
|
9ae3f9 |
}
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
@@ -4863,7 +4861,7 @@ out:
|
|
|
9ae3f9 |
LOCK(&defrag->lock);
|
|
|
9ae3f9 |
{
|
|
|
9ae3f9 |
status = dict_new();
|
|
|
9ae3f9 |
- gf_defrag_status_get(conf, status);
|
|
|
9ae3f9 |
+ gf_defrag_status_get(conf, status, _gf_true);
|
|
|
9ae3f9 |
if (ctx && ctx->notify)
|
|
|
9ae3f9 |
ctx->notify(GF_EN_DEFRAG_STATUS, status);
|
|
|
9ae3f9 |
if (status)
|
|
|
9ae3f9 |
@@ -4998,7 +4996,7 @@ out:
|
|
|
9ae3f9 |
}
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
int
|
|
|
9ae3f9 |
-gf_defrag_status_get(dht_conf_t *conf, dict_t *dict)
|
|
|
9ae3f9 |
+gf_defrag_status_get(dht_conf_t *conf, dict_t *dict, gf_boolean_t log_status)
|
|
|
9ae3f9 |
{
|
|
|
9ae3f9 |
int ret = 0;
|
|
|
9ae3f9 |
uint64_t files = 0;
|
|
|
9ae3f9 |
@@ -5095,34 +5093,35 @@ gf_defrag_status_get(dht_conf_t *conf, dict_t *dict)
|
|
|
9ae3f9 |
gf_log(THIS->name, GF_LOG_WARNING, "failed to set time-left");
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
log:
|
|
|
9ae3f9 |
- switch (defrag->defrag_status) {
|
|
|
9ae3f9 |
- case GF_DEFRAG_STATUS_NOT_STARTED:
|
|
|
9ae3f9 |
- status = "not started";
|
|
|
9ae3f9 |
- break;
|
|
|
9ae3f9 |
- case GF_DEFRAG_STATUS_STARTED:
|
|
|
9ae3f9 |
- status = "in progress";
|
|
|
9ae3f9 |
- break;
|
|
|
9ae3f9 |
- case GF_DEFRAG_STATUS_STOPPED:
|
|
|
9ae3f9 |
- status = "stopped";
|
|
|
9ae3f9 |
- break;
|
|
|
9ae3f9 |
- case GF_DEFRAG_STATUS_COMPLETE:
|
|
|
9ae3f9 |
- status = "completed";
|
|
|
9ae3f9 |
- break;
|
|
|
9ae3f9 |
- case GF_DEFRAG_STATUS_FAILED:
|
|
|
9ae3f9 |
- status = "failed";
|
|
|
9ae3f9 |
- break;
|
|
|
9ae3f9 |
- default:
|
|
|
9ae3f9 |
- break;
|
|
|
9ae3f9 |
- }
|
|
|
9ae3f9 |
+ if (log_status) {
|
|
|
9ae3f9 |
+ switch (defrag->defrag_status) {
|
|
|
9ae3f9 |
+ case GF_DEFRAG_STATUS_NOT_STARTED:
|
|
|
9ae3f9 |
+ status = "not started";
|
|
|
9ae3f9 |
+ break;
|
|
|
9ae3f9 |
+ case GF_DEFRAG_STATUS_STARTED:
|
|
|
9ae3f9 |
+ status = "in progress";
|
|
|
9ae3f9 |
+ break;
|
|
|
9ae3f9 |
+ case GF_DEFRAG_STATUS_STOPPED:
|
|
|
9ae3f9 |
+ status = "stopped";
|
|
|
9ae3f9 |
+ break;
|
|
|
9ae3f9 |
+ case GF_DEFRAG_STATUS_COMPLETE:
|
|
|
9ae3f9 |
+ status = "completed";
|
|
|
9ae3f9 |
+ break;
|
|
|
9ae3f9 |
+ case GF_DEFRAG_STATUS_FAILED:
|
|
|
9ae3f9 |
+ status = "failed";
|
|
|
9ae3f9 |
+ break;
|
|
|
9ae3f9 |
+ default:
|
|
|
9ae3f9 |
+ break;
|
|
|
9ae3f9 |
+ }
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
- gf_msg(THIS->name, GF_LOG_INFO, 0, DHT_MSG_REBALANCE_STATUS,
|
|
|
9ae3f9 |
- "Rebalance is %s. Time taken is %.2f secs", status, elapsed);
|
|
|
9ae3f9 |
- gf_msg(THIS->name, GF_LOG_INFO, 0, DHT_MSG_REBALANCE_STATUS,
|
|
|
9ae3f9 |
- "Files migrated: %" PRIu64 ", size: %" PRIu64 ", lookups: %" PRIu64
|
|
|
9ae3f9 |
- ", failures: %" PRIu64
|
|
|
9ae3f9 |
- ", skipped: "
|
|
|
9ae3f9 |
- "%" PRIu64,
|
|
|
9ae3f9 |
- files, size, lookup, failures, skipped);
|
|
|
9ae3f9 |
+ gf_msg("DHT", GF_LOG_INFO, 0, DHT_MSG_REBALANCE_STATUS,
|
|
|
9ae3f9 |
+ "Rebalance is %s. Time taken is %.2f secs "
|
|
|
9ae3f9 |
+ "Files migrated: %" PRIu64 ", size: %" PRIu64
|
|
|
9ae3f9 |
+ ", lookups: %" PRIu64 ", failures: %" PRIu64
|
|
|
9ae3f9 |
+ ", skipped: "
|
|
|
9ae3f9 |
+ "%" PRIu64,
|
|
|
9ae3f9 |
+ status, elapsed, files, size, lookup, failures, skipped);
|
|
|
9ae3f9 |
+ }
|
|
|
9ae3f9 |
out:
|
|
|
9ae3f9 |
return 0;
|
|
|
9ae3f9 |
}
|
|
|
9ae3f9 |
@@ -5299,7 +5298,7 @@ gf_defrag_stop(dht_conf_t *conf, gf_defrag_status_t status, dict_t *output)
|
|
|
9ae3f9 |
defrag->defrag_status = status;
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
if (output)
|
|
|
9ae3f9 |
- gf_defrag_status_get(conf, output);
|
|
|
9ae3f9 |
+ gf_defrag_status_get(conf, output, _gf_false);
|
|
|
9ae3f9 |
ret = 0;
|
|
|
9ae3f9 |
out:
|
|
|
9ae3f9 |
gf_msg_debug("", 0, "Returning %d", ret);
|
|
|
9ae3f9 |
--
|
|
|
9ae3f9 |
1.8.3.1
|
|
|
9ae3f9 |
|