summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSachin Pandit <spandit@redhat.com>2015-03-16 13:12:12 +0530
committerKrishnan Parthasarathi <kparthas@redhat.com>2015-04-10 08:19:09 +0000
commitda48df4e91b69b8f586d658de9573287cad2ce64 (patch)
tree5046c2ad5de3fbd22cc99879cd52dce8f904f36c
parentdf26c5e162b2ff413ff551119346e239df5ed663 (diff)
glusterd/snapshot : While snapshot restore, compute quota checksum.
Problem : During snapshot restore we anyways copy the quota conf file after that we need to compute the checksum for that. If not, there might be a checksum mismatch during glusterd handshake. Solution : Compute a checksum file for quota conf file if its present. Change-Id: Ic4a6567c6ede9923443abf4ca59380679be88094 BUG: 1202436 Signed-off-by: Sachin Pandit <spandit@redhat.com> Reviewed-on: http://review.gluster.org/9901 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Avra Sengupta <asengupt@redhat.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
-rw-r--r--tests/bugs/snapshot/bug-1202436-calculate-quota-cksum-during-snap-restore.t39
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c31
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c27
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c1
5 files changed, 69 insertions, 32 deletions
diff --git a/tests/bugs/snapshot/bug-1202436-calculate-quota-cksum-during-snap-restore.t b/tests/bugs/snapshot/bug-1202436-calculate-quota-cksum-during-snap-restore.t
new file mode 100644
index 00000000000..300b300febe
--- /dev/null
+++ b/tests/bugs/snapshot/bug-1202436-calculate-quota-cksum-during-snap-restore.t
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../cluster.rc
+. $(dirname $0)/../../volume.rc
+. $(dirname $0)/../../snapshot.rc
+
+cleanup;
+
+TEST verify_lvm_version
+TEST launch_cluster 2
+TEST setup_lvm 1
+
+TEST $CLI_1 volume create $V0 $H1:$L1
+EXPECT 'Created' volinfo_field $V0 'Status'
+
+TEST $CLI_1 volume start $V0
+EXPECT 'Started' volinfo_field $V0 'Status'
+
+# Quota is not working with cluster test framework
+# Need to check why, Until then commenting out this
+#TEST $CLI_1 volume quota $V0 enable
+#EXPECT 'on' volinfo_field $V0 'features.quota'
+
+TEST $CLI_1 snapshot create ${V0}_snap $V0
+EXPECT '1' get_snap_count CLI_1 $V0
+
+TEST $CLI_1 volume stop $V0
+EXPECT 'Stopped' volinfo_field $V0 'Status'
+
+TEST $CLI_1 snapshot restore $($CLI_1 snapshot list)
+EXPECT '0' get_snap_count CLI_1 $V0
+
+TEST $CLI_1 peer probe $H2
+EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count
+
+cleanup;
+
+
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
index 8819f69c594..1da8a5b4490 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
@@ -3054,7 +3054,8 @@ out:
int32_t
glusterd_copy_quota_files (glusterd_volinfo_t *src_vol,
- glusterd_volinfo_t *dest_vol) {
+ glusterd_volinfo_t *dest_vol,
+ gf_boolean_t *conf_present) {
int32_t ret = -1;
char src_dir[PATH_MAX] = "";
@@ -3104,33 +3105,7 @@ glusterd_copy_quota_files (glusterd_volinfo_t *src_vol,
goto out;
}
- ret = snprintf (src_path, sizeof (src_path), "%s/quota.cksum",
- src_dir);
- if (ret < 0)
- goto out;
-
- /* If quota.conf is present and quota.cksum is not present, then
- * that scenario is considered as invalid, hence error out.
- */
- ret = lstat (src_path, &stbuf);
- if (ret) {
- ret = -1;
- gf_log (this->name, GF_LOG_ERROR, "%s not found", src_path);
- goto out;
- }
-
- ret = snprintf (dest_path, sizeof (dest_path), "%s/quota.cksum",
- dest_dir);
- if (ret < 0)
- goto out;
-
- ret = glusterd_copy_file (src_path, dest_path);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to copy %s in %s",
- src_path, dest_path);
- goto out;
- }
-
+ *conf_present = _gf_true;
out:
return ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h
index 07a9709b65f..68906dcf59e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h
@@ -96,7 +96,8 @@ glusterd_restore_geo_rep_files (glusterd_volinfo_t *snap_vol);
int32_t
glusterd_copy_quota_files (glusterd_volinfo_t *src_vol,
- glusterd_volinfo_t *dest_vol);
+ glusterd_volinfo_t *dest_vol,
+ gf_boolean_t *conf_present);
int
glusterd_snap_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict);
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 6d1f79b65d0..cdd19cd354d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -4707,7 +4707,8 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,
int32_t brick_count = 0;
xlator_t *this = NULL;
int64_t brick_order = 0;
- char *clonename = NULL;
+ char *clonename = NULL;
+ gf_boolean_t conf_present = _gf_false;
this = THIS;
GF_ASSERT (this);
@@ -4834,7 +4835,7 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,
goto out;
}
- ret = glusterd_copy_quota_files (origin_vol, snap_vol);
+ ret = glusterd_copy_quota_files (origin_vol, snap_vol, &conf_present);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Failed to copy quota "
"config and cksum for volume %s", origin_vol->volname);
@@ -8781,6 +8782,7 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,
glusterd_conf_t *conf = NULL;
glusterd_volinfo_t *temp_volinfo = NULL;
glusterd_volinfo_t *voliter = NULL;
+ gf_boolean_t conf_present = _gf_false;
this = THIS;
GF_ASSERT (this);
@@ -8870,7 +8872,7 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,
snap_vol->snapshot->snapname);
}
- ret = glusterd_copy_quota_files (snap_vol, orig_vol);
+ ret = glusterd_copy_quota_files (snap_vol, orig_vol, &conf_present);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Failed to restore "
"quota files for snap %s",
@@ -8878,6 +8880,25 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,
goto out;
}
+ if (conf_present) {
+ /* TO calculate checksum of quota conf we need to send
+ * second argument as _gf_true
+ */
+ ret = glusterd_compute_cksum (new_volinfo, _gf_true);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to compute "
+ "checksum for quota conf file");
+ goto out;
+ }
+
+ ret = glusterd_store_save_quota_version_and_cksum (new_volinfo);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ "store quota version and cksum");
+ goto out;
+ }
+ }
+
/* New volinfo always shows the status as created. Therefore
* set the status to the original volume's status. */
glusterd_set_volume_status (new_volinfo, orig_vol->status);
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 4863733f84c..468b3c0af45 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -560,6 +560,7 @@ glusterd_volinfo_dup (glusterd_volinfo_t *volinfo,
new_volinfo->transport_type = volinfo->transport_type;
new_volinfo->brick_count = volinfo->brick_count;
new_volinfo->tier_info = volinfo->tier_info;
+ new_volinfo->quota_conf_version = volinfo->quota_conf_version;
dict_copy (volinfo->dict, new_volinfo->dict);
dict_copy (volinfo->gsync_slaves, new_volinfo->gsync_slaves);