diff options
author | Amar Tumballi <amar@gluster.com> | 2009-04-10 00:34:34 -0700 |
---|---|---|
committer | Anand V. Avati <avati@amp.gluster.com> | 2009-04-12 11:59:56 +0530 |
commit | 4a62b5af1c9add4a74ea38ab9008bf129e2b4110 (patch) | |
tree | deeb56a05bd727bcfd2c991d086bb0daa51c76f7 /xlators/protocol | |
parent | be9909606428d78ec23ea02900640c68ca2a40d2 (diff) |
feature to disable volumefile's checksum
in server volume define, "option verify-volfile-checksum no" to disable
the checksum feature.
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'xlators/protocol')
-rw-r--r-- | xlators/protocol/server/src/server-protocol.c | 66 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-protocol.h | 1 |
2 files changed, 47 insertions, 20 deletions
diff --git a/xlators/protocol/server/src/server-protocol.c b/xlators/protocol/server/src/server-protocol.c index 4de990d454e..d4d75c1abe8 100644 --- a/xlators/protocol/server/src/server-protocol.c +++ b/xlators/protocol/server/src/server-protocol.c @@ -7147,7 +7147,8 @@ mop_getspec (call_frame_t *frame, uint32_t flags = 0; uint32_t keylen = 0; char *key = NULL; - + server_conf_t *conf = NULL; + req = gf_param (hdr); flags = ntoh32 (req->flags); keylen = ntoh32 (req->keylen); @@ -7155,6 +7156,8 @@ mop_getspec (call_frame_t *frame, key = req->key; } + conf = frame->this->private; + filename = build_volfile_path (frame->this, key); if (filename) { /* to allocate the proper buffer to hold the file data */ @@ -7176,8 +7179,10 @@ mop_getspec (call_frame_t *frame, } ret = 0; file_len = stbuf.st_size; - get_checksum_for_file (spec_fd, &checksum); - _volfile_update_checksum (frame->this, key, checksum); + if (conf->verify_volfile_checksum) { + get_checksum_for_file (spec_fd, &checksum); + _volfile_update_checksum (frame->this, key, checksum); + } } else { errno = ENOENT; } @@ -7451,25 +7456,30 @@ mop_setvolume (call_frame_t *frame, xlator_t *bound_xl, goto fail; } - ret = dict_get_uint32 (params, "volfile-checksum", &checksum); - if (ret == 0) { - ret = dict_get_str (params, "volfile-key", &volfile_key); - - ret = _validate_volfile_checksum (trans->xl, volfile_key, - checksum); - if (-1 == ret) { - ret = dict_set_str (reply, "ERROR", - "volume-file checksum varies from " - "earlier access"); - if (ret < 0) - gf_log (trans->xl->name, GF_LOG_ERROR, - "failed to set error msg"); + if (conf->verify_volfile_checksum) { + ret = dict_get_uint32 (params, "volfile-checksum", &checksum); + if (ret == 0) { + ret = dict_get_str (params, "volfile-key", + &volfile_key); - op_ret = -1; - op_errno = ESTALE; - goto fail; + ret = _validate_volfile_checksum (trans->xl, + volfile_key, + checksum); + if (-1 == ret) { + ret = dict_set_str (reply, "ERROR", + "volume-file checksum " + "varies from earlier " + "access"); + if (ret < 0) + gf_log (trans->xl->name, GF_LOG_ERROR, + "failed to set error msg"); + + op_ret = -1; + op_errno = ESTALE; + goto fail; + } } - } + } peerinfo = &trans->peerinfo; @@ -8075,6 +8085,7 @@ init (xlator_t *this) int32_t ret = -1; transport_t *trans = NULL; server_conf_t *conf = NULL; + data_t *data = NULL; if (this->children == NULL) { gf_log (this->name, GF_LOG_ERROR, @@ -8137,6 +8148,18 @@ init (xlator_t *this) DEFAULT_BLOCK_SIZE); conf->max_block_size = DEFAULT_BLOCK_SIZE; } + + conf->verify_volfile_checksum = 1; + data = dict_get (this->options, "verify-volfile-checksum"); + if (data) { + ret = gf_string2boolean(data->data, + &conf->verify_volfile_checksum); + if (ret != 0) { + gf_log (this->name, GF_LOG_DEBUG, + "wrong value for verify-volfile-checksum"); + conf->verify_volfile_checksum = 1; + } + } #ifndef GF_DARWIN_HOST_OS { @@ -8291,5 +8314,8 @@ struct volume_options options[] = { { .key = {"client-volume-filename"}, .type = GF_OPTION_TYPE_PATH }, + { .key = {"verify-volfile-checksum"}, + .type = GF_OPTION_TYPE_BOOL + }, { .key = {NULL} }, }; diff --git a/xlators/protocol/server/src/server-protocol.h b/xlators/protocol/server/src/server-protocol.h index 2e6923fb4e2..1ea30cc6f66 100644 --- a/xlators/protocol/server/src/server-protocol.h +++ b/xlators/protocol/server/src/server-protocol.h @@ -105,6 +105,7 @@ typedef struct { int32_t inode_lru_limit; pthread_mutex_t mutex; struct list_head conns; + gf_boolean_t verify_volfile_checksum; } server_conf_t; |