glusterd: validate performance.nfs.* option values during volume set stage
PROBLEM: performance.nfs.* option values (which are of type boolean) are not validated during the stage phase of 'volume set'. The result - nfs graph generation fails during commit phase, AFTER the option and its (invalid) value have been placed in volinfo->dict. CAUSE: nfsperfxl_option_handler() - the function that validates the values of performance.nfs.* options - never receives the (key,value) pair that needs to be set, for validation during 'volume set' stage. FIX: In build_nfs_graph(), copy the (mod_)dict containing the (option,value) parameters into set_dict before attempting to build the client graph for the volume on which the operation is being performed. Of course, an easier way out would be to simply do a 'volume reset' and pretend nothing wrong happened! Change-Id: I56b17d0239d58a9e0b7798933a3c8451e2675b69 BUG: 949930 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-on: http://review.gluster.org/4814 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
This commit is contained in:
parent
dcebed550e
commit
9d74f78141
27
tests/bugs/bug-949930.t
Normal file
27
tests/bugs/bug-949930.t
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
. $(dirname $0)/../include.rc
|
||||||
|
. $(dirname $0)/../volume.rc
|
||||||
|
|
||||||
|
V1=patchy2
|
||||||
|
|
||||||
|
cleanup;
|
||||||
|
|
||||||
|
TEST glusterd;
|
||||||
|
TEST pidof glusterd;
|
||||||
|
|
||||||
|
TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2};
|
||||||
|
TEST $CLI volume start $V0;
|
||||||
|
|
||||||
|
TEST $CLI volume create $V1 $H0:$B0/${V1}{1,2};
|
||||||
|
TEST $CLI volume start $V1;
|
||||||
|
|
||||||
|
TEST ! $CLI volume set $V0 performance.nfs.read-ahead blah
|
||||||
|
EXPECT '' volume_option $V0 performance.nfs.read-ahead
|
||||||
|
|
||||||
|
TEST $CLI volume set $V0 performance.nfs.read-ahead on
|
||||||
|
EXPECT "on" volume_option $V0 performance.nfs.read-ahead
|
||||||
|
|
||||||
|
EXPECT '' volume_option $V1 performance.nfs.read-ahead
|
||||||
|
|
||||||
|
cleanup;
|
||||||
|
|
@ -2809,6 +2809,8 @@ build_nfs_graph (volgen_graph_t *graph, dict_t *mod_dict)
|
|||||||
char *skey = NULL;
|
char *skey = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char nfs_xprt[16] = {0,};
|
char nfs_xprt[16] = {0,};
|
||||||
|
char *volname = NULL;
|
||||||
|
data_t *data = NULL;
|
||||||
|
|
||||||
this = THIS;
|
this = THIS;
|
||||||
GF_ASSERT (this);
|
GF_ASSERT (this);
|
||||||
@ -2894,6 +2896,12 @@ build_nfs_graph (volgen_graph_t *graph, dict_t *mod_dict)
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
if (mod_dict && (data = dict_get (mod_dict, "volume-name"))) {
|
||||||
|
volname = data->data;
|
||||||
|
if (strcmp (volname, voliter->volname) == 0)
|
||||||
|
dict_copy (mod_dict, set_dict);
|
||||||
|
}
|
||||||
|
|
||||||
ret = build_client_graph (&cgraph, voliter, set_dict);
|
ret = build_client_graph (&cgraph, voliter, set_dict);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
@ -3405,6 +3413,9 @@ validate_nfsopts (glusterd_volinfo_t *volinfo,
|
|||||||
char transport_type[16] = {0,};
|
char transport_type[16] = {0,};
|
||||||
char *tt = NULL;
|
char *tt = NULL;
|
||||||
char err_str[4096] = {0,};
|
char err_str[4096] = {0,};
|
||||||
|
xlator_t *this = THIS;
|
||||||
|
|
||||||
|
GF_ASSERT (this);
|
||||||
|
|
||||||
graph.errstr = op_errstr;
|
graph.errstr = op_errstr;
|
||||||
|
|
||||||
@ -3415,7 +3426,7 @@ validate_nfsopts (glusterd_volinfo_t *volinfo,
|
|||||||
snprintf (err_str, sizeof (err_str), "Changing nfs "
|
snprintf (err_str, sizeof (err_str), "Changing nfs "
|
||||||
"transport type is allowed only for volumes "
|
"transport type is allowed only for volumes "
|
||||||
"of transport type tcp,rdma");
|
"of transport type tcp,rdma");
|
||||||
gf_log ("", GF_LOG_ERROR, "%s", err_str);
|
gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
|
||||||
*op_errstr = gf_strdup (err_str);
|
*op_errstr = gf_strdup (err_str);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto out;
|
goto out;
|
||||||
@ -3429,6 +3440,12 @@ validate_nfsopts (glusterd_volinfo_t *volinfo,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = dict_set_str (val_dict, "volume-name", volinfo->volname);
|
||||||
|
if (ret) {
|
||||||
|
gf_log (this->name, GF_LOG_ERROR, "Failed to set volume name");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
ret = build_nfs_graph (&graph, val_dict);
|
ret = build_nfs_graph (&graph, val_dict);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = graph_reconf_validateopt (&graph.graph, op_errstr);
|
ret = graph_reconf_validateopt (&graph.graph, op_errstr);
|
||||||
@ -3436,7 +3453,7 @@ validate_nfsopts (glusterd_volinfo_t *volinfo,
|
|||||||
volgen_graph_free (&graph);
|
volgen_graph_free (&graph);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
|
gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user