diff options
author | Amar Tumballi <amar@gluster.com> | 2010-06-29 05:36:30 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-07-01 03:31:51 -0700 |
commit | 01923eed1115e53c5be9fba3e72f75c7c631bf95 (patch) | |
tree | c1f1774247d8c25a9ced8c47ec416f63123591a2 /xlators/protocol/server | |
parent | c46f8452d75e2f1b4ab77306177f39bdbb4b232c (diff) |
minor fixes in rpc + protocol
* proper use of mem_acct_init in client.c/server.c
* fentrylk_resume to be called instead of finodelk_resume in
server_fentrylk().
* handle the case of xdr decoding failure on server by sending the
proper error reply to client, so there is no missing frame.
* removed unwanted functions from server-helpers.c
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 875 (Implement a new protocol to provide proper backward/forward compatibility)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=875
Diffstat (limited to 'xlators/protocol/server')
-rw-r--r-- | xlators/protocol/server/src/server-helpers.c | 213 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-helpers.h | 9 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.c | 26 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.h | 3 | ||||
-rw-r--r-- | xlators/protocol/server/src/server3_1-fops.c | 2 |
5 files changed, 20 insertions, 233 deletions
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index 617a12a01..11c489e88 100644 --- a/xlators/protocol/server/src/server-helpers.c +++ b/xlators/protocol/server/src/server-helpers.c @@ -46,149 +46,6 @@ server_decode_groups (call_frame_t *frame, rpcsvc_request_t *req) return 0; } -/* server_loc_fill - derive a loc_t for a given inode number - * - * NOTE: make sure that @loc is empty, because any pointers it holds with reference will - * be leaked after returning from here. - */ -int -server_loc_fill (loc_t *loc, server_state_t *state, - ino_t ino, ino_t par, - const char *name, const char *path) -{ - inode_t *inode = NULL; - inode_t *parent = NULL; - int32_t ret = -1; - char *dentry_path = NULL; - - - GF_VALIDATE_OR_GOTO ("server", loc, out); - GF_VALIDATE_OR_GOTO ("server", state, out); - GF_VALIDATE_OR_GOTO ("server", path, out); - - /* anything beyond this point is success */ - ret = 0; - loc->ino = ino; - inode = loc->inode; - if (inode == NULL) { - if (ino) - inode = inode_search (state->itable, ino, NULL); - - if ((inode == NULL) && - (par && name)) - inode = inode_search (state->itable, par, name); - - loc->inode = inode; - if (inode) - loc->ino = inode->ino; - } - - parent = loc->parent; - if (parent == NULL) { - if (inode) - parent = inode_parent (inode, par, name); - else - parent = inode_search (state->itable, par, NULL); - loc->parent = parent; - } - - if (name && parent) { - ret = inode_path (parent, name, &dentry_path); - if (ret < 0) { - gf_log (state->conn->bound_xl->name, GF_LOG_DEBUG, - "failed to build path for %"PRId64"/%s: %s", - parent->ino, name, strerror (-ret)); - } - } else if (inode) { - ret = inode_path (inode, NULL, &dentry_path); - if (ret < 0) { - gf_log (state->conn->bound_xl->name, GF_LOG_DEBUG, - "failed to build path for %"PRId64": %s", - inode->ino, strerror (-ret)); - } - } - - if (dentry_path) { - if (strcmp (dentry_path, path)) { - gf_log (state->conn->bound_xl->name, GF_LOG_DEBUG, - "paths differ for inode(%"PRId64"): " - "client path = %s. dentry path = %s", - ino, path, dentry_path); - } - - loc->path = dentry_path; - loc->name = strrchr (loc->path, '/'); - if (loc->name) - loc->name++; - } else { - loc->path = gf_strdup (path); - loc->name = strrchr (loc->path, '/'); - if (loc->name) - loc->name++; - } - -out: - return ret; -} - -/* - * stat_to_str - convert struct iatt to a ASCII string - * @stbuf: struct iatt pointer - * - * not for external reference - */ -char * -stat_to_str (struct iatt *stbuf) -{ - int ret = 0; - char *tmp_buf = NULL; - - uint64_t dev = stbuf->ia_gen; - uint64_t ino = stbuf->ia_ino; - uint32_t mode = st_mode_from_ia (stbuf->ia_prot, stbuf->ia_type); - uint32_t nlink = stbuf->ia_nlink; - uint32_t uid = stbuf->ia_uid; - uint32_t gid = stbuf->ia_gid; - uint64_t rdev = stbuf->ia_rdev; - uint64_t size = stbuf->ia_size; - uint32_t blksize = stbuf->ia_blksize; - uint64_t blocks = stbuf->ia_blocks; - uint32_t atime = stbuf->ia_atime; - uint32_t mtime = stbuf->ia_mtime; - uint32_t ctime = stbuf->ia_ctime; - - uint32_t atime_nsec = stbuf->ia_atime_nsec; - uint32_t mtime_nsec = stbuf->ia_mtime_nsec; - uint32_t ctime_nsec = stbuf->ia_ctime_nsec; - - - ret = gf_asprintf (&tmp_buf, - GF_STAT_PRINT_FMT_STR, - dev, - ino, - mode, - nlink, - uid, - gid, - rdev, - size, - blksize, - blocks, - atime, - atime_nsec, - mtime, - mtime_nsec, - ctime, - ctime_nsec); - if (-1 == ret) { - gf_log ("protocol/server", GF_LOG_DEBUG, - "asprintf failed while setting up stat buffer string"); - return NULL; - } - return tmp_buf; -} - - void server_loc_wipe (loc_t *loc) { @@ -279,34 +136,6 @@ free_state (server_state_t *state) } -call_frame_t * -server_copy_frame (call_frame_t *frame) -{ - call_frame_t *new_frame = NULL; - server_state_t *state = NULL, *new_state = NULL; - - state = frame->root->state; - - new_frame = copy_frame (frame); - - new_state = GF_CALLOC (1, sizeof (server_state_t), gf_server_mt_state_t); - - new_frame->root->op = frame->root->op; - new_frame->root->type = frame->root->type; - new_frame->root->trans = state->conn; - new_frame->root->state = new_state; - - new_state->itable = state->itable; - new_state->conn = state->conn; - //new_state->conn = xprt_ref (state->conn); - - new_state->resolve.fd_no = -1; - new_state->resolve2.fd_no = -1; - - return new_frame; -} - - int gf_add_locker (struct _lock_table *table, const char *volume, loc_t *loc, fd_t *fd, pid_t pid) @@ -408,48 +237,6 @@ gf_del_locker (struct _lock_table *table, const char *volume, return ret; } - -int -gf_direntry_to_bin (dir_entry_t *head, char *buffer) -{ - dir_entry_t *trav = NULL; - uint32_t len = 0; - uint32_t this_len = 0; - size_t buflen = -1; - char *ptr = NULL; - char *tmp_buf = NULL; - - trav = head->next; - while (trav) { - len += strlen (trav->name); - len += 1; - len += strlen (trav->link); - len += 1; /* for '\n' */ - len += 256; // max possible for statbuf; - trav = trav->next; - } - - ptr = buffer; - trav = head->next; - while (trav) { - tmp_buf = stat_to_str (&trav->buf); - /* tmp_buf will have \n before \0 */ - - this_len = sprintf (ptr, "%s/%s%s\n", - trav->name, tmp_buf, - trav->link); - - GF_FREE (tmp_buf); - trav = trav->next; - ptr += this_len; - } - - buflen = strlen (buffer); - - return buflen; -} - - static struct _lock_table * gf_lock_table_new (void) { diff --git a/xlators/protocol/server/src/server-helpers.h b/xlators/protocol/server/src/server-helpers.h index ef27b612a..9e295cd10 100644 --- a/xlators/protocol/server/src/server-helpers.h +++ b/xlators/protocol/server/src/server-helpers.h @@ -43,12 +43,6 @@ #define IS_NOT_ROOT(pathlen) ((pathlen > 2)? 1 : 0) -char * -stat_to_str (struct iatt *stbuf); - -call_frame_t * -server_copy_frame (call_frame_t *frame); - void free_state (server_state_t *state); void server_loc_wipe (loc_t *loc); @@ -65,9 +59,6 @@ gf_del_locker (struct _lock_table *table, const char *volume, fd_t *fd, pid_t pid); -int32_t -gf_direntry_to_bin (dir_entry_t *head, char *bufferp); - void server_print_request (call_frame_t *frame); diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index bb9edab13..104274edd 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -474,6 +474,25 @@ out: return 0; } +int32_t +mem_acct_init (xlator_t *this) +{ + int ret = -1; + + if (!this) + return ret; + + 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"); + return ret; + } + + return ret; +} + int init (xlator_t *this) { @@ -495,13 +514,6 @@ init (xlator_t *this) goto out; } - ret = xlator_mem_acct_init (this, gf_server_mt_end + 1); - if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "Failed to Initialize memory accounting"); - goto out; - } - conf = GF_CALLOC (1, sizeof (server_conf_t), gf_server_mt_server_conf_t); GF_VALIDATE_OR_GOTO(this->name, conf, out); diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h index 6626a7c46..aecac4507 100644 --- a/xlators/protocol/server/src/server.h +++ b/xlators/protocol/server/src/server.h @@ -76,9 +76,6 @@ void server_connection_put (xlator_t *this, server_connection_t *conn); int -server_connection_destroy (xlator_t *this, server_connection_t *conn); - -int server_connection_cleanup (xlator_t *this, server_connection_t *conn); int server_null (rpcsvc_request_t *req); diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c index 6dee758e7..686c0350d 100644 --- a/xlators/protocol/server/src/server3_1-fops.c +++ b/xlators/protocol/server/src/server3_1-fops.c @@ -4309,7 +4309,7 @@ server_fentrylk (rpcsvc_request_t *req) state->name = gf_strdup (args.name); state->volume = gf_strdup (args.volume); - resolve_and_resume (frame, server_finodelk_resume); + resolve_and_resume (frame, server_fentrylk_resume); out: return 0; } |