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>
This commit is contained in:
Sachin Pandit 2015-03-16 13:12:12 +05:30 committed by Krishnan Parthasarathi
parent df26c5e162
commit da48df4e91
5 changed files with 69 additions and 32 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);