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
This commit is contained in:
parent
c46f8452d7
commit
01923eed11
@ -1168,7 +1168,7 @@ rpcsvc_handle_rpc_call (rpcsvc_conn_t *conn, rpc_transport_pollin_t *msg)
|
||||
if (!actor)
|
||||
goto err_reply;
|
||||
|
||||
if (actor) {
|
||||
if (actor && (req->rpc_err == SUCCESS)) {
|
||||
if (req->vectorediob) {
|
||||
if (actor->vector_actor) {
|
||||
rpcsvc_conn_ref (conn);
|
||||
@ -1189,7 +1189,7 @@ rpcsvc_handle_rpc_call (rpcsvc_conn_t *conn, rpc_transport_pollin_t *msg)
|
||||
}
|
||||
|
||||
err_reply:
|
||||
if (ret == RPCSVC_ACTOR_ERROR)
|
||||
if ((ret == RPCSVC_ACTOR_ERROR) || (req->rpc_err != SUCCESS))
|
||||
ret = rpcsvc_error_reply (req);
|
||||
|
||||
/* No need to propagate error beyond this function since the reply
|
||||
|
@ -1526,7 +1526,7 @@ out:
|
||||
}
|
||||
|
||||
|
||||
static int32_t
|
||||
int32_t
|
||||
mem_acct_init (xlator_t *this)
|
||||
{
|
||||
int ret = -1;
|
||||
@ -1565,10 +1565,6 @@ init (xlator_t *this)
|
||||
"Volume is dangling. ");
|
||||
}
|
||||
|
||||
ret = mem_acct_init (this);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
conf = GF_CALLOC (1, sizeof (*conf), gf_client_mt_clnt_conf_t);
|
||||
if (!conf)
|
||||
goto out;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -75,9 +75,6 @@ server_connection_get (xlator_t *this, const char *id);
|
||||
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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user