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