diff options
Diffstat (limited to 'xlators/protocol')
-rw-r--r-- | xlators/protocol/client/src/client.h | 24 | ||||
-rw-r--r-- | xlators/protocol/client/src/client3_1-fops.c | 124 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-helpers.c | 17 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-resolve.c | 388 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.h | 5 | ||||
-rw-r--r-- | xlators/protocol/server/src/server3_1-fops.c | 85 |
6 files changed, 272 insertions, 371 deletions
diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h index 459ceed70cd..69830db9dc1 100644 --- a/xlators/protocol/client/src/client.h +++ b/xlators/protocol/client/src/client.h @@ -35,28 +35,18 @@ #define CLIENT_CMD_DISCONNECT "trusted.glusterfs.client-disconnect" #define CLIENT_DUMP_LOCKS "trusted.glusterfs.clientlk-dump" -#define CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, label) \ +#define CLIENT_GET_REMOTE_FD(conf, fd, remote_fd, label) \ do { \ + clnt_fd_ctx_t *fdctx = NULL; \ pthread_mutex_lock (&conf->lock); \ { \ - fdctx = this_fd_get_ctx (args->fd, this); \ + fdctx = this_fd_get_ctx (fd, THIS); \ } \ pthread_mutex_unlock (&conf->lock); \ - \ - if (fdctx == NULL) { \ - gf_log (this->name, GF_LOG_WARNING, \ - "(%s): failed to get fd ctx. EBADFD", \ - uuid_utoa (args->fd->inode->gfid)); \ - op_errno = EBADFD; \ - goto label; \ - } \ - \ - if (fdctx->remote_fd == -1) { \ - gf_log (this->name, GF_LOG_WARNING, \ - "(%s): failed to get fd ctx. EBADFD", \ - uuid_utoa (args->fd->inode->gfid)); \ - op_errno = EBADFD; \ - goto label; \ + if (!fdctx) { \ + remote_fd = -2; \ + } else { \ + remote_fd = fdctx->remote_fd; \ } \ } while (0); diff --git a/xlators/protocol/client/src/client3_1-fops.c b/xlators/protocol/client/src/client3_1-fops.c index 9b0fd63cc68..6300b264fb1 100644 --- a/xlators/protocol/client/src/client3_1-fops.c +++ b/xlators/protocol/client/src/client3_1-fops.c @@ -2600,7 +2600,10 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this, } req.path = (char *)args->loc->path; - req.bname = (char *)args->loc->name; + if (args->loc->name) + req.bname = (char *)args->loc->name; + else + req.bname = ""; req.dict.dict_len = dict_len; ret = client_submit_request (this, &req, frame, conf->fops, @@ -2750,7 +2753,7 @@ client3_1_ftruncate (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; gfs3_ftruncate_req req = {{0,},}; int op_errno = EINVAL; @@ -2763,10 +2766,11 @@ client3_1_ftruncate (call_frame_t *frame, xlator_t *this, conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); req.offset = args->offset; - req.fd = fdctx->remote_fd; + req.fd = remote_fd; + memcpy (req.gfid, args->fd->inode->gfid, 16); ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_FTRUNCATE, @@ -3510,7 +3514,7 @@ client3_1_readv (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; int op_errno = ESTALE; gfs3_read_req req = {{0,},}; @@ -3526,11 +3530,12 @@ client3_1_readv (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); req.size = args->size; req.offset = args->offset; - req.fd = fdctx->remote_fd; + req.fd = remote_fd; + memcpy (req.gfid, args->fd->inode->gfid, 16); /* TODO: what is the size we should send ? */ rsp_iobuf = iobuf_get (this->ctx->iobuf_pool); @@ -3601,7 +3606,7 @@ int32_t client3_1_writev (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; gfs3_write_req req = {{0,},}; int op_errno = ESTALE; @@ -3613,11 +3618,12 @@ client3_1_writev (call_frame_t *frame, xlator_t *this, void *data) args = data; conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); req.size = args->size; req.offset = args->offset; - req.fd = fdctx->remote_fd; + req.fd = remote_fd; + memcpy (req.gfid, args->fd->inode->gfid, 16); ret = client_submit_vec_request (this, &req, frame, conf->fops, GFS3_OP_WRITE, client3_1_writev_cbk, args->vector, @@ -3647,7 +3653,7 @@ client3_1_flush (call_frame_t *frame, xlator_t *this, { clnt_args_t *args = NULL; gfs3_flush_req req = {{0,},}; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; clnt_local_t *local = NULL; int op_errno = ESTALE; @@ -3659,7 +3665,7 @@ client3_1_flush (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); conf = this->private; @@ -3674,7 +3680,8 @@ client3_1_flush (call_frame_t *frame, xlator_t *this, local->owner = frame->root->lk_owner; frame->local = local; - req.fd = fdctx->remote_fd; + req.fd = remote_fd; + memcpy (req.gfid, args->fd->inode->gfid, 16); ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_FLUSH, client3_1_flush_cbk, NULL, @@ -3699,7 +3706,7 @@ client3_1_fsync (call_frame_t *frame, xlator_t *this, { clnt_args_t *args = NULL; gfs3_fsync_req req = {{0,},}; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; int op_errno = 0; int ret = 0; @@ -3710,10 +3717,11 @@ client3_1_fsync (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); - req.fd = fdctx->remote_fd; + req.fd = remote_fd; req.data = args->flags; + memcpy (req.gfid, args->fd->inode->gfid, 16); ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_FSYNC, client3_1_fsync_cbk, NULL, @@ -3738,7 +3746,7 @@ client3_1_fstat (call_frame_t *frame, xlator_t *this, { clnt_args_t *args = NULL; gfs3_fstat_req req = {{0,},}; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; int op_errno = ESTALE; int ret = 0; @@ -3749,9 +3757,10 @@ client3_1_fstat (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); - req.fd = fdctx->remote_fd; + req.fd = remote_fd; + memcpy (req.gfid, args->fd->inode->gfid, 16); ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_FSTAT, client3_1_fstat_cbk, NULL, @@ -3834,7 +3843,7 @@ int32_t client3_1_fsyncdir (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; int op_errno = ESTALE; gfs3_fsyncdir_req req = {{0,},}; @@ -3846,10 +3855,11 @@ client3_1_fsyncdir (call_frame_t *frame, xlator_t *this, void *data) args = data; conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); - req.fd = fdctx->remote_fd; + req.fd = remote_fd; req.data = args->flags; + memcpy (req.gfid, args->fd->inode->gfid, 16); conf = this->private; @@ -3994,7 +4004,7 @@ client3_1_fsetxattr (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; gfs3_fsetxattr_req req = {{0,},}; int op_errno = ESTALE; @@ -4007,11 +4017,11 @@ client3_1_fsetxattr (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); - req.fd = fdctx->remote_fd; + req.fd = remote_fd; req.flags = args->flags; - memcpy (req.gfid, args->fd->inode->gfid, 16); + memcpy (req.gfid, args->fd->inode->gfid, 16); if (args->dict) { ret = dict_allocate_and_serialize (args->dict, @@ -4056,7 +4066,7 @@ client3_1_fgetxattr (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; gfs3_fgetxattr_req req = {{0,},}; int op_errno = ESTALE; @@ -4074,7 +4084,7 @@ client3_1_fgetxattr (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); local = GF_CALLOC (1, sizeof (*local), gf_client_mt_clnt_local_t); @@ -4108,12 +4118,13 @@ client3_1_fgetxattr (call_frame_t *frame, xlator_t *this, rsp_iobref = NULL; req.namelen = 1; /* Use it as a flag */ - req.fd = fdctx->remote_fd; + req.fd = remote_fd; req.name = (char *)args->name; if (!req.name) { req.name = ""; req.namelen = 0; } + memcpy (req.gfid, args->fd->inode->gfid, 16); ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_FGETXATTR, @@ -4413,7 +4424,7 @@ client3_1_fxattrop (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; gfs3_fxattrop_req req = {{0,},}; int op_errno = ESTALE; @@ -4432,11 +4443,11 @@ client3_1_fxattrop (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); - req.fd = fdctx->remote_fd; + req.fd = remote_fd; req.flags = args->flags; - memcpy (req.gfid, args->fd->inode->gfid, 16); + memcpy (req.gfid, args->fd->inode->gfid, 16); local = GF_CALLOC (1, sizeof (*local), gf_client_mt_clnt_local_t); @@ -4580,7 +4591,7 @@ client3_1_lk (call_frame_t *frame, xlator_t *this, gfs3_lk_req req = {{0,},}; int32_t gf_cmd = 0; int32_t gf_type = 0; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_local_t *local = NULL; clnt_conf_t *conf = NULL; int op_errno = ESTALE; @@ -4597,7 +4608,7 @@ client3_1_lk (call_frame_t *frame, xlator_t *this, goto unwind; } - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); ret = client_cmd_to_gf_cmd (args->cmd, &gf_cmd); if (ret) { @@ -4624,10 +4635,11 @@ client3_1_lk (call_frame_t *frame, xlator_t *this, local->fd = fd_ref (args->fd); frame->local = local; - req.fd = fdctx->remote_fd; + req.fd = remote_fd; req.cmd = gf_cmd; req.type = gf_type; gf_proto_flock_from_flock (&req.flock, args->flock); + memcpy (req.gfid, args->fd->inode->gfid, 16); ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_LK, client3_1_lk_cbk, NULL, @@ -4733,7 +4745,7 @@ client3_1_finodelk (call_frame_t *frame, xlator_t *this, gfs3_finodelk_req req = {{0,},}; int32_t gf_cmd = 0; int32_t gf_type = 0; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; int op_errno = ESTALE; int ret = 0; @@ -4744,7 +4756,7 @@ client3_1_finodelk (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); if (args->cmd == F_GETLK || args->cmd == F_GETLK64) gf_cmd = GF_LK_GETLK; @@ -4771,10 +4783,11 @@ client3_1_finodelk (call_frame_t *frame, xlator_t *this, } req.volume = (char *)args->volume; - req.fd = fdctx->remote_fd; + req.fd = remote_fd; req.cmd = gf_cmd; req.type = gf_type; gf_proto_flock_from_flock (&req.flock, args->flock); + memcpy (req.gfid, args->fd->inode->gfid, 16); ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_FINODELK, @@ -4857,7 +4870,7 @@ client3_1_fentrylk (call_frame_t *frame, xlator_t *this, { clnt_args_t *args = NULL; gfs3_fentrylk_req req = {{0,},}; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; int op_errno = ESTALE; int ret = 0; @@ -4868,9 +4881,9 @@ client3_1_fentrylk (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); - req.fd = fdctx->remote_fd; + req.fd = remote_fd; req.cmd = args->cmd_entrylk; req.type = args->type; req.volume = (char *)args->volume; @@ -4879,6 +4892,7 @@ client3_1_fentrylk (call_frame_t *frame, xlator_t *this, req.name = (char *)args->basename; req.namelen = 1; } + memcpy (req.gfid, args->fd->inode->gfid, 16); ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_FENTRYLK, @@ -4903,7 +4917,7 @@ client3_1_rchecksum (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; gfs3_rchecksum_req req = {0,}; int op_errno = ESTALE; @@ -4915,11 +4929,11 @@ client3_1_rchecksum (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); req.len = args->len; req.offset = args->offset; - req.fd = fdctx->remote_fd; + req.fd = remote_fd; ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_RCHECKSUM, @@ -4945,7 +4959,7 @@ client3_1_readdir (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; gfs3_readdir_req req = {{0,},}; gfs3_readdir_rsp rsp = {0, }; @@ -4965,7 +4979,7 @@ client3_1_readdir (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); readdir_rsp_size = xdr_sizeof ((xdrproc_t) xdr_gfs3_readdir_rsp, &rsp) + args->size; @@ -5004,7 +5018,8 @@ client3_1_readdir (call_frame_t *frame, xlator_t *this, req.size = args->size; req.offset = args->offset; - req.fd = fdctx->remote_fd; + req.fd = remote_fd; + memcpy (req.gfid, args->fd->inode->gfid, 16); ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_READDIR, @@ -5047,7 +5062,7 @@ client3_1_readdirp (call_frame_t *frame, xlator_t *this, clnt_args_t *args = NULL; gfs3_readdirp_req req = {{0,},}; gfs3_readdirp_rsp rsp = {0,}; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; int op_errno = ESTALE; int ret = 0; @@ -5065,7 +5080,7 @@ client3_1_readdirp (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); readdirp_rsp_size = xdr_sizeof ((xdrproc_t) xdr_gfs3_readdirp_rsp, &rsp) + args->size; @@ -5106,7 +5121,8 @@ client3_1_readdirp (call_frame_t *frame, xlator_t *this, req.size = args->size; req.offset = args->offset; - req.fd = fdctx->remote_fd; + req.fd = remote_fd; + memcpy (req.gfid, args->fd->inode->gfid, 16); ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_READDIRP, @@ -5192,7 +5208,7 @@ int32_t client3_1_fsetattr (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; - clnt_fd_ctx_t *fdctx = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; gfs3_fsetattr_req req = {0,}; int op_errno = ESTALE; @@ -5204,9 +5220,9 @@ client3_1_fsetattr (call_frame_t *frame, xlator_t *this, void *data) args = data; conf = this->private; - CLIENT_GET_FD_CTX(conf, args, fdctx, op_errno, unwind); + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); - req.fd = fdctx->remote_fd; + req.fd = remote_fd; req.valid = args->valid; gf_stat_from_iatt (&req.stbuf, args->stbuf); diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index 45f14dcb36e..f259a651fe1 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 50ae9231c33..38ab368c3f0 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 c8fd5f2717c..6a37482f405 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 60444061d86..8df517be30a 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); |