From 8ac8f359b24c8583eb1a15b9926929770b869db8 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Mon, 10 Sep 2018 17:04:30 +0300 Subject: mgmt xlators: store boolean fields using integer Surprisingly, there is not set_boolean() as there is a get_boolean() In fact, it is stored as an INT dictionary type. In some occasions it was stored using a string, and this caused errors such as: key gfproxy-server, integer type asked, has string type [Invalid argument] I've fixed what I saw in some logs, I'm sure there are more. The CORRECT fix is to create a boolean set and use it, but this requires a bit more work. I'll see if I can do it later on. Only compile-tested! updates: bz#1193929 Signed-off-by: Yaniv Kaul Change-Id: I45fd0c7a0824b2f42b8ce510296c9dfa4f32ad66 --- xlators/mgmt/glusterd/src/glusterd-volgen.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-volgen.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 3e56eb36508..166d52394f1 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -1553,7 +1553,8 @@ gfproxy_server_graph_builder (volgen_graph_t *graph, if (ret != 0) goto out; - ret = dict_set_str (set_dict, "gfproxy-server", "on"); + ret = dict_set_int32n (set_dict, "gfproxy-server", + SLEN ("gfproxy-server"), 1); if (ret != 0) goto out; @@ -1562,8 +1563,8 @@ gfproxy_server_graph_builder (volgen_graph_t *graph, /* Clear this setting so that future users of set_dict do not end up * thinking they are a gfproxy server */ - dict_del (set_dict, "gfproxy-server"); - dict_del (set_dict, "trusted-client"); + dict_deln (set_dict, "gfproxy-server", SLEN ("gfproxy-server")); + dict_deln (set_dict, "trusted-client", SLEN ("trusted-client")); /* Then add the server to it */ get_vol_transport_type (volinfo, transt); @@ -6218,7 +6219,8 @@ generate_client_volfiles (glusterd_volinfo_t *volinfo, glusterd_get_gfproxy_client_volfile (volinfo, filepath, PATH_MAX); - ret = dict_set_str (dict, "gfproxy-client", "on"); + ret = dict_set_int32n (dict, "gfproxy-client", + SLEN ("gfproxy-client"), 1); } else { ret = glusterd_get_client_filepath (filepath, volinfo, @@ -6851,7 +6853,8 @@ validate_shdopts (glusterd_volinfo_t *volinfo, ret = 0; goto out; } - ret = dict_set_str (val_dict, "graph-check", "on"); + ret = dict_set_int32n (val_dict, "graph-check", + SLEN ("graph-check"), 1); if (ret) goto out; ret = build_shd_graph (&graph, val_dict); @@ -6862,7 +6865,7 @@ validate_shdopts (glusterd_volinfo_t *volinfo, gf_msg_debug ("glusterd", 0, "Returning %d", ret); out: - dict_del (val_dict, "graph-check"); + dict_deln (val_dict, "graph-check", SLEN ("graph-check")); return ret; } -- cgit