summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/protocol/server/src')
-rw-r--r--xlators/protocol/server/src/server-helpers.c17
-rw-r--r--xlators/protocol/server/src/server-resolve.c388
-rw-r--r--xlators/protocol/server/src/server.h5
-rw-r--r--xlators/protocol/server/src/server3_1-fops.c85
4 files changed, 195 insertions, 300 deletions
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c
index 45f14dcb3..f259a651f 100644
--- a/xlators/protocol/server/src/server-helpers.c
+++ b/xlators/protocol/server/src/server-helpers.c
@@ -69,28 +69,13 @@ server_loc_wipe (loc_t *loc)
void
server_resolve_wipe (server_resolve_t *resolve)
{
- struct resolve_comp *comp = NULL;
- int i = 0;
-
if (resolve->path)
GF_FREE ((void *)resolve->path);
if (resolve->bname)
GF_FREE ((void *)resolve->bname);
- if (resolve->resolved)
- GF_FREE ((void *)resolve->resolved);
-
- loc_wipe (&resolve->deep_loc);
-
- comp = resolve->components;
- if (comp) {
- for (i = 0; comp[i].basename; i++) {
- if (comp[i].inode)
- inode_unref (comp[i].inode);
- }
- GF_FREE ((void *)resolve->components);
- }
+ loc_wipe (&resolve->resolve_loc);
}
diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c
index 50ae9231c..38ab368c3 100644
--- a/xlators/protocol/server/src/server-resolve.c
+++ b/xlators/protocol/server/src/server-resolve.c
@@ -33,72 +33,9 @@ resolve_entry_simple (call_frame_t *frame);
int
resolve_inode_simple (call_frame_t *frame);
int
-resolve_path_simple (call_frame_t *frame);
-
+resolve_continue (call_frame_t *frame);
int
-component_count (const char *path)
-{
- int count = 0;
- const char *trav = NULL;
-
- for (trav = path; *trav; trav++) {
- if (*trav == '/')
- count++;
- }
-
- return count + 2;
-}
-
-
-int
-prepare_components (call_frame_t *frame)
-{
- server_state_t *state = NULL;
- server_resolve_t *resolve = NULL;
- char *resolved = NULL;
- int count = 0;
- struct resolve_comp *components = NULL;
- int i = 0;
- char *trav = NULL;
-
- state = CALL_STATE (frame);
- resolve = state->resolve_now;
-
- resolved = gf_strdup (resolve->path);
- resolve->resolved = resolved;
-
- count = component_count (resolve->path);
- components = GF_CALLOC (sizeof (*components), count,
- gf_server_mt_resolv_comp_t);
- if (!components)
- goto out;
-
- resolve->components = components;
-
- components[0].basename = "";
- components[0].inode = state->itable->root;
-
- i = 1;
- for (trav = resolved; *trav; trav++) {
- if (*trav == '/') {
- *trav = 0;
-
- if (!(*(trav + 1))) {
- /* Skip trailing "/" in a path.
- This is the check which prevents
- inode_link'age of itable->root
- */
- break;
- }
-
- components[i].basename = trav + 1;
- i++;
- }
- }
-out:
- return 0;
-}
-
+resolve_anonfd_simple (call_frame_t *frame);
int
resolve_loc_touchup (call_frame_t *frame)
@@ -123,231 +60,177 @@ resolve_loc_touchup (call_frame_t *frame)
if (ret)
gf_log (frame->this->name, GF_LOG_TRACE,
"return value inode_path %d", ret);
-
- if (!path)
- path = gf_strdup (resolve->path);
-
loc->path = path;
}
- loc->name = strrchr (loc->path, '/');
- if (loc->name)
- loc->name++;
-
- if (!loc->parent && loc->inode) {
- loc->parent = inode_parent (loc->inode, 0, NULL);
- }
-
return 0;
}
int
-resolve_deep_continue (call_frame_t *frame)
+resolve_gfid_entry_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int op_ret, int op_errno, inode_t *inode,
+ struct iatt *buf, dict_t *xattr, struct iatt *postparent)
{
server_state_t *state = NULL;
- xlator_t *this = NULL;
server_resolve_t *resolve = NULL;
- int ret = 0;
+ inode_t *link_inode = NULL;
+ loc_t *resolve_loc = NULL;
state = CALL_STATE (frame);
- this = frame->this;
resolve = state->resolve_now;
+ resolve_loc = &resolve->resolve_loc;
- resolve->op_ret = 0;
- resolve->op_errno = 0;
+ if (op_ret == -1) {
+ gf_log (this->name, ((op_errno == ENOENT) ? GF_LOG_DEBUG :
+ GF_LOG_WARNING),
+ "%s/%s: failed to resolve (%s)",
+ uuid_utoa (resolve_loc->pargfid), resolve_loc->name,
+ strerror (op_errno));
+ goto out;
+ }
- if (!uuid_is_null (resolve->pargfid))
- ret = resolve_entry_simple (frame);
- else if (!uuid_is_null (resolve->gfid))
- ret = resolve_inode_simple (frame);
- else if (resolve->path)
- ret = resolve_path_simple (frame);
- if (ret)
- gf_log (this->name, GF_LOG_DEBUG,
- "return value of resolve_*_simple %d", ret);
+ link_inode = inode_link (inode, resolve_loc->parent,
+ resolve_loc->name, buf);
- resolve_loc_touchup (frame);
+ if (!link_inode)
+ goto out;
- server_resolve_all (frame);
+ inode_lookup (link_inode);
+
+ inode_unref (link_inode);
+out:
+ loc_wipe (resolve_loc);
+
+ resolve_continue (frame);
return 0;
}
int
-resolve_deep_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+resolve_gfid_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int op_ret, int op_errno, inode_t *inode, struct iatt *buf,
dict_t *xattr, struct iatt *postparent)
{
server_state_t *state = NULL;
server_resolve_t *resolve = NULL;
- struct resolve_comp *components = NULL;
- int i = 0;
inode_t *link_inode = NULL;
+ loc_t *resolve_loc = NULL;
state = CALL_STATE (frame);
resolve = state->resolve_now;
- components = resolve->components;
-
- i = (long) cookie;
+ resolve_loc = &resolve->resolve_loc;
if (op_ret == -1) {
gf_log (this->name, ((op_errno == ENOENT) ? GF_LOG_DEBUG :
GF_LOG_WARNING),
"%s: failed to resolve (%s)",
- resolve->resolved, strerror (op_errno));
- goto get_out_of_here;
+ uuid_utoa (resolve_loc->gfid), strerror (op_errno));
+ loc_wipe (&resolve->resolve_loc);
+ goto out;
}
- if (i != 0) {
- /* no linking for root inode */
- link_inode = inode_link (inode, resolve->deep_loc.parent,
- resolve->deep_loc.name, buf);
- inode_lookup (link_inode);
- components[i].inode = link_inode;
- link_inode = NULL;
- }
+ loc_wipe (resolve_loc);
- loc_wipe (&resolve->deep_loc);
+ link_inode = inode_link (inode, NULL, NULL, buf);
- i++; /* next component */
+ if (!link_inode)
+ goto out;
- if (!components[i].basename) {
- /* all components of the path are resolved */
- goto get_out_of_here;
+ inode_lookup (link_inode);
+
+ if (uuid_is_null (resolve->pargfid)) {
+ inode_unref (link_inode);
+ goto out;
}
- /* join the current component with the path resolved until now */
- *(components[i].basename - 1) = '/';
+ resolve_loc->parent = link_inode;
+ uuid_copy (resolve_loc->pargfid, resolve_loc->parent->gfid);
- resolve->deep_loc.path = gf_strdup (resolve->resolved);
- resolve->deep_loc.parent = inode_ref (components[i-1].inode);
- resolve->deep_loc.inode = inode_new (state->itable);
- resolve->deep_loc.name = components[i].basename;
+ resolve_loc->name = resolve->bname;
- if (frame && frame->root->state && BOUND_XL (frame)) {
- STACK_WIND_COOKIE (frame, resolve_deep_cbk, (void *) (long) i,
- BOUND_XL (frame), BOUND_XL (frame)->fops->lookup,
- &resolve->deep_loc, NULL);
- return 0;
- }
+ resolve_loc->inode = inode_new (state->itable);
+ inode_path (resolve_loc->parent, resolve_loc->name,
+ (char **) &resolve_loc->path);
-get_out_of_here:
- resolve_deep_continue (frame);
+ STACK_WIND (frame, resolve_gfid_entry_cbk,
+ BOUND_XL (frame), BOUND_XL (frame)->fops->lookup,
+ &resolve->resolve_loc, NULL);
+ return 0;
+out:
+ resolve_continue (frame);
return 0;
}
int
-resolve_path_deep (call_frame_t *frame)
+resolve_gfid (call_frame_t *frame)
{
- server_state_t *state = NULL;
- server_resolve_t *resolve = NULL;
- int i = 0;
+ server_state_t *state = NULL;
+ xlator_t *this = NULL;
+ server_resolve_t *resolve = NULL;
+ loc_t *resolve_loc = NULL;
+ int ret = 0;
state = CALL_STATE (frame);
+ this = frame->this;
resolve = state->resolve_now;
+ resolve_loc = &resolve->resolve_loc;
- gf_log (BOUND_XL (frame)->name, GF_LOG_DEBUG,
- "RESOLVE %s() seeking deep resolution of %s",
- gf_fop_list[frame->root->op], resolve->path);
-
- prepare_components (frame);
-
- /* start from the root */
- resolve->deep_loc.inode = state->itable->root;
- resolve->deep_loc.path = gf_strdup ("/");
- resolve->deep_loc.name = "";
-
- if (frame && frame->root->state && BOUND_XL (frame)) {
- STACK_WIND_COOKIE (frame, resolve_deep_cbk, (void *) (long) i,
- BOUND_XL (frame), BOUND_XL (frame)->fops->lookup,
- &resolve->deep_loc, NULL);
- return 0;
+ if (!uuid_is_null (resolve->pargfid)) {
+ uuid_copy (resolve_loc->gfid, resolve->pargfid);
+ resolve_loc->inode = inode_new (state->itable);
+ ret = inode_path (resolve_loc->inode, NULL,
+ (char **)&resolve_loc->path);
+ } else if (!uuid_is_null (resolve->gfid)) {
+ uuid_copy (resolve_loc->gfid, resolve->gfid);
+ resolve_loc->inode = inode_new (state->itable);
+ ret = inode_path (resolve_loc->inode, NULL,
+ (char **)&resolve_loc->path);
}
- resolve_deep_continue (frame);
+ STACK_WIND (frame, resolve_gfid_cbk,
+ BOUND_XL (frame), BOUND_XL (frame)->fops->lookup,
+ &resolve->resolve_loc, NULL);
return 0;
}
int
-resolve_path_simple (call_frame_t *frame)
+resolve_continue (call_frame_t *frame)
{
server_state_t *state = NULL;
+ xlator_t *this = NULL;
server_resolve_t *resolve = NULL;
- struct resolve_comp *components = NULL;
- int ret = -1;
- int par_idx = -1;
- int ino_idx = -1;
- int i = 0;
+ int ret = 0;
state = CALL_STATE (frame);
+ this = frame->this;
resolve = state->resolve_now;
- components = resolve->components;
-
- if (!components) {
- gf_log ("", GF_LOG_INFO,
- "failed to resolve, component not found");
- resolve->op_ret = -1;
- resolve->op_errno = ENOENT;
- goto out;
- }
- for (i = 0; components[i].basename; i++) {
- par_idx = ino_idx;
- ino_idx = i;
- }
-
- if (ino_idx == -1) {
- gf_log ("", GF_LOG_INFO,
- "failed to resolve, inode index not found");
- resolve->op_ret = -1;
- resolve->op_errno = EINVAL;
- goto out;
- }
-
- if (par_idx == -1)
- /* "/" will not have a parent */
- goto noparent;
-
- if (!components[par_idx].inode) {
- gf_log ("", GF_LOG_INFO,
- "failed to resolve, parent inode not found");
- resolve->op_ret = -1;
- resolve->op_errno = ENOENT;
- goto out;
- }
- state->loc_now->parent = inode_ref (components[par_idx].inode);
-noparent:
-
- if (!components[ino_idx].inode &&
- (resolve->type == RESOLVE_MUST || resolve->type == RESOLVE_EXACT)) {
- gf_log ("", GF_LOG_INFO,
- "failed to resolve, inode not found");
- resolve->op_ret = -1;
- resolve->op_errno = ENOENT;
- goto out;
- }
+ resolve->op_ret = 0;
+ resolve->op_errno = 0;
- if (components[ino_idx].inode && resolve->type == RESOLVE_NOT) {
- gf_log ("", GF_LOG_INFO,
- "failed to resolve, inode found");
- resolve->op_ret = -1;
- resolve->op_errno = EEXIST;
+ if (resolve->fd_no != -1) {
+ ret = resolve_anonfd_simple (frame);
goto out;
- }
-
- if (components[ino_idx].inode)
- state->loc_now->inode = inode_ref (components[ino_idx].inode);
-
- ret = 0;
+ } else if (!uuid_is_null (resolve->pargfid))
+ ret = resolve_entry_simple (frame);
+ else if (!uuid_is_null (resolve->gfid))
+ ret = resolve_inode_simple (frame);
+ if (ret)
+ gf_log (this->name, GF_LOG_DEBUG,
+ "return value of resolve_*_simple %d", ret);
+ resolve_loc_touchup (frame);
out:
- return ret;
+ server_resolve_all (frame);
+
+ return 0;
}
+
/*
Check if the requirements are fulfilled by entries in the inode cache itself
Return value:
@@ -380,7 +263,9 @@ resolve_entry_simple (call_frame_t *frame)
}
/* expected @parent was found from the inode cache */
+ uuid_copy (state->loc_now->pargfid, resolve->pargfid);
state->loc_now->parent = inode_ref (parent);
+ state->loc_now->name = resolve->bname;
inode = inode_grep (state->itable, parent, resolve->bname);
if (!inode) {
@@ -441,7 +326,7 @@ server_resolve_entry (call_frame_t *frame)
if (ret > 0) {
loc_wipe (loc);
- resolve_path_deep (frame);
+ resolve_gfid (frame);
return 0;
}
@@ -477,6 +362,7 @@ resolve_inode_simple (call_frame_t *frame)
ret = 0;
state->loc_now->inode = inode_ref (inode);
+ uuid_copy (state->loc_now->gfid, resolve->gfid);
out:
if (inode)
@@ -500,7 +386,7 @@ server_resolve_inode (call_frame_t *frame)
if (ret > 0) {
loc_wipe (loc);
- resolve_path_deep (frame);
+ resolve_gfid (frame);
return 0;
}
@@ -514,6 +400,62 @@ server_resolve_inode (call_frame_t *frame)
int
+resolve_anonfd_simple (call_frame_t *frame)
+{
+ server_state_t *state = NULL;
+ server_resolve_t *resolve = NULL;
+ inode_t *inode = NULL;
+ int ret = 0;
+
+ state = CALL_STATE (frame);
+ resolve = state->resolve_now;
+
+ inode = inode_find (state->itable, resolve->gfid);
+
+ if (!inode) {
+ resolve->op_ret = -1;
+ resolve->op_errno = ENOENT;
+ ret = 1;
+ goto out;
+ }
+
+ ret = 0;
+
+ state->fd = fd_anonymous (inode);
+out:
+ if (inode)
+ inode_unref (inode);
+
+ return ret;
+}
+
+
+int
+server_resolve_anonfd (call_frame_t *frame)
+{
+ server_state_t *state = NULL;
+ int ret = 0;
+ loc_t *loc = NULL;
+
+ state = CALL_STATE (frame);
+ loc = state->loc_now;
+
+ ret = resolve_anonfd_simple (frame);
+
+ if (ret > 0) {
+ loc_wipe (loc);
+ resolve_gfid (frame);
+ return 0;
+ }
+
+ server_resolve_all (frame);
+
+ return 0;
+
+}
+
+
+int
server_resolve_fd (call_frame_t *frame)
{
server_state_t *state = NULL;
@@ -527,6 +469,11 @@ server_resolve_fd (call_frame_t *frame)
fd_no = resolve->fd_no;
+ if (fd_no == -2) {
+ server_resolve_anonfd (frame);
+ return 0;
+ }
+
state->fd = gf_fd_fdptr_get (conn->fdtable, fd_no);
if (!state->fd) {
@@ -562,14 +509,11 @@ server_resolve (call_frame_t *frame)
server_resolve_inode (frame);
- } else if (resolve->path) {
-
- gf_log (frame->this->name, GF_LOG_INFO,
- "pure path resolution for %s (%s)",
- resolve->path, gf_fop_list[frame->root->op]);
- resolve_path_deep (frame);
-
- } else {
+ } else {
+ if (resolve == &state->resolve)
+ gf_log (frame->this->name, GF_LOG_WARNING,
+ "no resolution type for %s (%s)",
+ resolve->path, gf_fop_list[frame->root->op]);
resolve->op_ret = -1;
resolve->op_errno = EINVAL;
diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h
index c8fd5f271..6a37482f4 100644
--- a/xlators/protocol/server/src/server.h
+++ b/xlators/protocol/server/src/server.h
@@ -122,12 +122,9 @@ typedef struct {
u_char pargfid[16];
char *path;
char *bname;
- char *resolved;
int op_ret;
int op_errno;
- loc_t deep_loc;
- struct resolve_comp *components;
- int comp_count;
+ loc_t resolve_loc;
} server_resolve_t;
diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c
index 60444061d..8df517be3 100644
--- a/xlators/protocol/server/src/server3_1-fops.c
+++ b/xlators/protocol/server/src/server3_1-fops.c
@@ -2690,7 +2690,6 @@ server_stat (rpcsvc_request_t *req)
return 0;
/* Initialize args first, then decode */
- args.path = alloca (req->msg[0].iov_len);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_stat_req)) {
//failed to decode msg;
@@ -2715,7 +2714,6 @@ server_stat (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
memcpy (state->resolve.gfid, args.gfid, 16);
- state->resolve.path = gf_strdup (args.path);
ret = 0;
resolve_and_resume (frame, server_stat_resume);
@@ -2735,8 +2733,6 @@ server_setattr (rpcsvc_request_t *req)
if (!req)
return 0;
- args.path = alloca (req->msg[0].iov_len);
-
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_setattr_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -2760,7 +2756,6 @@ server_setattr (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
memcpy (state->resolve.gfid, args.gfid, 16);
- state->resolve.path = gf_strdup (args.path);
gf_stat_to_iatt (&args.stbuf, &state->stbuf);
state->valid = args.valid;
@@ -2828,8 +2823,6 @@ server_readlink (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
-
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_readlink_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -2853,7 +2846,6 @@ server_readlink (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
memcpy (state->resolve.gfid, args.gfid, 16);
- state->resolve.path = gf_strdup (args.path);
state->size = args.size;
@@ -2877,7 +2869,6 @@ server_create (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
args.bname = alloca (req->msg[0].iov_len);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_create_req)) {
@@ -2927,7 +2918,6 @@ server_create (rpcsvc_request_t *req)
buf = NULL;
}
- state->resolve.path = gf_strdup (args.path);
state->resolve.bname = gf_strdup (args.bname);
state->mode = args.mode;
state->flags = gf_flags_to_flags (args.flags);
@@ -2976,8 +2966,6 @@ server_open (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
-
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_open_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -3001,7 +2989,6 @@ server_open (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
memcpy (state->resolve.gfid, args.gfid, 16);
- state->resolve.path = gf_strdup (args.path);
state->flags = gf_flags_to_flags (args.flags);
@@ -3048,6 +3035,7 @@ server_readv (rpcsvc_request_t *req)
state->resolve.fd_no = args.fd;
state->size = args.size;
state->offset = args.offset;
+ memcpy (state->resolve.gfid, args.gfid, 16);
ret = 0;
resolve_and_resume (frame, server_readv_resume);
@@ -3095,6 +3083,7 @@ server_writev (rpcsvc_request_t *req)
state->resolve.fd_no = args.fd;
state->offset = args.offset;
state->iobref = iobref_ref (req->iobref);
+ memcpy (state->resolve.gfid, args.gfid, 16);
if (len < req->msg[0].iov_len) {
state->payload_vector[0].iov_base
@@ -3236,6 +3225,7 @@ server_fsync (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.fd_no = args.fd;
state->flags = args.data;
+ memcpy (state->resolve.gfid, args.gfid, 16);
ret = 0;
resolve_and_resume (frame, server_fsync_resume);
@@ -3279,6 +3269,7 @@ server_flush (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.fd_no = args.fd;
+ memcpy (state->resolve.gfid, args.gfid, 16);
ret = 0;
resolve_and_resume (frame, server_flush_resume);
@@ -3323,6 +3314,7 @@ server_ftruncate (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.fd_no = args.fd;
state->offset = args.offset;
+ memcpy (state->resolve.gfid, args.gfid, 16);
ret = 0;
resolve_and_resume (frame, server_ftruncate_resume);
@@ -3365,6 +3357,7 @@ server_fstat (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.fd_no = args.fd;
+ memcpy (state->resolve.gfid, args.gfid, 16);
ret = 0;
resolve_and_resume (frame, server_fstat_resume);
@@ -3384,7 +3377,6 @@ server_truncate (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_truncate_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -3407,7 +3399,6 @@ server_truncate (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = gf_strdup (args.path);
memcpy (state->resolve.gfid, args.gfid, 16);
state->offset = args.offset;
@@ -3430,7 +3421,6 @@ server_unlink (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
args.bname = alloca (req->msg[0].iov_len);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_unlink_req)) {
@@ -3455,7 +3445,6 @@ server_unlink (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = gf_strdup (args.path);
state->resolve.bname = gf_strdup (args.bname);
memcpy (state->resolve.pargfid, args.pargfid, 16);
@@ -3482,7 +3471,6 @@ server_setxattr (rpcsvc_request_t *req)
conn = req->trans->xl_private;
- args.path = alloca (req->msg[0].iov_len);
args.dict.dict_val = alloca (req->msg[0].iov_len);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_setxattr_req)) {
@@ -3507,7 +3495,6 @@ server_setxattr (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = gf_strdup (args.path);
state->flags = args.flags;
memcpy (state->resolve.gfid, args.gfid, 16);
@@ -3595,6 +3582,7 @@ server_fsetxattr (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.fd_no = args.fd;
state->flags = args.flags;
+ memcpy (state->resolve.gfid, args.gfid, 16);
if (args.dict.dict_len) {
dict = dict_new ();
@@ -3732,7 +3720,6 @@ server_xattrop (rpcsvc_request_t *req)
conn = req->trans->xl_private;
args.dict.dict_val = alloca (req->msg[0].iov_len);
- args.path = alloca (req->msg[0].iov_len);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_xattrop_req)) {
//failed to decode msg;
@@ -3756,7 +3743,6 @@ server_xattrop (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = gf_strdup (args.path);
state->flags = args.flags;
memcpy (state->resolve.gfid, args.gfid, 16);
@@ -3808,8 +3794,7 @@ server_getxattr (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
- args.name = alloca (4096);
+ args.name = alloca (256);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_getxattr_req)) {
//failed to decode msg;
@@ -3833,7 +3818,6 @@ server_getxattr (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = gf_strdup (args.path);
memcpy (state->resolve.gfid, args.gfid, 16);
if (args.namelen) {
@@ -3860,7 +3844,7 @@ server_fgetxattr (rpcsvc_request_t *req)
if (!req)
return ret;
- args.name = alloca (4096);
+ args.name = alloca (256);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_fgetxattr_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -3884,6 +3868,7 @@ server_fgetxattr (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.fd_no = args.fd;
+ memcpy (state->resolve.gfid, args.gfid, 16);
if (args.namelen)
state->name = gf_strdup (args.name);
@@ -3907,8 +3892,7 @@ server_removexattr (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
- args.name = alloca (4096);
+ args.name = alloca (256);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_removexattr_req)) {
//failed to decode msg;
@@ -3932,7 +3916,6 @@ server_removexattr (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = gf_strdup (args.path);
memcpy (state->resolve.gfid, args.gfid, 16);
state->name = gf_strdup (args.name);
@@ -3956,8 +3939,6 @@ server_opendir (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
-
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_opendir_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -3980,7 +3961,6 @@ server_opendir (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = gf_strdup (args.path);
memcpy (state->resolve.gfid, args.gfid, 16);
ret = 0;
@@ -4037,6 +4017,7 @@ server_readdirp (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.fd_no = args.fd;
state->offset = args.offset;
+ memcpy (state->resolve.gfid, args.gfid, 16);
ret = 0;
resolve_and_resume (frame, server_readdirp_resume);
@@ -4091,6 +4072,7 @@ server_readdir (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.fd_no = args.fd;
state->offset = args.offset;
+ memcpy (state->resolve.gfid, args.gfid, 16);
ret = 0;
resolve_and_resume (frame, server_readdir_resume);
@@ -4133,6 +4115,7 @@ server_fsyncdir (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.fd_no = args.fd;
state->flags = args.data;
+ memcpy (state->resolve.gfid, args.gfid, 16);
ret = 0;
resolve_and_resume (frame, server_fsyncdir_resume);
@@ -4155,7 +4138,6 @@ server_mknod (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
args.bname = alloca (req->msg[0].iov_len);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_mknod_req)) {
@@ -4208,7 +4190,6 @@ server_mknod (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_NOT;
memcpy (state->resolve.pargfid, args.pargfid, 16);
- state->resolve.path = gf_strdup (args.path);
state->resolve.bname = gf_strdup (args.bname);
state->mode = args.mode;
@@ -4254,7 +4235,6 @@ server_mkdir (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
args.bname = alloca (req->msg[0].iov_len);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_mkdir_req)) {
@@ -4306,7 +4286,6 @@ server_mkdir (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_NOT;
memcpy (state->resolve.pargfid, args.pargfid, 16);
- state->resolve.path = gf_strdup (args.path);
state->resolve.bname = gf_strdup (args.bname);
state->mode = args.mode;
@@ -4348,7 +4327,6 @@ server_rmdir (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
args.bname = alloca (req->msg[0].iov_len);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_rmdir_req)) {
@@ -4374,7 +4352,6 @@ server_rmdir (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
memcpy (state->resolve.pargfid, args.pargfid, 16);
- state->resolve.path = gf_strdup (args.path);
state->resolve.bname = gf_strdup (args.bname);
state->flags = args.flags;
@@ -4399,8 +4376,7 @@ server_inodelk (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
- args.volume = alloca (4096);
+ args.volume = alloca (256);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_inodelk_req)) {
//failed to decode msg;
@@ -4425,7 +4401,6 @@ server_inodelk (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_EXACT;
memcpy (state->resolve.gfid, args.gfid, 16);
- state->resolve.path = gf_strdup (args.path);
cmd = args.cmd;
switch (cmd) {
@@ -4474,7 +4449,7 @@ server_finodelk (rpcsvc_request_t *req)
if (!req)
return ret;
- args.volume = alloca (4096);
+ args.volume = alloca (256);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_finodelk_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -4500,6 +4475,7 @@ server_finodelk (rpcsvc_request_t *req)
state->volume = gf_strdup (args.volume);
state->resolve.fd_no = args.fd;
state->cmd = args.cmd;
+ memcpy (state->resolve.gfid, args.gfid, 16);
switch (state->cmd) {
case GF_LK_GETLK:
@@ -4547,9 +4523,8 @@ server_entrylk (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
- args.volume = alloca (4096);
- args.name = alloca (4096);
+ args.volume = alloca (256);
+ args.name = alloca (256);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_entrylk_req)) {
//failed to decode msg;
@@ -4573,7 +4548,6 @@ server_entrylk (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_EXACT;
- state->resolve.path = gf_strdup (args.path);
memcpy (state->resolve.gfid, args.gfid, 16);
if (args.namelen)
@@ -4600,8 +4574,8 @@ server_fentrylk (rpcsvc_request_t *req)
if (!req)
return ret;
- args.name = alloca (4096);
- args.volume = alloca (4096);
+ args.name = alloca (256);
+ args.volume = alloca (256);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_fentrylk_req)) {
//failed to decode msg;
@@ -4628,6 +4602,7 @@ server_fentrylk (rpcsvc_request_t *req)
state->resolve.fd_no = args.fd;
state->cmd = args.cmd;
state->type = args.type;
+ memcpy (state->resolve.gfid, args.gfid, 16);
if (args.namelen)
state->name = gf_strdup (args.name);
@@ -4650,7 +4625,6 @@ server_access (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_access_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -4674,7 +4648,6 @@ server_access (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
memcpy (state->resolve.gfid, args.gfid, 16);
- state->resolve.path = gf_strdup (args.path);
state->mask = args.mask;
ret = 0;
@@ -4698,7 +4671,6 @@ server_symlink (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
args.bname = alloca (req->msg[0].iov_len);
args.linkname = alloca (4096);
@@ -4752,7 +4724,6 @@ server_symlink (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_NOT;
memcpy (state->resolve.pargfid, args.pargfid, 16);
- state->resolve.path = gf_strdup (args.path);
state->resolve.bname = gf_strdup (args.bname);
state->name = gf_strdup (args.linkname);
@@ -4925,6 +4896,7 @@ server_lk (rpcsvc_request_t *req)
state->resolve.fd_no = args.fd;
state->cmd = args.cmd;
state->type = args.type;
+ memcpy (state->resolve.gfid, args.gfid, 16);
switch (state->cmd) {
case GF_LK_GETLK:
@@ -5052,7 +5024,6 @@ server_lookup (rpcsvc_request_t *req)
conn = req->trans->xl_private;
- args.path = alloca (req->msg[0].iov_len);
args.bname = alloca (req->msg[0].iov_len);
args.dict.dict_val = alloca (req->msg[0].iov_len);
@@ -5080,14 +5051,14 @@ server_lookup (rpcsvc_request_t *req)
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- memcpy (state->resolve.gfid, args.gfid, 16);
state->resolve.type = RESOLVE_DONTCARE;
- memcpy (state->resolve.pargfid, args.pargfid, 16);
- state->resolve.path = gf_strdup (args.path);
- if (IS_NOT_ROOT (STRLEN_0 (args.path))) {
+ if (args.bname && strcmp (args.bname, "")) {
+ memcpy (state->resolve.pargfid, args.pargfid, 16);
state->resolve.bname = gf_strdup (args.bname);
+ } else {
+ memcpy (state->resolve.gfid, args.gfid, 16);
}
if (args.dict.dict_len) {
@@ -5147,7 +5118,6 @@ server_statfs (rpcsvc_request_t *req)
if (!req)
return ret;
- args.path = alloca (req->msg[0].iov_len);
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_statfs_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -5171,7 +5141,6 @@ server_statfs (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
memcpy (state->resolve.gfid, args.gfid, 16);
- state->resolve.path = gf_strdup (args.path);
ret = 0;
resolve_and_resume (frame, server_statfs_resume);