|
|
a3470f |
From 69e6933898a37ef7c929b2d4b5561e5e3a407be4 Mon Sep 17 00:00:00 2001
|
|
|
a3470f |
From: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
a3470f |
Date: Thu, 16 Aug 2018 17:04:22 +0530
|
|
|
a3470f |
Subject: [PATCH 353/359] snapshot/handshake: store description after strdup
|
|
|
a3470f |
|
|
|
a3470f |
problem:
|
|
|
a3470f |
During a handshake, when we import a friend data
|
|
|
a3470f |
snap description variable was just referenced to
|
|
|
a3470f |
dictionary value.
|
|
|
a3470f |
|
|
|
a3470f |
Solution:
|
|
|
a3470f |
snap description should have a separate memory allocated
|
|
|
a3470f |
through gf_strdup
|
|
|
a3470f |
|
|
|
a3470f |
>Change-Id: I94da0c57919e1228919231d1563a001362b100b8
|
|
|
a3470f |
>fixes: bz#1618004
|
|
|
a3470f |
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
a3470f |
|
|
|
a3470f |
upstream patch: https://review.gluster.org/#/c/glusterfs/+/20747/
|
|
|
a3470f |
|
|
|
a3470f |
Change-Id: I94da0c57919e1228919231d1563a001362b100b8
|
|
|
a3470f |
BUG: 1615578
|
|
|
a3470f |
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
|
|
|
a3470f |
Reviewed-on: https://code.engineering.redhat.com/gerrit/147521
|
|
|
a3470f |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
a3470f |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
a3470f |
---
|
|
|
a3470f |
...-1618004-fix-memory-corruption-in-snap-import.t | 48 ++++++++++++++++++++++
|
|
|
a3470f |
.../mgmt/glusterd/src/glusterd-snapshot-utils.c | 17 ++++++--
|
|
|
a3470f |
2 files changed, 62 insertions(+), 3 deletions(-)
|
|
|
a3470f |
create mode 100644 tests/bugs/snapshot/bug-1618004-fix-memory-corruption-in-snap-import.t
|
|
|
a3470f |
|
|
|
a3470f |
diff --git a/tests/bugs/snapshot/bug-1618004-fix-memory-corruption-in-snap-import.t b/tests/bugs/snapshot/bug-1618004-fix-memory-corruption-in-snap-import.t
|
|
|
a3470f |
new file mode 100644
|
|
|
a3470f |
index 0000000..a2c004e
|
|
|
a3470f |
--- /dev/null
|
|
|
a3470f |
+++ b/tests/bugs/snapshot/bug-1618004-fix-memory-corruption-in-snap-import.t
|
|
|
a3470f |
@@ -0,0 +1,48 @@
|
|
|
a3470f |
+#!/bin/bash
|
|
|
a3470f |
+
|
|
|
a3470f |
+. $(dirname $0)/../../include.rc
|
|
|
a3470f |
+. $(dirname $0)/../../volume.rc
|
|
|
a3470f |
+. $(dirname $0)/../../snapshot.rc
|
|
|
a3470f |
+. $(dirname $0)/../../cluster.rc
|
|
|
a3470f |
+
|
|
|
a3470f |
+function get_volume_info ()
|
|
|
a3470f |
+{
|
|
|
a3470f |
+ local var=$1
|
|
|
a3470f |
+ $CLI_1 volume info $V0 | grep "^$var" | sed 's/.*: //'
|
|
|
a3470f |
+}
|
|
|
a3470f |
+
|
|
|
a3470f |
+cleanup;
|
|
|
a3470f |
+
|
|
|
a3470f |
+TEST verify_lvm_version
|
|
|
a3470f |
+TEST launch_cluster 2
|
|
|
a3470f |
+TEST setup_lvm 2
|
|
|
a3470f |
+
|
|
|
a3470f |
+TEST $CLI_1 peer probe $H2;
|
|
|
a3470f |
+EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count;
|
|
|
a3470f |
+
|
|
|
a3470f |
+TEST $CLI_1 volume create $V0 $H1:$L1 $H2:$L2
|
|
|
a3470f |
+EXPECT "$V0" get_volume_info 'Volume Name';
|
|
|
a3470f |
+EXPECT 'Created' get_volume_info 'Status';
|
|
|
a3470f |
+
|
|
|
a3470f |
+TEST $CLI_1 volume start $V0
|
|
|
a3470f |
+EXPECT 'Started' get_volume_info 'Status';
|
|
|
a3470f |
+
|
|
|
a3470f |
+
|
|
|
a3470f |
+# Setting system limit
|
|
|
a3470f |
+TEST $CLI_1 snapshot config activate-on-create enable
|
|
|
a3470f |
+
|
|
|
a3470f |
+TEST $CLI_1 snapshot create snap1 $V0 no-timestamp description "test"
|
|
|
a3470f |
+TEST kill_glusterd 1
|
|
|
a3470f |
+#deactivate snapshot for changing snap version, so that handshake will
|
|
|
a3470f |
+#happen when glusterd is restarted
|
|
|
a3470f |
+TEST $CLI_2 snapshot deactivate snap1
|
|
|
a3470f |
+TEST start_glusterd 1
|
|
|
a3470f |
+
|
|
|
a3470f |
+#Wait till handshake complete
|
|
|
a3470f |
+EXPECT_WITHIN ${PROCESS_UP_TIMEOUT} 'Stopped' snapshot_status snap1
|
|
|
a3470f |
+
|
|
|
a3470f |
+#Delete the snapshot, without this fix, delete will lead to assertion failure
|
|
|
a3470f |
+$CLI_1 snapshot delete all
|
|
|
a3470f |
+EXPECT '0' get_snap_count CLI_1;
|
|
|
a3470f |
+cleanup;
|
|
|
a3470f |
+
|
|
|
a3470f |
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
|
|
|
a3470f |
index ad206f6..48cf326 100644
|
|
|
a3470f |
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
|
|
|
a3470f |
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
|
|
|
a3470f |
@@ -766,7 +766,7 @@ glusterd_add_snap_to_dict (glusterd_snap_t *snap, dict_t *peer_data,
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
if (snap->description) {
|
|
|
a3470f |
- snprintf (buf, sizeof(buf), "%s.snapid", prefix);
|
|
|
a3470f |
+ snprintf (buf, sizeof(buf), "%s.description", prefix);
|
|
|
a3470f |
ret = dict_set_dynstr_with_alloc (peer_data, buf,
|
|
|
a3470f |
snap->description);
|
|
|
a3470f |
if (ret) {
|
|
|
a3470f |
@@ -1551,6 +1551,7 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
|
|
|
a3470f |
{
|
|
|
a3470f |
char buf[NAME_MAX] = "";
|
|
|
a3470f |
char prefix[NAME_MAX] = "";
|
|
|
a3470f |
+ char *description = NULL;
|
|
|
a3470f |
dict_t *dict = NULL;
|
|
|
a3470f |
glusterd_snap_t *snap = NULL;
|
|
|
a3470f |
glusterd_volinfo_t *snap_vol = NULL;
|
|
|
a3470f |
@@ -1590,8 +1591,18 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
|
|
|
a3470f |
strncpy (snap->snapname, peer_snap_name, sizeof (snap->snapname) - 1);
|
|
|
a3470f |
gf_uuid_parse (peer_snap_id, snap->snap_id);
|
|
|
a3470f |
|
|
|
a3470f |
- snprintf (buf, sizeof(buf), "%s.snapid", prefix);
|
|
|
a3470f |
- ret = dict_get_str (peer_data, buf, &snap->description);
|
|
|
a3470f |
+ snprintf (buf, sizeof(buf), "%s.description", prefix);
|
|
|
a3470f |
+ ret = dict_get_str (peer_data, buf, &description);
|
|
|
a3470f |
+ if (ret == 0 && description) {
|
|
|
a3470f |
+ snap->description = gf_strdup (description);
|
|
|
a3470f |
+ if (snap->description == NULL) {
|
|
|
a3470f |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
a3470f |
+ GD_MSG_SNAP_CREATION_FAIL,
|
|
|
a3470f |
+ "Saving the Snapshot Description Failed");
|
|
|
a3470f |
+ ret = -1;
|
|
|
a3470f |
+ goto out;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+ }
|
|
|
a3470f |
|
|
|
a3470f |
snprintf (buf, sizeof(buf), "%s.time_stamp", prefix);
|
|
|
a3470f |
ret = dict_get_int64 (peer_data, buf, &snap->time_stamp);
|
|
|
a3470f |
--
|
|
|
a3470f |
1.8.3.1
|
|
|
a3470f |
|