feature/compress: Validate option and enable doc

* Validate network.compression option
* Enable descriptions of xlator configurable options
* Improve indentation in code
* Make network.compression.mode not configurable by user.
  This is similar to "iam-self-heal-daemon" option in AFR xlator.

Fixes BUGs: 1065658, 1065640, 1065655

Change-Id: I99d82b574ee0e5c8c2baf5f5d52dbf8d015d330a
BUG: 1065640
Signed-off-by: Prashanth Pai <ppai@redhat.com>
Reviewed-on: http://review.gluster.org/7024
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
This commit is contained in:
Prashanth Pai 2014-02-17 20:42:42 +05:30 committed by Vijay Bellur
parent 64079f8352
commit f69e855116
4 changed files with 53 additions and 59 deletions

View File

@ -21,18 +21,16 @@ EXPECT 'off' volinfo_field $V0 'performance.io-cache'
TEST $CLI volume set $V0 performance.quick-read off
EXPECT 'off' volinfo_field $V0 'performance.quick-read'
TEST $CLI volume set $V0 strict-write-ordering on
TEST $CLI volume set $V0 performance.strict-write-ordering on
EXPECT 'on' volinfo_field $V0 'performance.strict-write-ordering'
## Turn on cdc xlator by setting network.compression to on
TEST $CLI volume set $V0 network.compression on
EXPECT 'on' volinfo_field $V0 'network.compression'
EXPECT 'server' volinfo_field $V0 'network.compression.mode'
## Make sure that user cannot change network.compression.mode
## This would break the cdc xlator if allowed!
TEST $CLI volume set $V0 network.compression.mode client
EXPECT 'server' volinfo_field $V0 'network.compression.mode'
TEST ! $CLI volume set $V0 network.compression.mode client
## Turn on network.compression.debug option
## This will dump compressed data onto disk as gzip file
@ -44,6 +42,7 @@ EXPECT 'on' volinfo_field $V0 'network.compression.debug'
TEST $CLI volume start $V0;
EXPECT 'Started' volinfo_field $V0 'Status';
sleep 2
## Mount FUSE with caching disabled
TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0;
@ -121,7 +120,6 @@ TEST umount $M0
## Reset the network.compression options
TEST $CLI volume reset $V0 network.compression.debug
TEST $CLI volume reset $V0 network.compression.min-size
TEST $CLI volume reset $V0 network.compression.mode
TEST $CLI volume reset $V0 network.compression
## Stop the volume

View File

@ -115,8 +115,8 @@ cdc_writev_cbk (call_frame_t *frame,
struct iatt *postbuf, dict_t *xdata)
{
STACK_UNWIND_STRICT (writev, frame, op_ret, op_errno, prebuf, postbuf, xdata);
return 0;
STACK_UNWIND_STRICT (writev, frame, op_ret, op_errno, prebuf, postbuf, xdata);
return 0;
}
int32_t
@ -129,24 +129,23 @@ cdc_writev (call_frame_t *frame,
uint32_t flags,
struct iobref *iobref, dict_t *xdata)
{
int ret = -1;
cdc_priv_t *priv = NULL;
cdc_info_t ci = {0,};
size_t isize = 0;
int ret = -1;
cdc_priv_t *priv = NULL;
cdc_info_t ci = {0,};
size_t isize = 0;
GF_VALIDATE_OR_GOTO ("cdc", this, default_out);
GF_VALIDATE_OR_GOTO (this->name, frame, default_out);
GF_VALIDATE_OR_GOTO ("cdc", this, default_out);
GF_VALIDATE_OR_GOTO (this->name, frame, default_out);
priv = this->private;
priv = this->private;
isize = iov_length(vector, count);
isize = iov_length(vector, count);
if (isize <= 0)
goto default_out;
if (isize <= 0)
goto default_out;
if ( (priv->min_file_size != 0)
&& (isize < priv->min_file_size) )
goto default_out;
if ( (priv->min_file_size != 0) && (isize < priv->min_file_size) )
goto default_out;
ci.count = count;
ci.ibytes = isize;
@ -159,18 +158,18 @@ cdc_writev (call_frame_t *frame,
/* A writev compresses on the client side and decompresses on the server side
*/
if (priv->op_mode == GF_CDC_MODE_CLIENT) {
ret = cdc_compress (this, priv, &ci, &xdata);
} else if (priv->op_mode == GF_CDC_MODE_SERVER) {
ret = cdc_decompress (this, priv, &ci, xdata);
} else {
gf_log (this->name, GF_LOG_ERROR, "Invalid operation mode (%d) ", priv->op_mode);
}
if (priv->op_mode == GF_CDC_MODE_CLIENT) {
ret = cdc_compress (this, priv, &ci, &xdata);
} else if (priv->op_mode == GF_CDC_MODE_SERVER) {
ret = cdc_decompress (this, priv, &ci, xdata);
} else {
gf_log (this->name, GF_LOG_ERROR, "Invalid operation mode (%d) ", priv->op_mode);
}
if (ret)
goto default_out;
if (ret)
goto default_out;
STACK_WIND (frame,
STACK_WIND (frame,
cdc_writev_cbk,
FIRST_CHILD (this),
FIRST_CHILD (this)->fops->writev,
@ -181,13 +180,13 @@ cdc_writev (call_frame_t *frame,
return 0;
default_out:
STACK_WIND (frame,
STACK_WIND (frame,
cdc_writev_cbk,
FIRST_CHILD (this),
FIRST_CHILD (this)->fops->writev,
fd, vector, count, offset, flags,
iobref, xdata);
return 0;
return 0;
}
int32_t
@ -309,17 +308,17 @@ struct volume_options options[] = {
{ .key = {"mem-level"},
.default_value = "8",
.type = GF_OPTION_TYPE_INT,
.description = "Memory allocated for internal compression state.\
1 uses minimum memory but is slow and reduces \
compression ratio; memLevel=9 uses maximum memory \
for optimal speed. The default value is 8."
.description = "Memory allocated for internal compression state. "
"1 uses minimum memory but is slow and reduces "
"compression ratio; memLevel=9 uses maximum memory "
"for optimal speed. The default value is 8."
},
{ .key = {"compression-level"},
.default_value = "-1",
.type = GF_OPTION_TYPE_INT,
.description = "Compression levels \
0 : no compression, 1 : best speed, \
9 : best compression, -1 : default compression "
.description = "Compression levels \n"
"0 : no compression, 1 : best speed, \n"
"9 : best compression, -1 : default compression "
},
{ .key = {"min-size"},
.default_value = "0",
@ -329,13 +328,14 @@ struct volume_options options[] = {
{ .key = {"mode"},
.value = {"server", "client"},
.type = GF_OPTION_TYPE_STR,
.description = "Set on the basis of where the xlator is loaded."
.description = "Set on the basis of where the xlator is loaded. "
"This option should NOT be configured by user."
},
{ .key = {"debug"},
.default_value = "false",
.type = GF_OPTION_TYPE_BOOL,
.description = "This is used in testing. Will dump compressed data \
to disk as a gzip file."
.description = "This is used in testing. Will dump compressed data "
"to disk as a gzip file."
},
{ .key = {NULL}
},

View File

@ -1666,13 +1666,16 @@ server_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
}
/* Check for compress volume option, and add it to the graph on server side */
if (dict_get_str_boolean (set_dict, "network.compression", 0)) {
ret = dict_get_str_boolean (set_dict, "network.compression", 0);
if (ret == -1)
goto out;
if (ret) {
xl = volgen_graph_add (graph, "features/cdc", volname);
if (!xl) {
ret = -1;
goto out;
}
ret = dict_set_str (set_dict, "network.compression.mode", "server");
ret = xlator_set_option (xl, "mode", "server");
if (ret)
goto out;
}
@ -2543,16 +2546,18 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
goto out;
/* Check for compress volume option, and add it to the graph on client side */
if (dict_get_str_boolean (set_dict, "network.compression", 0)) {
ret = dict_get_str_boolean (set_dict, "network.compression", 0);
if (ret == -1)
goto out;
if (ret) {
xl = volgen_graph_add (graph, "features/cdc", volname);
if (!xl) {
ret = -1;
goto out;
}
ret = dict_set_str (set_dict, "network.compression.mode", "client");
ret = xlator_set_option (xl, "mode", "client");
if (ret)
goto out;
}
ret = glusterd_volinfo_get_boolean (volinfo, "features.encryption");

View File

@ -1020,39 +1020,30 @@ struct volopt_map_entry glusterd_volopt_map[] = {
*/
{ .key = "network.compression",
.voltype = "features/cdc",
.option = "!feat",
.value = "off",
.type = NO_DOC,
.op_version = 3,
.description = "enable/disable network compression translator"
},
{ .key = "network.compression.mode",
.voltype = "features/cdc",
.option = "mode",
.type = NO_DOC,
.op_version = 3
.description = "enable/disable network compression translator",
.flags = OPT_FLAG_XLATOR_OPT
},
{ .key = "network.compression.window-size",
.voltype = "features/cdc",
.option = "window-size",
.type = NO_DOC,
.op_version = 3
},
{ .key = "network.compression.mem-level",
.voltype = "features/cdc",
.option = "mem-level",
.type = NO_DOC,
.op_version = 3
},
{ .key = "network.compression.min-size",
.voltype = "features/cdc",
.option = "min-size",
.type = NO_DOC,
.op_version = 3
},
{ .key = "network.compression.compression-level",
.voltype = "features/cdc",
.option = "compression-level",
.type = NO_DOC,
.op_version = 3
},
{ .key = "network.compression.debug",