diff options
author | Mohammed Junaid Ahmed <junaid@gluster.com> | 2011-03-16 09:43:21 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2011-03-17 11:59:08 -0700 |
commit | d3e9a97b6ef340f827cf55de5340a8bf5c732f3e (patch) | |
tree | 90d88ecb609c9ab2b3fd4717d8ec3dbe126f360d | |
parent | 0d7628c6c2b0c1d1e1bdcc6dc3904d30d6ebf38e (diff) |
protocol/server: White space cleanup and NULL check validations.
Signed-off-by: Junaid <junaid@gluster.com>
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 2346 (Log message enhancements in GlusterFS - phase 1)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2346
-rw-r--r-- | xlators/protocol/server/src/authenticate.c | 324 | ||||
-rw-r--r-- | xlators/protocol/server/src/authenticate.h | 18 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-handshake.c | 12 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-helpers.c | 204 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-helpers.h | 24 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-mem-types.h | 26 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-resolve.c | 5 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.c | 243 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.h | 76 | ||||
-rw-r--r-- | xlators/protocol/server/src/server3_1-fops.c | 15 |
10 files changed, 512 insertions, 435 deletions
diff --git a/xlators/protocol/server/src/authenticate.c b/xlators/protocol/server/src/authenticate.c index bcdf06910..5a1c2a8c8 100644 --- a/xlators/protocol/server/src/authenticate.c +++ b/xlators/protocol/server/src/authenticate.c @@ -32,218 +32,210 @@ #include "authenticate.h" static void -init (dict_t *this, - char *key, - data_t *value, - void *data) +init (dict_t *this, char *key, data_t *value, void *data) { - void *handle = NULL; - char *auth_file = NULL; - auth_handle_t *auth_handle = NULL; - auth_fn_t authenticate = NULL; - int *error = NULL; + void *handle = NULL; + char *auth_file = NULL; + auth_handle_t *auth_handle = NULL; + auth_fn_t authenticate = NULL; + int *error = NULL; int ret = 0; - /* It gets over written */ - error = data; - - if (!strncasecmp (key, "ip", strlen ("ip"))) { - gf_log ("authenticate", GF_LOG_ERROR, - "AUTHENTICATION MODULE \"IP\" HAS BEEN REPLACED " - "BY \"ADDR\""); - dict_set (this, key, data_from_dynptr (NULL, 0)); - /* TODO: 1.3.x backword compatibility */ - // *error = -1; - // return; - key = "addr"; - } - - ret = gf_asprintf (&auth_file, "%s/%s.so", LIBDIR, key); + /* It gets over written */ + error = data; + + if (!strncasecmp (key, "ip", strlen ("ip"))) { + gf_log ("authenticate", GF_LOG_ERROR, + "AUTHENTICATION MODULE \"IP\" HAS BEEN REPLACED " + "BY \"ADDR\""); + dict_set (this, key, data_from_dynptr (NULL, 0)); + /* TODO: 1.3.x backword compatibility */ + // *error = -1; + // return; + key = "addr"; + } + + ret = gf_asprintf (&auth_file, "%s/%s.so", LIBDIR, key); if (-1 == ret) { - gf_log ("authenticate", GF_LOG_ERROR, "asprintf failed"); dict_set (this, key, data_from_dynptr (NULL, 0)); *error = -1; return; } - handle = dlopen (auth_file, RTLD_LAZY); - if (!handle) { - gf_log ("authenticate", GF_LOG_ERROR, "dlopen(%s): %s\n", - auth_file, dlerror ()); - dict_set (this, key, data_from_dynptr (NULL, 0)); - GF_FREE (auth_file); - *error = -1; - return; - } - GF_FREE (auth_file); - - authenticate = dlsym (handle, "gf_auth"); - if (!authenticate) { - gf_log ("authenticate", GF_LOG_ERROR, - "dlsym(gf_auth) on %s\n", dlerror ()); - dict_set (this, key, data_from_dynptr (NULL, 0)); - *error = -1; - return; - } - - auth_handle = GF_CALLOC (1, sizeof (*auth_handle), + handle = dlopen (auth_file, RTLD_LAZY); + if (!handle) { + gf_log ("authenticate", GF_LOG_ERROR, "dlopen(%s): %s\n", + auth_file, dlerror ()); + dict_set (this, key, data_from_dynptr (NULL, 0)); + GF_FREE (auth_file); + *error = -1; + return; + } + GF_FREE (auth_file); + + authenticate = dlsym (handle, "gf_auth"); + if (!authenticate) { + gf_log ("authenticate", GF_LOG_ERROR, + "dlsym(gf_auth) on %s\n", dlerror ()); + dict_set (this, key, data_from_dynptr (NULL, 0)); + *error = -1; + return; + } + + auth_handle = GF_CALLOC (1, sizeof (*auth_handle), gf_common_mt_auth_handle_t); - if (!auth_handle) { - gf_log ("authenticate", GF_LOG_ERROR, "Out of memory"); - dict_set (this, key, data_from_dynptr (NULL, 0)); - *error = -1; - return; - } - auth_handle->vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t), - gf_common_mt_volume_opt_list_t); - auth_handle->vol_opt->given_opt = dlsym (handle, "options"); - if (auth_handle->vol_opt->given_opt == NULL) { - gf_log ("authenticate", GF_LOG_DEBUG, - "volume option validation not specified"); - } - - auth_handle->authenticate = authenticate; - auth_handle->handle = handle; - - dict_set (this, key, - data_from_dynptr (auth_handle, sizeof (*auth_handle))); + if (!auth_handle) { + dict_set (this, key, data_from_dynptr (NULL, 0)); + *error = -1; + return; + } + auth_handle->vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t), + gf_common_mt_volume_opt_list_t); + auth_handle->vol_opt->given_opt = dlsym (handle, "options"); + if (auth_handle->vol_opt->given_opt == NULL) { + gf_log ("authenticate", GF_LOG_DEBUG, + "volume option validation not specified"); + } + + auth_handle->authenticate = authenticate; + auth_handle->handle = handle; + + dict_set (this, key, + data_from_dynptr (auth_handle, sizeof (*auth_handle))); } static void -fini (dict_t *this, - char *key, - data_t *value, - void *data) +fini (dict_t *this, char *key, data_t *value, void *data) { - auth_handle_t *handle = data_to_ptr (value); - if (handle) { - dlclose (handle->handle); - } + auth_handle_t *handle = data_to_ptr (value); + if (handle) { + dlclose (handle->handle); + } } int32_t gf_auth_init (xlator_t *xl, dict_t *auth_modules) { - int ret = 0; - auth_handle_t *handle = NULL; - data_pair_t *pair = NULL; - dict_foreach (auth_modules, init, &ret); - if (!ret) { - pair = auth_modules->members_list; - while (pair) { - handle = data_to_ptr (pair->value); - if (handle) { - list_add_tail (&(handle->vol_opt->list), - &(xl->volume_options)); - if (-1 == - validate_xlator_volume_options (xl, - handle->vol_opt->given_opt)) { - gf_log ("authenticate", GF_LOG_ERROR, - "volume option validation " - "failed"); - ret = -1; - } - } - pair = pair->next; - } - } - if (ret) { - gf_log (xl->name, GF_LOG_ERROR, "authentication init failed"); - dict_foreach (auth_modules, fini, &ret); - ret = -1; - } - return ret; + int ret = 0; + auth_handle_t *handle = NULL; + data_pair_t *pair = NULL; + + dict_foreach (auth_modules, init, &ret); + if (ret) + goto out; + + pair = auth_modules->members_list; + while (pair) { + handle = data_to_ptr (pair->value); + if (!handle) { + pair = pair->next; + continue; + } + + list_add_tail (&(handle->vol_opt->list), + &(xl->volume_options)); + ret = validate_xlator_volume_options (xl, + handle->vol_opt->given_opt); + if (ret) + gf_log ("authenticate", GF_LOG_ERROR, + "volume option validation failed"); + + pair = pair->next; + } + +out: + if (ret) { + gf_log (xl->name, GF_LOG_ERROR, "authentication init failed"); + dict_foreach (auth_modules, fini, &ret); + ret = -1; + } + return ret; } static dict_t *__input_params; static dict_t *__config_params; void -map (dict_t *this, - char *key, - data_t *value, - void *data) +map (dict_t *this, char *key, data_t *value, void *data) { - dict_t *res = data; - auth_fn_t authenticate; - auth_handle_t *handle = NULL; - - if (value && (handle = data_to_ptr (value)) && - (authenticate = handle->authenticate)) { - dict_set (res, key, - int_to_data (authenticate (__input_params, - __config_params))); - } else { - dict_set (res, key, int_to_data (AUTH_DONT_CARE)); - } + dict_t *res = data; + auth_fn_t authenticate; + auth_handle_t *handle = NULL; + + if (value && (handle = data_to_ptr (value)) && + (authenticate = handle->authenticate)) { + dict_set (res, key, + int_to_data (authenticate (__input_params, + __config_params))); + } else { + dict_set (res, key, int_to_data (AUTH_DONT_CARE)); + } } void -reduce (dict_t *this, - char *key, - data_t *value, - void *data) +reduce (dict_t *this, char *key, data_t *value, void *data) { - int64_t val = 0; - int64_t *res = data; - if (!data) - return; - - val = data_to_int64 (value); - switch (val) - { - case AUTH_ACCEPT: - if (AUTH_DONT_CARE == *res) - *res = AUTH_ACCEPT; - break; - - case AUTH_REJECT: - *res = AUTH_REJECT; - break; - - case AUTH_DONT_CARE: - break; - } + int64_t val = 0; + int64_t *res = data; + if (!data) + return; + + val = data_to_int64 (value); + switch (val) + { + case AUTH_ACCEPT: + if (AUTH_DONT_CARE == *res) + *res = AUTH_ACCEPT; + break; + + case AUTH_REJECT: + *res = AUTH_REJECT; + break; + + case AUTH_DONT_CARE: + break; + } } auth_result_t gf_authenticate (dict_t *input_params, - dict_t *config_params, - dict_t *auth_modules) + dict_t *config_params, + dict_t *auth_modules) { - dict_t *results = NULL; - int64_t result = AUTH_DONT_CARE; + char *name = NULL; + dict_t *results = NULL; + int64_t result = AUTH_DONT_CARE; + data_t *peerinfo_data = NULL; - results = get_new_dict (); - __input_params = input_params; - __config_params = config_params; + results = get_new_dict (); + __input_params = input_params; + __config_params = config_params; - dict_foreach (auth_modules, map, results); + dict_foreach (auth_modules, map, results); - dict_foreach (results, reduce, &result); - if (AUTH_DONT_CARE == result) { - data_t *peerinfo_data = dict_get (input_params, "peer-info-name"); - char *name = NULL; + dict_foreach (results, reduce, &result); + if (AUTH_DONT_CARE == result) { + peerinfo_data = dict_get (input_params, "peer-info-name"); - if (peerinfo_data) { - name = peerinfo_data->data; - } + if (peerinfo_data) { + name = peerinfo_data->data; + } - gf_log ("auth", GF_LOG_ERROR, - "no authentication module is interested in " - "accepting remote-client %s", name); - result = AUTH_REJECT; - } + gf_log ("auth", GF_LOG_ERROR, + "no authentication module is interested in " + "accepting remote-client %s", name); + result = AUTH_REJECT; + } - dict_destroy (results); - return result; + dict_destroy (results); + return result; } void gf_auth_fini (dict_t *auth_modules) { - int32_t dummy; + int32_t dummy; - dict_foreach (auth_modules, fini, &dummy); + dict_foreach (auth_modules, fini, &dummy); } diff --git a/xlators/protocol/server/src/authenticate.h b/xlators/protocol/server/src/authenticate.h index 49480a6b8..7c9dd58d2 100644 --- a/xlators/protocol/server/src/authenticate.h +++ b/xlators/protocol/server/src/authenticate.h @@ -37,23 +37,23 @@ #include "xlator.h" typedef enum { - AUTH_ACCEPT, - AUTH_REJECT, - AUTH_DONT_CARE + AUTH_ACCEPT, + AUTH_REJECT, + AUTH_DONT_CARE } auth_result_t; typedef auth_result_t (*auth_fn_t) (dict_t *input_params, - dict_t *config_params); + dict_t *config_params); typedef struct { - void *handle; - auth_fn_t authenticate; - volume_opt_list_t *vol_opt; + void *handle; + auth_fn_t authenticate; + volume_opt_list_t *vol_opt; } auth_handle_t; auth_result_t gf_authenticate (dict_t *input_params, - dict_t *config_params, - dict_t *auth_modules); + dict_t *config_params, + dict_t *auth_modules); int32_t gf_auth_init (xlator_t *xl, dict_t *auth_modules); void gf_auth_fini (dict_t *auth_modules); diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c index 709e36b56..1dc05f032 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -109,14 +109,14 @@ _volfile_update_checksum (xlator_t *this, char *key, uint32_t checksum) temp_volfile->checksum = checksum; } - out: +out: return 0; } static size_t getspec_build_volfile_path (xlator_t *this, const char *key, char *path, - size_t path_len) + size_t path_len) { int ret = -1; int free_filename = 0; @@ -205,7 +205,7 @@ _validate_volfile_checksum (xlator_t *this, char *key, if (!temp_volfile) { ret = getspec_build_volfile_path (this, key, filename, - sizeof (filename)); + sizeof (filename)); if (ret <= 0) goto out; fd = open (filename, O_RDONLY); @@ -377,7 +377,7 @@ server_setvolume (rpcsvc_request_t *req) op_errno = ENOMEM; goto fail; } - + ret = dict_unserialize (buf, args.dict.dict_len, ¶ms); if (ret < 0) { ret = dict_set_str (reply, "ERROR", @@ -438,7 +438,7 @@ server_setvolume (rpcsvc_request_t *req) ret = gf_asprintf (&msg, "version mismatch: client(%d)" " - client-mgmt(%d)", fop_version, mgmt_version); - /* get_supported_version (req)); */ + /* get_supported_version (req)); */ if (-1 == ret) { gf_log (this->name, GF_LOG_ERROR, "asprintf failed while setting up error msg"); @@ -470,7 +470,7 @@ server_setvolume (rpcsvc_request_t *req) xl = get_xlator_by_name (this, name); if (xl == NULL) { ret = gf_asprintf (&msg, "remote-subvolume \"%s\" is not found", - name); + name); if (-1 == ret) { gf_log (this->name, GF_LOG_ERROR, "asprintf failed while setting error msg"); diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index 0ae8ecec9..78d850fc7 100644 --- a/xlators/protocol/server/src/server-helpers.c +++ b/xlators/protocol/server/src/server-helpers.c @@ -32,8 +32,8 @@ server_decode_groups (call_frame_t *frame, rpcsvc_request_t *req) { int i = 0; - if ((!frame) || (!req)) - return 0; + GF_VALIDATE_OR_GOTO ("server", frame, out); + GF_VALIDATE_OR_GOTO ("server", req, out); frame->root->ngrps = req->auxgidcount; if (frame->root->ngrps == 0) @@ -44,7 +44,7 @@ server_decode_groups (call_frame_t *frame, rpcsvc_request_t *req) for (; i < frame->root->ngrps; ++i) frame->root->groups[i] = req->auxgids[i]; - +out: return 0; } @@ -155,6 +155,11 @@ gf_add_locker (struct _lock_table *table, const char *volume, int32_t ret = -1; struct _locker *new = NULL; + GF_VALIDATE_OR_GOTO ("server", table, out); + GF_VALIDATE_OR_GOTO ("server", volume, out); + GF_VALIDATE_OR_GOTO ("server", loc, out); + GF_VALIDATE_OR_GOTO ("server", fd, out); + new = GF_CALLOC (1, sizeof (struct _locker), gf_server_mt_locker_t); if (new == NULL) { gf_log ("server", GF_LOG_ERROR, @@ -193,10 +198,15 @@ gf_del_locker (struct _lock_table *table, const char *volume, { struct _locker *locker = NULL; struct _locker *tmp = NULL; - int32_t ret = 0; + int32_t ret = -1; struct list_head *head = NULL; struct list_head del; + GF_VALIDATE_OR_GOTO ("server", table, out); + GF_VALIDATE_OR_GOTO ("server", volume, out); + GF_VALIDATE_OR_GOTO ("server", loc, out); + GF_VALIDATE_OR_GOTO ("server", fd, out); + INIT_LIST_HEAD (&del); LOCK (&table->lock); @@ -237,6 +247,8 @@ gf_del_locker (struct _lock_table *table, const char *volume, GF_FREE (locker); } + ret = 0; +out: return ret; } @@ -262,14 +274,22 @@ static int server_nop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno) { + int ret = -1; server_state_t *state = NULL; + GF_VALIDATE_OR_GOTO ("server", frame, out); + GF_VALIDATE_OR_GOTO ("server", cookie, out); + GF_VALIDATE_OR_GOTO ("server", this, out); + state = CALL_STATE(frame); if (state) free_state (state); STACK_DESTROY (frame->root); - return 0; + + ret = 0; +out: + return ret; } int @@ -284,6 +304,11 @@ do_lock_table_cleanup (xlator_t *this, server_connection_t *conn, int ret = -1; char *path = NULL; + GF_VALIDATE_OR_GOTO ("server", this, out); + GF_VALIDATE_OR_GOTO ("server", conn, out); + GF_VALIDATE_OR_GOTO ("server", frame, out); + GF_VALIDATE_OR_GOTO ("server", ltable, out); + bound_xl = conn->bound_xl; INIT_LIST_HEAD (&inodelk_lockers); INIT_LIST_HEAD (&entrylk_lockers); @@ -311,8 +336,8 @@ do_lock_table_cleanup (xlator_t *this, server_connection_t *conn, goto out; } /* - lock owner = 0 is a special case that tells posix-locks - to release all locks from this transport + lock owner = 0 is a special case that tells posix-locks + to release all locks from this transport */ tmp_frame->root->pid = 0; tmp_frame->root->lk_owner = 0; @@ -416,15 +441,23 @@ server_connection_cleanup_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno) { + int32_t ret = -1; fd_t *fd = NULL; + GF_VALIDATE_OR_GOTO ("server", this, out); + GF_VALIDATE_OR_GOTO ("server", cookie, out); + GF_VALIDATE_OR_GOTO ("server", frame, out); + fd = frame->local; fd_unref (fd); frame->local = NULL; STACK_DESTROY (frame->root); - return 0; + + ret = 0; +out: + return ret; } @@ -438,6 +471,11 @@ do_fd_cleanup (xlator_t *this, server_connection_t *conn, call_frame_t *frame, xlator_t *bound_xl = NULL; char *path = NULL; + GF_VALIDATE_OR_GOTO ("server", this, out); + GF_VALIDATE_OR_GOTO ("server", conn, out); + GF_VALIDATE_OR_GOTO ("server", frame, out); + GF_VALIDATE_OR_GOTO ("server", fdentries, out); + bound_xl = conn->bound_xl; for (i = 0;i < fd_count; i++) { fd = fdentries[i].fd; @@ -493,6 +531,11 @@ do_connection_cleanup (xlator_t *this, server_connection_t *conn, call_frame_t *frame = NULL; server_state_t *state = NULL; + GF_VALIDATE_OR_GOTO ("server", this, out); + GF_VALIDATE_OR_GOTO ("server", conn, out); + GF_VALIDATE_OR_GOTO ("server", fdentries, out); + GF_VALIDATE_OR_GOTO ("server", ltable, out); + frame = create_frame (this, this->ctx->pool); if (frame == NULL) { gf_log (this->name, GF_LOG_ERROR, "out of memory"); @@ -529,9 +572,8 @@ server_connection_cleanup (xlator_t *this, server_connection_t *conn) uint32_t fd_count = 0; int ret = 0; - if (conn == NULL) { - goto out; - } + GF_VALIDATE_OR_GOTO ("server", this, out); + GF_VALIDATE_OR_GOTO ("server", conn, out); pthread_mutex_lock (&conn->lock); { @@ -577,10 +619,8 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn) uint32_t fd_count = 0; char *path = NULL; - if (conn == NULL) { - ret = 0; - goto out; - } + GF_VALIDATE_OR_GOTO ("server", this, out); + GF_VALIDATE_OR_GOTO ("server", conn, out); bound_xl = (xlator_t *) (conn->bound_xl); @@ -621,8 +661,8 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn) tmp, &inodelk_lockers, lockers) { tmp_frame = copy_frame (frame); /* - lock_owner = 0 is a special case that tells posix-locks - to release all locks from this transport + lock_owner = 0 is a special case that tells posix-locks + to release all locks from this transport */ tmp_frame->root->lk_owner = 0; tmp_frame->root->trans = conn; @@ -766,9 +806,12 @@ out: server_connection_t * server_connection_get (xlator_t *this, const char *id) { - server_connection_t *conn = NULL; - server_connection_t *trav = NULL; - server_conf_t *conf = NULL; + server_connection_t *conn = NULL; + server_connection_t *trav = NULL; + server_conf_t *conf = NULL; + + GF_VALIDATE_OR_GOTO ("server", this, out); + GF_VALIDATE_OR_GOTO ("server", id, out); conf = this->private; @@ -793,15 +836,15 @@ server_connection_get (xlator_t *this, const char *id) conn->this = this; pthread_mutex_init (&conn->lock, NULL); - list_add (&conn->list, &conf->conns); - } + list_add (&conn->list, &conf->conns); + } conn->ref++; conn->active_transports++; - } + } unlock: - pthread_mutex_unlock (&conf->mutex); - + pthread_mutex_unlock (&conf->mutex); +out: return conn; } @@ -812,15 +855,11 @@ server_connection_put (xlator_t *this, server_connection_t *conn) server_conf_t *conf = NULL; server_connection_t *todel = NULL; - if (conn == NULL) { - goto out; - } + GF_VALIDATE_OR_GOTO ("server", this, out); + GF_VALIDATE_OR_GOTO ("server", conn, out); conf = this->private; - - if (conf == NULL) { - goto out; - } + GF_VALIDATE_OR_GOTO ("server", conf, out); pthread_mutex_lock (&conf->mutex); { @@ -848,20 +887,19 @@ server_alloc_frame (rpcsvc_request_t *req) server_state_t *state = NULL; server_connection_t *conn = NULL; - GF_VALIDATE_OR_GOTO("server", req, out); - GF_VALIDATE_OR_GOTO("server", req->trans, out); - GF_VALIDATE_OR_GOTO("server", req->svc, out); - GF_VALIDATE_OR_GOTO("server", req->svc->ctx, out); + GF_VALIDATE_OR_GOTO ("server", req, out); + GF_VALIDATE_OR_GOTO ("server", req->trans, out); + GF_VALIDATE_OR_GOTO ("server", req->svc, out); + GF_VALIDATE_OR_GOTO ("server", req->svc->ctx, out); conn = (server_connection_t *)req->trans->xl_private; - if (!conn) - goto out; + GF_VALIDATE_OR_GOTO ("server", conn, out); frame = create_frame (conn->this, req->svc->ctx->pool); - GF_VALIDATE_OR_GOTO("server", frame, out); + GF_VALIDATE_OR_GOTO ("server", frame, out); state = GF_CALLOC (1, sizeof (*state), gf_server_mt_state_t); - GF_VALIDATE_OR_GOTO("server", state, out); + GF_VALIDATE_OR_GOTO ("server", state, out); if (conn->bound_xl) state->itable = conn->bound_xl->itable; @@ -887,9 +925,10 @@ get_frame_from_request (rpcsvc_request_t *req) { call_frame_t *frame = NULL; + GF_VALIDATE_OR_GOTO ("server", req, out); + frame = server_alloc_frame (req); - if (!frame) - goto out; + GF_VALIDATE_OR_GOTO ("server", frame, out); frame->root->op = req->procnum; frame->root->type = req->type; @@ -917,6 +956,9 @@ server_build_config (xlator_t *this, server_conf_t *conf) int ret = -1; struct stat buf = {0,}; + GF_VALIDATE_OR_GOTO ("server", this, out); + GF_VALIDATE_OR_GOTO ("server", conf, out); + ret = dict_get_int32 (this->options, "inode-lru-limit", &conf->inode_lru_limit); if (ret < 0) { @@ -935,14 +977,14 @@ server_build_config (xlator_t *this, server_conf_t *conf) } data = dict_get (this->options, "trace"); - if (data) { + if (data) { ret = gf_string2boolean (data->data, &conf->trace); if (ret != 0) { - gf_log (this->name, GF_LOG_WARNING, - "'trace' takes on only boolean values. " + gf_log (this->name, GF_LOG_WARNING, + "'trace' takes on only boolean values. " "Neglecting option"); - } - } + } + } /* TODO: build_rpc_config (); */ ret = dict_get_int32 (this->options, "limits.transaction-size", @@ -984,7 +1026,12 @@ out: server_connection_t * get_server_conn_state (xlator_t *this, rpc_transport_t *xprt) { + GF_VALIDATE_OR_GOTO ("server", this, out); + GF_VALIDATE_OR_GOTO ("server", xprt, out); + return (server_connection_t *)xprt->xl_private; +out: + return NULL; } server_connection_t * @@ -993,6 +1040,9 @@ create_server_conn_state (xlator_t *this, rpc_transport_t *xprt) server_connection_t *conn = NULL; int ret = -1; + GF_VALIDATE_OR_GOTO ("server", this, out); + GF_VALIDATE_OR_GOTO ("server", xprt, out); + conn = GF_CALLOC (1, sizeof (*conn), gf_server_mt_conn_t); if (!conn) goto out; @@ -1022,9 +1072,7 @@ out: void destroy_server_conn_state (server_connection_t *conn) { - if (!conn) { - return; - } + GF_VALIDATE_OR_GOTO ("server", conn, out); if (conn->ltable) { /* TODO */ @@ -1038,7 +1086,7 @@ destroy_server_conn_state (server_connection_t *conn) pthread_mutex_destroy (&conn->lock); GF_FREE (conn); - +out: return; } @@ -1048,6 +1096,9 @@ print_caller (char *str, int size, call_frame_t *frame) { server_state_t *state = NULL; + GF_VALIDATE_OR_GOTO ("server", str, out); + GF_VALIDATE_OR_GOTO ("server", frame, out); + state = CALL_STATE (frame); snprintf (str, size, @@ -1055,6 +1106,7 @@ print_caller (char *str, int size, call_frame_t *frame) frame->root->unique, state->xprt->peerinfo.identifier); +out: return; } @@ -1064,6 +1116,8 @@ server_print_resolve (char *str, int size, server_resolve_t *resolve) { int filled = 0; + GF_VALIDATE_OR_GOTO ("server", str, out); + if (!resolve) { snprintf (str, size, "<nul>"); return; @@ -1091,6 +1145,8 @@ server_print_resolve (char *str, int size, server_resolve_t *resolve) "path=%s", resolve->path); snprintf (str + filled, size - filled, "}"); +out: + return; } @@ -1099,6 +1155,8 @@ server_print_loc (char *str, int size, loc_t *loc) { int filled = 0; + GF_VALIDATE_OR_GOTO ("server", str, out); + if (!loc) { snprintf (str, size, "<nul>"); return; @@ -1118,6 +1176,8 @@ server_print_loc (char *str, int size, loc_t *loc) "parent=%p", loc->parent); snprintf (str + filled, size - filled, "}"); +out: + return; } @@ -1126,6 +1186,8 @@ server_print_params (char *str, int size, server_state_t *state) { int filled = 0; + GF_VALIDATE_OR_GOTO ("server", str, out); + filled += snprintf (str + filled, size - filled, " Params={"); @@ -1165,6 +1227,8 @@ server_print_params (char *str, int size, server_state_t *state) snprintf (str + filled, size - filled, "bound_xl=%s}", state->conn->bound_xl->name); +out: + return; } int @@ -1201,11 +1265,13 @@ server_print_reply (call_frame_t *frame, int op_ret, int op_errno) char fdstr[32]; char *op = "UNKNOWN"; + GF_VALIDATE_OR_GOTO ("server", frame, out); + this = frame->this; conf = this->private; - if (!conf || !conf->trace) - return; + GF_VALIDATE_OR_GOTO ("server", conf, out); + GF_VALIDATE_OR_GOTO ("server", conf->trace, out); state = CALL_STATE (frame); @@ -1229,6 +1295,8 @@ server_print_reply (call_frame_t *frame, int op_ret, int op_errno) gf_log (this->name, GF_LOG_NORMAL, "%s%s => (%d, %d)%s", op, caller, op_ret, op_errno, fdstr); +out: + return; } @@ -1246,11 +1314,13 @@ server_print_request (call_frame_t *frame) char caller[512]; char *op = "UNKNOWN"; + GF_VALIDATE_OR_GOTO ("server", frame, out); + this = frame->this; conf = this->private; - if (!conf || !conf->trace) - return; + GF_VALIDATE_OR_GOTO ("server", conf, out); + GF_VALIDATE_OR_GOTO ("server", conf->trace, out); state = CALL_STATE (frame); @@ -1290,17 +1360,22 @@ server_print_request (call_frame_t *frame) "%s%s%s%s%s%s%s", op, caller, resolve_vars, loc_vars, resolve2_vars, loc2_vars, other_vars); +out: + return; } int serialize_rsp_direntp (gf_dirent_t *entries, gfs3_readdirp_rsp *rsp) { - gf_dirent_t *entry = NULL; + gf_dirent_t *entry = NULL; gfs3_dirplist *trav = NULL; gfs3_dirplist *prev = NULL; - int ret = -1; + int ret = -1; - list_for_each_entry (entry, &entries->list, list) { + GF_VALIDATE_OR_GOTO ("server", entries, out); + GF_VALIDATE_OR_GOTO ("server", rsp, out); + + list_for_each_entry (entry, &entries->list, list) { trav = GF_CALLOC (1, sizeof (*trav), gf_server_mt_dirent_rsp_t); if (!trav) goto out; @@ -1320,7 +1395,7 @@ serialize_rsp_direntp (gf_dirent_t *entries, gfs3_readdirp_rsp *rsp) rsp->reply = trav; prev = trav; - } + } ret = 0; out: @@ -1331,12 +1406,15 @@ out: int serialize_rsp_dirent (gf_dirent_t *entries, gfs3_readdir_rsp *rsp) { - gf_dirent_t *entry = NULL; + gf_dirent_t *entry = NULL; gfs3_dirlist *trav = NULL; gfs3_dirlist *prev = NULL; - int ret = -1; + int ret = -1; - list_for_each_entry (entry, &entries->list, list) { + GF_VALIDATE_OR_GOTO ("server", entries, out); + GF_VALIDATE_OR_GOTO ("server", rsp, out); + + list_for_each_entry (entry, &entries->list, list) { trav = GF_CALLOC (1, sizeof (*trav), gf_server_mt_dirent_rsp_t); if (!trav) goto out; @@ -1351,7 +1429,7 @@ serialize_rsp_dirent (gf_dirent_t *entries, gfs3_readdir_rsp *rsp) rsp->reply = trav; prev = trav; - } + } ret = 0; out: diff --git a/xlators/protocol/server/src/server-helpers.h b/xlators/protocol/server/src/server-helpers.h index 4fe03db26..85929bbba 100644 --- a/xlators/protocol/server/src/server-helpers.h +++ b/xlators/protocol/server/src/server-helpers.h @@ -28,16 +28,16 @@ #define XPRT_FROM_FRAME(frame) ((rpc_transport_t *) CALL_STATE(frame)->xprt) -#define SERVER_CONNECTION(frame) \ - ((server_connection_t *) CALL_STATE(frame)->conn) +#define SERVER_CONNECTION(frame) \ + ((server_connection_t *) CALL_STATE(frame)->conn) -#define SERVER_CONF(frame) \ - ((server_conf_t *)XPRT_FROM_FRAME(frame)->this->private) +#define SERVER_CONF(frame) \ + ((server_conf_t *)XPRT_FROM_FRAME(frame)->this->private) #define XPRT_FROM_XLATOR(this) ((((server_conf_t *)this->private))->listen) -#define INODE_LRU_LIMIT(this) \ - (((server_conf_t *)(this->private))->config.inode_lru_limit) +#define INODE_LRU_LIMIT(this) \ + (((server_conf_t *)(this->private))->config.inode_lru_limit) #define IS_ROOT_INODE(inode) (inode == inode->table->root) @@ -49,17 +49,17 @@ void server_loc_wipe (loc_t *loc); int32_t gf_add_locker (struct _lock_table *table, const char *volume, - loc_t *loc, - fd_t *fd, - pid_t pid, + loc_t *loc, + fd_t *fd, + pid_t pid, uint64_t owner, glusterfs_fop_t type); int32_t gf_del_locker (struct _lock_table *table, const char *volume, - loc_t *loc, - fd_t *fd, - uint64_t owner, + loc_t *loc, + fd_t *fd, + uint64_t owner, glusterfs_fop_t type); void diff --git a/xlators/protocol/server/src/server-mem-types.h b/xlators/protocol/server/src/server-mem-types.h index a1435d0b7..bf1a2faa5 100644 --- a/xlators/protocol/server/src/server-mem-types.h +++ b/xlators/protocol/server/src/server-mem-types.h @@ -1,20 +1,20 @@ /* - Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com> - This file is part of GlusterFS. + Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com> + This file is part of GlusterFS. - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. + GlusterFS is free software; you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. + GlusterFS is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see + <http://www.gnu.org/licenses/>. */ diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c index df16aef22..1da41b2fd 100644 --- a/xlators/protocol/server/src/server-resolve.c +++ b/xlators/protocol/server/src/server-resolve.c @@ -61,7 +61,6 @@ prepare_components (call_frame_t *frame) int i = 0; char *trav = NULL; - state = CALL_STATE (frame); resolve = state->resolve_now; @@ -71,8 +70,8 @@ prepare_components (call_frame_t *frame) count = component_count (resolve->path); components = GF_CALLOC (sizeof (*components), count, gf_server_mt_resolv_comp_t); - if (!components) - goto out; + GF_VALIDATE_OR_GOTO ("server", components, out); + resolve->components = components; components[0].basename = ""; diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index 650b66bf1..5b2560f58 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -43,6 +43,8 @@ gfs_serialize_reply (rpcsvc_request_t *req, void *arg, gfs_serialize_t sfunc, struct iobuf *iob = NULL; ssize_t retlen = -1; + GF_VALIDATE_OR_GOTO ("server", req, ret); + /* First, get the io buffer into which the reply in arg will * be serialized. */ @@ -93,9 +95,7 @@ server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg, server_state_t *state = NULL; char new_iobref = 0; - if (!req) { - goto ret; - } + GF_VALIDATE_OR_GOTO ("server", req, ret); if (frame) { state = CALL_STATE (frame); @@ -126,7 +126,7 @@ server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg, /* TODO: this is demo purpose only */ /* ret = rpcsvc_callback_submit (req->svc, req->trans, req->prog, - GF_CBK_NULL, &rsp, 1); + GF_CBK_NULL, &rsp, 1); */ /* Now that we've done our job of handing the message to the RPC layer * we can safely unref the iob in the hope that RPC layer must have @@ -161,74 +161,73 @@ xdr_to_glusterfs_req (rpcsvc_request_t *req, void *arg, gfs_serialize_t sfunc) { int ret = -1; - if (!req) - return -1; + GF_VALIDATE_OR_GOTO ("server", req, out); ret = sfunc (req->msg[0], arg); if (ret > 0) ret = 0; - +out: return ret; } int server_fd (xlator_t *this) { - server_conf_t *conf = NULL; - server_connection_t *trav = NULL; - char key[GF_DUMP_MAX_BUF_LEN]; - int i = 1; - int ret = -1; + server_conf_t *conf = NULL; + server_connection_t *trav = NULL; + char key[GF_DUMP_MAX_BUF_LEN]; + int i = 1; + int ret = -1; - if (!this) - return -1; + GF_VALIDATE_OR_GOTO ("server", this, out); - conf = this->private; - if (!conf) { + conf = this->private; + if (!conf) { gf_log (this->name, GF_LOG_WARNING, "conf null in xlator"); return -1; - } + } - gf_proc_dump_add_section("xlator.protocol.server.conn"); + gf_proc_dump_add_section("xlator.protocol.server.conn"); - ret = pthread_mutex_trylock (&conf->mutex); - if (ret) { + ret = pthread_mutex_trylock (&conf->mutex); + if (ret) { gf_log("", GF_LOG_WARNING, "Unable to dump fdtable" - " errno: %d", errno); + " errno: %d", errno); return -1; } - list_for_each_entry (trav, &conf->conns, list) { - if (trav->id) { - gf_proc_dump_build_key(key, - "xlator.protocol.server.conn", - "%d.id", i); - gf_proc_dump_write(key, "%s", trav->id); - } - - gf_proc_dump_build_key(key,"xlator.protocol.server.conn", - "%d.ref",i) - gf_proc_dump_write(key, "%d", trav->ref); - if (trav->bound_xl) { - gf_proc_dump_build_key(key, - "xlator.protocol.server.conn", - "%d.bound_xl", i); - gf_proc_dump_write(key, "%s", trav->bound_xl->name); - } - - gf_proc_dump_build_key(key, - "xlator.protocol.server.conn", - "%d.id", i); - fdtable_dump(trav->fdtable,key); - i++; - } - pthread_mutex_unlock (&conf->mutex); + list_for_each_entry (trav, &conf->conns, list) { + if (trav->id) { + gf_proc_dump_build_key(key, + "xlator.protocol.server.conn", + "%d.id", i); + gf_proc_dump_write(key, "%s", trav->id); + } + gf_proc_dump_build_key(key,"xlator.protocol.server.conn", + "%d.ref",i) + gf_proc_dump_write(key, "%d", trav->ref); + if (trav->bound_xl) { + gf_proc_dump_build_key(key, + "xlator.protocol.server.conn", + "%d.bound_xl", i); + gf_proc_dump_write(key, "%s", trav->bound_xl->name); + } - return 0; - } + gf_proc_dump_build_key(key, + "xlator.protocol.server.conn", + "%d.id", i); + fdtable_dump(trav->fdtable,key); + i++; + } + pthread_mutex_unlock (&conf->mutex); + + ret = 0; +out: + return ret; +} int server_priv (xlator_t *this) @@ -238,6 +237,9 @@ server_priv (xlator_t *this) char key[GF_DUMP_MAX_BUF_LEN] = {0,}; uint64_t total_read = 0; uint64_t total_write = 0; + int32_t ret = -1; + + GF_VALIDATE_OR_GOTO ("server", this, out); conf = this->private; if (!conf) @@ -254,49 +256,51 @@ server_priv (xlator_t *this) gf_proc_dump_build_key(key, "server", "total-bytes-write"); gf_proc_dump_write(key, "%"PRIu64, total_write); - return 0; + ret = 0; +out: + return ret; } int server_inode (xlator_t *this) { - server_conf_t *conf = NULL; - server_connection_t *trav = NULL; - char key[GF_DUMP_MAX_BUF_LEN]; - int i = 1; - int ret = -1; + server_conf_t *conf = NULL; + server_connection_t *trav = NULL; + char key[GF_DUMP_MAX_BUF_LEN]; + int i = 1; + int ret = -1; - if (!this) - return -1; + GF_VALIDATE_OR_GOTO ("server", this, out); - conf = this->private; - if (!conf) { + conf = this->private; + if (!conf) { gf_log (this->name, GF_LOG_WARNING, "conf null in xlator"); return -1; - } + } - ret = pthread_mutex_trylock (&conf->mutex); - if (ret) { + ret = pthread_mutex_trylock (&conf->mutex); + if (ret) { gf_log("", GF_LOG_WARNING, "Unable to dump itable" - " errno: %d", errno); + " errno: %d", errno); return -1; } list_for_each_entry (trav, &conf->conns, list) { - if (trav->bound_xl && trav->bound_xl->itable) { - gf_proc_dump_build_key(key, - "xlator.protocol.server.conn", - "%d.bound_xl.%s", - i, trav->bound_xl->name); - inode_table_dump(trav->bound_xl->itable,key); - i++; - } + if (trav->bound_xl && trav->bound_xl->itable) { + gf_proc_dump_build_key(key, + "xlator.protocol.server.conn", + "%d.bound_xl.%s", + i, trav->bound_xl->name); + inode_table_dump(trav->bound_xl->itable,key); + i++; + } } pthread_mutex_unlock (&conf->mutex); - - return 0; + ret = 0; +out: + return ret; } @@ -309,6 +313,10 @@ get_auth_types (dict_t *this, char *key, data_t *value, void *data) char *key_cpy = NULL; int32_t ret = -1; + GF_VALIDATE_OR_GOTO ("server", this, out); + GF_VALIDATE_OR_GOTO ("server", key, out); + GF_VALIDATE_OR_GOTO ("server", data, out); + auth_dict = data; key_cpy = gf_strdup (key); GF_VALIDATE_OR_GOTO("server", key_cpy, out); @@ -340,11 +348,14 @@ out: int validate_auth_options (xlator_t *this, dict_t *dict) { - int error = 0; + int error = -1; xlator_list_t *trav = NULL; data_pair_t *pair = NULL; char *tail = NULL; + GF_VALIDATE_OR_GOTO ("server", this, out); + GF_VALIDATE_OR_GOTO ("server", dict, out); + trav = this->children; while (trav) { error = -1; @@ -376,7 +387,7 @@ validate_auth_options (xlator_t *this, dict_t *dict) } trav = trav->next; } - +out: return error; } @@ -406,11 +417,11 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, { /* Have a structure per new connection */ /* TODO: Should we create anything here at all ? * / - conn = create_server_conn_state (this, xprt); - if (!conn) - goto out; + conn = create_server_conn_state (this, xprt); + if (!conn) + goto out; - xprt->protocol_private = conn; + xprt->protocol_private = conn; */ INIT_LIST_HEAD (&xprt->list); @@ -448,21 +459,20 @@ mem_acct_init (xlator_t *this) { int ret = -1; - if (!this) - return ret; + GF_VALIDATE_OR_GOTO ("server", this, out); ret = xlator_mem_acct_init (this, gf_server_mt_end + 1); if (ret != 0) { gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" - "failed"); + "failed"); return ret; } - +out: return ret; } -int +int validate_options (xlator_t *this, dict_t *options, char **op_errstr) { int inode_lru_limit = 0; @@ -475,34 +485,34 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr) if (dict_get_int32 ( options, "inode-lru-limit", &inode_lru_limit) == 0){ - if (!(inode_lru_limit < (1 * GF_UNIT_MB) && + if (!(inode_lru_limit < (1 * GF_UNIT_MB) && inode_lru_limit >1 )) { gf_log (this->name, GF_LOG_DEBUG, "Validate inode-lru" - "-limit %d, was WRONG", inode_lru_limit); + "-limit %d, was WRONG", inode_lru_limit); snprintf (errstr,1024, "Error, Greater than max value %d " - ,inode_lru_limit); + ,inode_lru_limit); *op_errstr = gf_strdup (errstr); ret = -1; goto out; - } + } } - + data = dict_get (options, "trace"); if (data) { ret = gf_string2boolean (data->data, &trace); if (ret != 0) { gf_log (this->name, GF_LOG_WARNING, "'trace' takes on only boolean values. " - "Neglecting option"); + "Neglecting option"); snprintf (errstr,1024, "Error, trace takes only boolean" - "values"); + "values"); *op_errstr = gf_strdup (errstr); ret = -1; goto out; } } - + auth_modules = dict_new (); if (!auth_modules) { gf_log (this->name, GF_LOG_ERROR, "Out of memory"); @@ -566,32 +576,32 @@ int reconfigure (xlator_t *this, dict_t *options) { - server_conf_t *conf =NULL; + server_conf_t *conf =NULL; rpcsvc_t *rpc_conf; rpcsvc_listener_t *listeners; - int inode_lru_limit; - gf_boolean_t trace; - data_t *data; - int ret = 0; + int inode_lru_limit; + gf_boolean_t trace; + data_t *data; + int ret = 0; - conf = this->private; + conf = this->private; if (!conf) { gf_log (this->name, GF_LOG_DEBUG, "conf == null!!!"); goto out; } - if (dict_get_int32 ( options, "inode-lru-limit", &inode_lru_limit) == 0){ - conf->inode_lru_limit = inode_lru_limit; - gf_log (this->name, GF_LOG_TRACE, "Reconfigured inode-lru-limit" - " to %d", conf->inode_lru_limit); - } + if (dict_get_int32 ( options, "inode-lru-limit", &inode_lru_limit) == 0){ + conf->inode_lru_limit = inode_lru_limit; + gf_log (this->name, GF_LOG_TRACE, "Reconfigured inode-lru-limit" + " to %d", conf->inode_lru_limit); + } - data = dict_get (options, "trace"); - if (data) { + data = dict_get (options, "trace"); + if (data) { ret = gf_string2boolean (data->data, &trace); if (ret != 0) { - gf_log (this->name, GF_LOG_WARNING, - "'trace' takes on only boolean values. " + gf_log (this->name, GF_LOG_WARNING, + "'trace' takes on only boolean values. " "Neglecting option"); ret = -1; goto out; @@ -630,12 +640,10 @@ reconfigure (xlator_t *this, dict_t *options) if (listeners->trans->reconfigure ) listeners->trans->reconfigure (listeners->trans, options); else - gf_log (this->name, GF_LOG_ERROR, - "Reconfigure not found for transport" ); + gf_log (this->name, GF_LOG_ERROR, + "Reconfigure not found for transport" ); } } - - out: gf_log ("", GF_LOG_DEBUG, "returning %d", ret); @@ -649,8 +657,7 @@ init (xlator_t *this) server_conf_t *conf = NULL; rpcsvc_listener_t *listener = NULL; - if (!this) - goto out; + GF_VALIDATE_OR_GOTO ("init", this, out); if (this->children == NULL) { gf_log (this->name, GF_LOG_ERROR, @@ -664,7 +671,9 @@ init (xlator_t *this) goto out; } - conf = GF_CALLOC (1, sizeof (server_conf_t), gf_server_mt_server_conf_t); + conf = GF_CALLOC (1, sizeof (server_conf_t), + gf_server_mt_server_conf_t); + GF_VALIDATE_OR_GOTO(this->name, conf, out); INIT_LIST_HEAD (&conf->conns); @@ -798,10 +807,10 @@ fini (xlator_t *this) if (conf->rpc) { /* TODO: memory leak here, have to free RPC */ /* - if (conf->rpc->conn) { - rpcsvc_conn_destroy (conf->rpc->conn); - } - rpcsvc_fini (conf->rpc); + if (conf->rpc->conn) { + rpcsvc_conn_destroy (conf->rpc->conn); + } + rpcsvc_fini (conf->rpc); */ ; } diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h index 5c04c5847..55ca63248 100644 --- a/xlators/protocol/server/src/server.h +++ b/xlators/protocol/server/src/server.h @@ -35,34 +35,34 @@ typedef struct _server_state server_state_t; struct _locker { - struct list_head lockers; + struct list_head lockers; char *volume; - loc_t loc; - fd_t *fd; + loc_t loc; + fd_t *fd; uint64_t owner; - pid_t pid; + pid_t pid; }; struct _lock_table { - struct list_head inodelk_lockers; - struct list_head entrylk_lockers; - gf_lock_t lock; - size_t count; + struct list_head inodelk_lockers; + struct list_head entrylk_lockers; + gf_lock_t lock; + size_t count; }; /* private structure per connection (transport object) * used as transport_t->xl_private */ struct _server_connection { - struct list_head list; - char *id; - int ref; + struct list_head list; + char *id; + int ref; int active_transports; - pthread_mutex_t lock; - char disconnected; - fdtable_t *fdtable; - struct _lock_table *ltable; - xlator_t *bound_xl; + pthread_mutex_t lock; + char disconnected; + fdtable_t *fdtable; + struct _lock_table *ltable; + xlator_t *bound_xl; xlator_t *this; }; @@ -95,9 +95,9 @@ struct server_conf { char *conf_dir; struct _volfile_ctx *volfile; - dict_t *auth_modules; - pthread_mutex_t mutex; - struct list_head conns; + dict_t *auth_modules; + pthread_mutex_t mutex; + struct list_head conns; struct list_head xprt_list; }; typedef struct server_conf server_conf_t; @@ -129,7 +129,7 @@ typedef struct { u_char pargfid[16]; char *path; char *bname; - char *resolved; + char *resolved; int op_ret; int op_errno; loc_t deep_loc; @@ -150,8 +150,8 @@ struct _server_state { server_resume_fn_t resume_fn; - loc_t loc; - loc_t loc2; + loc_t loc; + loc_t loc2; server_resolve_t resolve; server_resolve_t resolve2; @@ -162,29 +162,29 @@ struct _server_state { struct iatt stbuf; int valid; - fd_t *fd; + fd_t *fd; dict_t *params; - int flags; + int flags; int wbflags; struct iovec payload_vector[MAX_IOVEC]; int payload_count; struct iobuf *iobuf; struct iobref *iobref; - size_t size; - off_t offset; - mode_t mode; - dev_t dev; - size_t nr_count; - int cmd; - int type; - char *name; - int name_len; - - int mask; - char is_revalidate; - dict_t *dict; - struct gf_flock flock; + size_t size; + off_t offset; + mode_t mode; + dev_t dev; + size_t nr_count; + int cmd; + int type; + char *name; + int name_len; + + int mask; + char is_revalidate; + dict_t *dict; + struct gf_flock flock; const char *volume; dir_entry_t *entry; }; diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c index d18133b27..43f7c82d4 100644 --- a/xlators/protocol/server/src/server3_1-fops.c +++ b/xlators/protocol/server/src/server3_1-fops.c @@ -1328,8 +1328,8 @@ server_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (link_inode != inode) { /* - VERY racy code (if used anywhere else) - -- don't do this without understanding + VERY racy code (if used anywhere else) + -- don't do this without understanding */ inode_unref (fd->inode); @@ -2025,7 +2025,7 @@ err: int - server_readdir_resume (call_frame_t *frame, xlator_t *bound_xl) +server_readdir_resume (call_frame_t *frame, xlator_t *bound_xl) { server_state_t *state = NULL; @@ -4835,7 +4835,7 @@ server_lk (rpcsvc_request_t *req) case GF_LK_SETLKW: state->cmd = F_SETLKW; break; - case GF_LK_RESLK_LCK: + case GF_LK_RESLK_LCK: state->cmd = F_RESLK_LCK; break; case GF_LK_RESLK_LCKW: @@ -4946,8 +4946,7 @@ server_lookup (rpcsvc_request_t *req) gfs3_lookup_req args = {{0,},}; int ret = -1; - if (!req) - return ret; + GF_VALIDATE_OR_GOTO ("server", req, err); conn = req->trans->xl_private; @@ -5113,8 +5112,8 @@ rpcsvc_actor_t glusterfs3_1_fop_actors[] = { [GFS3_OP_READDIR] = { "READDIR", GFS3_OP_READDIR, server_readdir, NULL, NULL }, [GFS3_OP_INODELK] = { "INODELK", GFS3_OP_INODELK, server_inodelk, NULL, NULL }, [GFS3_OP_FINODELK] = { "FINODELK", GFS3_OP_FINODELK, server_finodelk, NULL, NULL }, - [GFS3_OP_ENTRYLK] = { "ENTRYLK", GFS3_OP_ENTRYLK, server_entrylk, NULL, NULL }, - [GFS3_OP_FENTRYLK] = { "FENTRYLK", GFS3_OP_FENTRYLK, server_fentrylk, NULL, NULL }, + [GFS3_OP_ENTRYLK] = { "ENTRYLK", GFS3_OP_ENTRYLK, server_entrylk, NULL, NULL }, + [GFS3_OP_FENTRYLK] = { "FENTRYLK", GFS3_OP_FENTRYLK, server_fentrylk, NULL, NULL }, [GFS3_OP_XATTROP] = { "XATTROP", GFS3_OP_XATTROP, server_xattrop, NULL, NULL }, [GFS3_OP_FXATTROP] = { "FXATTROP", GFS3_OP_FXATTROP, server_fxattrop, NULL, NULL }, [GFS3_OP_FGETXATTR] = { "FGETXATTR", GFS3_OP_FGETXATTR, server_fgetxattr, NULL, NULL }, |