diff options
author | Amar Tumballi <amar@gluster.com> | 2010-09-03 11:46:21 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-04 01:45:41 -0700 |
commit | 2c400f60cad3ac0b9dbf1be06b48675d40fcc824 (patch) | |
tree | d2593d77e0e24a9ffc63f247a2e737c70bde2571 /xlators/protocol | |
parent | 64443fa783c9c43a597440164b35fd8131b7f4d3 (diff) |
gfid: protocol/xdr changes to handle gfid based fops.
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand V. Avati <avati@blackhole.gluster.com>
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 971 (dynamic volume management)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971
Diffstat (limited to 'xlators/protocol')
-rw-r--r-- | xlators/protocol/client/src/client.c | 6 | ||||
-rw-r--r-- | xlators/protocol/client/src/client3_1-fops.c | 548 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-resolve.c | 4 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.h | 2 | ||||
-rw-r--r-- | xlators/protocol/server/src/server3_1-fops.c | 242 |
5 files changed, 394 insertions, 408 deletions
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index f1d99ce6c..f500a4612 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -374,6 +374,7 @@ client_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, args.loc = loc; args.mode = mode; args.rdev = rdev; + args.dict = params; proc = &conf->fops->proctable[GF_FOP_MKNOD]; if (proc->fn) @@ -400,8 +401,9 @@ client_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, if (!conf->fops) goto out; - args.loc = loc; + args.loc = loc; args.mode = mode; + args.dict = params; proc = &conf->fops->proctable[GF_FOP_MKDIR]; if (proc->fn) @@ -483,6 +485,7 @@ client_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath, args.linkname = linkpath; args.loc = loc; + args.dict = params; proc = &conf->fops->proctable[GF_FOP_SYMLINK]; if (proc->fn) @@ -571,6 +574,7 @@ client_create (call_frame_t *frame, xlator_t *this, loc_t *loc, args.flags = flags; args.mode = mode; args.fd = fd; + args.dict = params; proc = &conf->fops->proctable[GF_FOP_CREATE]; if (proc->fn) diff --git a/xlators/protocol/client/src/client3_1-fops.c b/xlators/protocol/client/src/client3_1-fops.c index dffa210ba..9bad8b4ed 100644 --- a/xlators/protocol/client/src/client3_1-fops.c +++ b/xlators/protocol/client/src/client3_1-fops.c @@ -143,16 +143,6 @@ client3_1_symlink_cbk (struct rpc_req *req, struct iovec *iov, int count, if (-1 != rsp.op_ret) { gf_stat_to_iatt (&rsp.stat, &stbuf); - ret = inode_ctx_put2 (inode, frame->this, - stbuf.ia_ino, stbuf.ia_gen); - if (ret < 0) { - gf_log (frame->this->name, GF_LOG_DEBUG, - "SYMLINK %"PRId64"/%s (%s): failed to set " - "remote inode number to inode ctx", - local->loc.parent->ino, local->loc.name, - local->loc.path); - } - gf_stat_to_iatt (&rsp.preparent, &preparent); gf_stat_to_iatt (&rsp.postparent, &postparent); } @@ -205,16 +195,6 @@ client3_1_mknod_cbk (struct rpc_req *req, struct iovec *iov, int count, if (-1 != rsp.op_ret) { gf_stat_to_iatt (&rsp.stat, &stbuf); - ret = inode_ctx_put2 (inode, frame->this, - stbuf.ia_ino, stbuf.ia_gen); - if (ret < 0) { - gf_log (frame->this->name, GF_LOG_DEBUG, - "MKNOD %"PRId64"/%s (%s): failed to set " - "remote inode number to inode ctx", - local->loc.parent->ino, local->loc.name, - local->loc.path); - } - gf_stat_to_iatt (&rsp.preparent, &preparent); gf_stat_to_iatt (&rsp.postparent, &postparent); } @@ -266,16 +246,6 @@ client3_1_mkdir_cbk (struct rpc_req *req, struct iovec *iov, int count, if (-1 != rsp.op_ret) { gf_stat_to_iatt (&rsp.stat, &stbuf); - ret = inode_ctx_put2 (inode, frame->this, - stbuf.ia_ino, stbuf.ia_gen); - if (ret < 0) { - gf_log (frame->this->name, GF_LOG_DEBUG, - "MKDIR %"PRId64"/%s (%s): failed to set " - "remote inode number to inode ctx", - local->loc.parent->ino, local->loc.name, - local->loc.path); - } - gf_stat_to_iatt (&rsp.preparent, &preparent); gf_stat_to_iatt (&rsp.postparent, &postparent); } @@ -300,8 +270,6 @@ client3_1_open_cbk (struct rpc_req *req, struct iovec *iov, int count, clnt_fd_ctx_t *fdctx = NULL; call_frame_t *frame = NULL; fd_t *fd = NULL; - ino_t ino = 0; - uint64_t gen = 0; int ret = 0; gfs3_open_rsp rsp = {0,}; @@ -339,12 +307,8 @@ client3_1_open_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } - inode_ctx_get2 (fd->inode, frame->this, &ino, &gen); - fdctx->remote_fd = rsp.fd; fdctx->inode = inode_ref (fd->inode); - fdctx->ino = ino; - fdctx->gen = gen; fdctx->flags = local->flags; fdctx->wbflags = local->wbflags; @@ -1462,16 +1426,6 @@ client3_1_create_cbk (struct rpc_req *req, struct iovec *iov, int count, if (-1 != rsp.op_ret) { gf_stat_to_iatt (&rsp.stat, &stbuf); - ret = inode_ctx_put2 (inode, frame->this, - stbuf.ia_ino, stbuf.ia_gen); - if (ret < 0) { - gf_log (frame->this->name, GF_LOG_DEBUG, - "CREATE %"PRId64"/%s (%s): failed to set " - "remote inode number to inode ctx", - local->loc.parent->ino, local->loc.name, - local->loc.path); - } - gf_stat_to_iatt (&rsp.preparent, &preparent); gf_stat_to_iatt (&rsp.postparent, &postparent); @@ -1485,8 +1439,6 @@ client3_1_create_cbk (struct rpc_req *req, struct iovec *iov, int count, fdctx->remote_fd = rsp.fd; fdctx->inode = inode_ref (inode); - fdctx->ino = stbuf.ia_ino; - fdctx->gen = stbuf.ia_gen; fdctx->flags = local->flags; INIT_LIST_HEAD (&fdctx->sfd_pos); @@ -1780,8 +1732,6 @@ client3_1_opendir_cbk (struct rpc_req *req, struct iovec *iov, int count, clnt_local_t *local = NULL; clnt_conf_t *conf = NULL; clnt_fd_ctx_t *fdctx = NULL; - ino_t ino = 0; - uint64_t gen = 0; call_frame_t *frame = NULL; fd_t *fd = NULL; int ret = 0; @@ -1822,13 +1772,8 @@ client3_1_opendir_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } - inode_ctx_get2 (fd->inode, frame->this, &ino, &gen); - fdctx->remote_fd = rsp.fd; fdctx->inode = inode_ref (fd->inode); - fdctx->ino = ino; - fdctx->gen = gen; - fdctx->is_dir = 1; INIT_LIST_HEAD (&fdctx->sfd_pos); @@ -1864,8 +1809,6 @@ client3_1_lookup_cbk (struct rpc_req *req, struct iovec *iov, int count, struct iatt stbuf = {0,}; struct iatt postparent = {0,}; int op_errno = EINVAL; - ino_t oldino = 0; - uint64_t oldgen = 0; dict_t *xattr = NULL; inode_t *inode = NULL; char *buf = NULL; @@ -1892,63 +1835,35 @@ client3_1_lookup_cbk (struct rpc_req *req, struct iovec *iov, int count, op_errno = gf_error_to_errno (rsp.op_errno); gf_stat_to_iatt (&rsp.postparent, &postparent); - if (rsp.op_ret == 0) { - rsp.op_ret = -1; - gf_stat_to_iatt (&rsp.stat, &stbuf); - - ret = inode_ctx_get2 (inode, frame->this, &oldino, &oldgen); - if ((!ret) && ((oldino != stbuf.ia_ino) || - (oldgen != stbuf.ia_gen))) { - gf_log (frame->this->name, GF_LOG_DEBUG, - "LOOKUP %"PRId64"/%s (%s): " - "inode number changed from " - "{%"PRId64",%"PRId64"} to {%"PRId64",%"PRId64"}", - local->loc.parent ? - local->loc.parent->ino : (uint64_t) 0, - local->loc.name, - local->loc.path, - oldgen, oldino, stbuf.ia_gen, stbuf.ia_ino); - op_errno = ESTALE; - goto out; - } + if (rsp.op_ret == -1) + goto out; - ret = inode_ctx_put2 (inode, frame->this, - stbuf.ia_ino, stbuf.ia_gen); - if (ret < 0) { - gf_log (frame->this->name, GF_LOG_DEBUG, - "LOOKUP %"PRId64"/%s (%s) : " - "failed to set remote inode " - "number to inode ctx", - local->loc.parent ? - local->loc.parent->ino : (uint64_t) 0, - local->loc.name, - local->loc.path); - } + rsp.op_ret = -1; + gf_stat_to_iatt (&rsp.stat, &stbuf); - if (rsp.dict.dict_len > 0) { - xattr = dict_new(); - GF_VALIDATE_OR_GOTO (frame->this->name, xattr, out); + if (rsp.dict.dict_len > 0) { + xattr = dict_new(); + GF_VALIDATE_OR_GOTO (frame->this->name, xattr, out); - buf = memdup (rsp.dict.dict_val, rsp.dict.dict_len); - GF_VALIDATE_OR_GOTO (frame->this->name, buf, out); + buf = memdup (rsp.dict.dict_val, rsp.dict.dict_len); + GF_VALIDATE_OR_GOTO (frame->this->name, buf, out); - ret = dict_unserialize (buf, rsp.dict.dict_len, &xattr); - if (ret < 0) { - gf_log (frame->this->name, GF_LOG_DEBUG, - "%s (%"PRId64"): failed to " - "unserialize dictionary", - local->loc.path, inode->ino); - op_errno = EINVAL; - goto out; - } - - xattr->extra_free = buf; - buf = NULL; + ret = dict_unserialize (buf, rsp.dict.dict_len, &xattr); + if (ret < 0) { + gf_log (frame->this->name, GF_LOG_DEBUG, + "%s (%"PRId64"): failed to " + "unserialize dictionary", + local->loc.path, inode->ino); + op_errno = EINVAL; + goto out; } - rsp.op_ret = 0; + xattr->extra_free = buf; + buf = NULL; } + rsp.op_ret = 0; + out: rsp.op_errno = op_errno; frame->local = NULL; @@ -2262,8 +2177,7 @@ protocol_client_reopendir (xlator_t *this, clnt_fd_ctx_t *fdctx) goto out; } - req.ino = fdctx->ino; - req.gen = fdctx->gen; + memcpy (req.gfid, inode->gfid, 16); req.path = (char *)local->loc.path; req.gfs_id = GFS3_OP_OPENDIR; @@ -2336,8 +2250,7 @@ protocol_client_reopen (xlator_t *this, clnt_fd_ctx_t *fdctx) path = NULL; frame->local = local; - req.ino = fdctx->ino; - req.gen = fdctx->gen; + memcpy (req.gfid, inode->gfid, 16); req.flags = gf_flags_from_flags (fdctx->flags); req.wbflags = fdctx->wbflags; req.path = (char *)local->loc.path; @@ -2514,24 +2427,16 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this, goto unwind; } + if (!(args->loc && args->loc->inode)) + goto unwind; + loc_copy (&local->loc, args->loc); frame->local = local; - if (args->loc->ino != 1 && args->loc->parent) { - ret = inode_ctx_get2 (args->loc->parent, this, - &req.par, &req.gen); - if (args->loc->parent->ino && ret < 0) { - gf_log (this->name, GF_LOG_TRACE, - "LOOKUP %"PRId64"/%s (%s): failed to get " - "remote inode number for parent", - args->loc->parent->ino, args->loc->name, - args->loc->path); - goto unwind; - } - GF_VALIDATE_OR_GOTO (this->name, args->loc->name, unwind); - } else { - req.ino = 1; - } + if (args->loc->parent) + memcpy (req.pargfid, args->loc->parent->gfid, 16); + else + memcpy (req.gfid, args->loc->inode->gfid, 16); if (args->dict) { content = dict_get (args->dict, GF_CONTENT_KEY); @@ -2638,15 +2543,10 @@ client3_1_stat (call_frame_t *frame, xlator_t *this, goto unwind; args = data; + if (!(args->loc && args->loc->inode)) + goto unwind; - ret = inode_ctx_get2 (args->loc->inode, this, &req.ino, &req.gen); - if (args->loc->inode->ino && ret < 0) { - gf_log (this->name, GF_LOG_TRACE, - "STAT %"PRId64" (%s): " - "failed to get remote inode number", - args->loc->inode->ino, args->loc->path); - goto unwind; - } + memcpy (req.gfid, args->loc->inode->gfid, 16); req.path = (char *)args->loc->path; req.gfs_id = GFS3_OP_STAT; conf = this->private; @@ -2681,14 +2581,10 @@ client3_1_truncate (call_frame_t *frame, xlator_t *this, args = data; - ret = inode_ctx_get2 (args->loc->inode, this, &req.ino, &req.gen); - if (args->loc->inode->ino && ret < 0) { - gf_log (this->name, GF_LOG_TRACE, - "STAT %"PRId64" (%s): " - "failed to get remote inode number", - args->loc->inode->ino, args->loc->path); - goto unwind; - } + if (!(args->loc && args->loc->inode)) + goto unwind; + + memcpy (req.gfid, args->loc->inode->gfid, 16); req.path = (char *)args->loc->path; req.offset = args->offset; req.gfs_id = GFS3_OP_TRUNCATE; @@ -2786,14 +2682,10 @@ client3_1_access (call_frame_t *frame, xlator_t *this, args = data; - ret = inode_ctx_get2 (args->loc->inode, this, &req.ino, &req.gen); - if (args->loc->inode->ino && ret < 0) { - gf_log (this->name, GF_LOG_TRACE, - "STAT %"PRId64" (%s): " - "failed to get remote inode number", - args->loc->inode->ino, args->loc->path); - goto unwind; - } + if (!(args->loc && args->loc->inode)) + goto unwind; + + memcpy (req.gfid, args->loc->inode->gfid, 16); req.path = (char *)args->loc->path; req.mask = args->mask; req.gfs_id = GFS3_OP_ACCESS; @@ -2831,14 +2723,10 @@ client3_1_readlink (call_frame_t *frame, xlator_t *this, args = data; - ret = inode_ctx_get2 (args->loc->inode, this, &req.ino, &req.gen); - if (args->loc->inode->ino && ret < 0) { - gf_log (this->name, GF_LOG_TRACE, - "STAT %"PRId64" (%s): " - "failed to get remote inode number", - args->loc->inode->ino, args->loc->path); - goto unwind; - } + if (!(args->loc && args->loc->inode)) + goto unwind; + + memcpy (req.gfid, args->loc->inode->gfid, 16); req.path = (char *)args->loc->path; req.size = args->size; req.gfs_id = GFS3_OP_READLINK; @@ -2878,14 +2766,10 @@ client3_1_unlink (call_frame_t *frame, xlator_t *this, args = data; - ret = inode_ctx_get2 (args->loc->parent, this, &req.par, &req.gen); - if (args->loc->parent->ino && ret < 0) { - gf_log (this->name, GF_LOG_TRACE, - "STAT %"PRId64"/%s (%s): " - "failed to get remote inode number for parent", - args->loc->parent->ino, args->loc->name, args->loc->path); - goto unwind; - } + if (!(args->loc && args->loc->parent)) + goto unwind; + + memcpy (req.pargfid, args->loc->parent->gfid, 16); req.path = (char *)args->loc->path; req.bname = (char *)args->loc->name; req.gfs_id = GFS3_OP_UNLINK; @@ -2923,14 +2807,10 @@ client3_1_rmdir (call_frame_t *frame, xlator_t *this, args = data; - ret = inode_ctx_get2 (args->loc->parent, this, &req.par, &req.gen); - if (args->loc->inode->ino && ret < 0) { - gf_log (this->name, GF_LOG_TRACE, - "STAT %"PRId64"/%s (%s): " - "failed to get remote inode number for parent", - args->loc->parent->ino, args->loc->name, args->loc->path); - goto unwind; - } + if (!(args->loc && args->loc->parent)) + goto unwind; + + memcpy (req.pargfid, args->loc->parent->gfid, 16); req.path = (char *)args->loc->path; req.bname = (char *)args->loc->name; req.gfs_id = GFS3_OP_RMDIR; @@ -2960,6 +2840,7 @@ client3_1_symlink (call_frame_t *frame, xlator_t *this, clnt_conf_t *conf = NULL; clnt_args_t *args = NULL; gfs3_symlink_req req = {0,}; + size_t dict_len = 0; int ret = 0; int op_errno = ESTALE; @@ -2973,23 +2854,30 @@ client3_1_symlink (call_frame_t *frame, xlator_t *this, goto unwind; } + if (!(args->loc && args->loc->parent)) + goto unwind; + loc_copy (&local->loc, args->loc); frame->local = local; - ret = inode_ctx_get2 (args->loc->parent, this, &req.par, &req.gen); - if (args->loc->parent->ino && ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, - "SYMLINK %"PRId64"/%s (%s): failed to get remote inode" - " number parent", - args->loc->parent->ino, args->loc->name, - args->loc->path); - goto unwind; - } - + memcpy (req.pargfid, args->loc->parent->gfid, 16); req.path = (char *)args->loc->path; req.linkname = (char *)args->linkname; req.bname = (char *)args->loc->name; req.gfs_id = GFS3_OP_SYMLINK; + if (args->dict) { + ret = dict_allocate_and_serialize (args->dict, + &req.dict.dict_val, + &dict_len); + if (ret < 0) { + gf_log (this->name, GF_LOG_DEBUG, + "failed to get serialized length of dict"); + op_errno = EINVAL; + goto unwind; + } + } + req.dict.dict_len = dict_len; + conf = this->private; ret = client_submit_request (this, &req, frame, conf->fops, @@ -3000,6 +2888,9 @@ client3_1_symlink (call_frame_t *frame, xlator_t *this, op_errno = ENOTCONN; goto unwind; } + if (req.dict.dict_val) { + GF_FREE (req.dict.dict_val); + } return 0; unwind: if (frame) @@ -3009,6 +2900,9 @@ unwind: if (local) client_local_wipe (local); + if (req.dict.dict_val) { + GF_FREE (req.dict.dict_val); + } return 0; } @@ -3029,26 +2923,12 @@ client3_1_rename (call_frame_t *frame, xlator_t *this, args = data; - ret = inode_ctx_get2 (args->oldloc->parent, this, - &req.oldpar, &req.oldgen); - if (args->oldloc->parent->ino && ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, - "RENAME %"PRId64"/%s (%s): failed to get remote inode " - "number for source parent", args->oldloc->parent->ino, - args->oldloc->name, args->oldloc->path); - goto unwind; - } + if (!(args->oldloc && args->newloc && args->oldloc->parent && + args->newloc->parent)) + goto unwind; - ret = inode_ctx_get2 (args->newloc->parent, this, &req.newpar, - &req.newgen); - if (args->newloc->parent->ino && ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, - "CREATE %"PRId64"/%s (%s): failed to get remote inode " - "number for destination parent", - args->newloc->parent->ino, args->newloc->name, - args->newloc->path); - goto unwind; - } + memcpy (req.oldgfid, args->oldloc->parent->gfid, 16); + memcpy (req.newgfid, args->newloc->parent->gfid, 16); req.oldpath = (char *)args->oldloc->path; req.oldbname = (char *)args->oldloc->name; @@ -3089,6 +2969,13 @@ client3_1_link (call_frame_t *frame, xlator_t *this, args = data; + if (!(args->oldloc && args->oldloc->inode && args->newloc && + args->newloc->parent)) + goto unwind; + + memcpy (req.oldgfid, args->oldloc->inode->gfid, 16); + memcpy (req.newgfid, args->newloc->parent->gfid, 16); + local = GF_CALLOC (1, sizeof (*local), gf_client_mt_clnt_local_t); if (!local) { op_errno = ENOMEM; @@ -3098,28 +2985,6 @@ client3_1_link (call_frame_t *frame, xlator_t *this, loc_copy (&local->loc, args->oldloc); frame->local = local; - ret = inode_ctx_get2 (args->oldloc->inode, this, - &req.oldino, &req.oldgen); - if (args->oldloc->parent->ino && ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, - "RENAME %"PRId64"/%s (%s): failed to get remote inode " - "number for source parent", args->oldloc->parent->ino, - args->oldloc->name, args->oldloc->path); - op_errno = ENOENT; - goto unwind; - } - - ret = inode_ctx_get2 (args->newloc->parent, this, &req.newpar, - &req.newgen); - if (args->newloc->parent->ino && ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, - "CREATE %"PRId64"/%s (%s): failed to get remote inode " - "number for destination parent", - args->newloc->parent->ino, args->newloc->name, - args->newloc->path); - goto unwind; - } - req.oldpath = (char *)args->oldloc->path; req.newpath = (char *)args->newloc->path; req.newbname = (char *)args->newloc->name; @@ -3149,6 +3014,7 @@ client3_1_mknod (call_frame_t *frame, xlator_t *this, clnt_conf_t *conf = NULL; clnt_args_t *args = NULL; gfs3_mknod_req req = {0,}; + size_t dict_len = 0; int ret = 0; int op_errno = ESTALE; @@ -3163,24 +3029,30 @@ client3_1_mknod (call_frame_t *frame, xlator_t *this, goto unwind; } + if (!(args->loc && args->loc->parent)) + goto unwind; + loc_copy (&local->loc, args->loc); frame->local = local; - ret = inode_ctx_get2 (args->loc->parent, this, &req.par, &req.gen); - if (args->loc->parent->ino && ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, - "SYMLINK %"PRId64"/%s (%s): failed to get remote inode" - " number parent", - args->loc->parent->ino, args->loc->name, - args->loc->path); - goto unwind; - } - + memcpy (req.pargfid, args->loc->parent->gfid, 16); req.path = (char *)args->loc->path; req.bname = (char *)args->loc->name; req.mode = args->mode; req.dev = args->rdev; req.gfs_id = GFS3_OP_MKNOD; + if (args->dict) { + ret = dict_allocate_and_serialize (args->dict, + &req.dict.dict_val, + &dict_len); + if (ret < 0) { + gf_log (this->name, GF_LOG_DEBUG, + "failed to get serialized length of dict"); + op_errno = EINVAL; + goto unwind; + } + } + req.dict.dict_len = dict_len; conf = this->private; @@ -3192,6 +3064,9 @@ client3_1_mknod (call_frame_t *frame, xlator_t *this, op_errno = ENOTCONN; goto unwind; } + if (req.dict.dict_val) { + GF_FREE (req.dict.dict_val); + } return 0; unwind: if (frame) @@ -3201,6 +3076,9 @@ unwind: if (local) client_local_wipe (local); + if (req.dict.dict_val) { + GF_FREE (req.dict.dict_val); + } return 0; } @@ -3214,6 +3092,7 @@ client3_1_mkdir (call_frame_t *frame, xlator_t *this, clnt_conf_t *conf = NULL; clnt_args_t *args = NULL; gfs3_mkdir_req req = {0,}; + size_t dict_len = 0; int ret = 0; int op_errno = ESTALE; @@ -3228,23 +3107,29 @@ client3_1_mkdir (call_frame_t *frame, xlator_t *this, goto unwind; } + if (!(args->loc && args->loc->parent)) + goto unwind; + loc_copy (&local->loc, args->loc); frame->local = local; - ret = inode_ctx_get2 (args->loc->parent, this, &req.par, &req.gen); - if (args->loc->parent->ino && ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, - "SYMLINK %"PRId64"/%s (%s): failed to get remote inode" - " number parent", - args->loc->parent->ino, args->loc->name, - args->loc->path); - goto unwind; - } - + memcpy (req.pargfid, args->loc->parent->gfid, 16); req.path = (char *)args->loc->path; req.bname = (char *)args->loc->name; req.mode = args->mode; req.gfs_id = GFS3_OP_MKDIR; + if (args->dict) { + ret = dict_allocate_and_serialize (args->dict, + &req.dict.dict_val, + &dict_len); + if (ret < 0) { + gf_log (this->name, GF_LOG_DEBUG, + "failed to get serialized length of dict"); + op_errno = EINVAL; + goto unwind; + } + } + req.dict.dict_len = dict_len; conf = this->private; @@ -3256,6 +3141,9 @@ client3_1_mkdir (call_frame_t *frame, xlator_t *this, op_errno = ENOTCONN; goto unwind; } + if (req.dict.dict_val) { + GF_FREE (req.dict.dict_val); + } return 0; unwind: if (frame) @@ -3265,6 +3153,9 @@ unwind: if (local) client_local_wipe (local); + if (req.dict.dict_val) { + GF_FREE (req.dict.dict_val); + } return 0; } @@ -3277,6 +3168,7 @@ client3_1_create (call_frame_t *frame, xlator_t *this, clnt_conf_t *conf = NULL; clnt_args_t *args = NULL; gfs3_create_req req = {0,}; + size_t dict_len = 0; int ret = 0; int op_errno = ESTALE; @@ -3290,26 +3182,33 @@ client3_1_create (call_frame_t *frame, xlator_t *this, op_errno = ENOMEM; goto unwind; } + if (!(args->loc && args->loc->parent)) + goto unwind; + local->fd = fd_ref (args->fd); local->flags = args->flags; + loc_copy (&local->loc, args->loc); frame->local = local; - ret = inode_ctx_get2 (args->loc->parent, this, &req.par, &req.gen); - if (args->loc->parent->ino && ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, - "SYMLINK %"PRId64"/%s (%s): failed to get remote inode" - " number parent", - args->loc->parent->ino, args->loc->name, - args->loc->path); - goto unwind; - } - + memcpy (req.pargfid, args->loc->parent->gfid, 16); req.path = (char *)args->loc->path; req.bname = (char *)args->loc->name; req.mode = args->mode; req.flags = gf_flags_from_flags (args->flags); req.gfs_id = GFS3_OP_CREATE; + if (args->dict) { + ret = dict_allocate_and_serialize (args->dict, + &req.dict.dict_val, + &dict_len); + if (ret < 0) { + gf_log (this->name, GF_LOG_DEBUG, + "failed to get serialized length of dict"); + op_errno = EINVAL; + goto unwind; + } + } + req.dict.dict_len = dict_len; conf = this->private; @@ -3321,6 +3220,9 @@ client3_1_create (call_frame_t *frame, xlator_t *this, op_errno = ENOTCONN; goto unwind; } + if (req.dict.dict_val) { + GF_FREE (req.dict.dict_val); + } return 0; unwind: if (frame) @@ -3330,6 +3232,9 @@ unwind: NULL, NULL); if (local) client_local_wipe (local); + if (req.dict.dict_val) { + GF_FREE (req.dict.dict_val); + } return 0; } @@ -3356,20 +3261,16 @@ client3_1_open (call_frame_t *frame, xlator_t *this, op_errno = ENOMEM; goto unwind; } + if (!(args->loc && args->loc->inode)) + goto unwind; + local->fd = fd_ref (args->fd); local->flags = args->flags; local->wbflags = args->wbflags; loc_copy (&local->loc, args->loc); frame->local = local; - ret = inode_ctx_get2 (args->loc->inode, this, &req.ino, &req.gen); - if (args->loc->inode->ino && ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, - "OPEN %"PRId64" (%s): " - "failed to get remote inode number", - args->loc->inode->ino, args->loc->path); - goto unwind; - } + memcpy (req.gfid, args->loc->inode->gfid, 16); req.flags = gf_flags_from_flags (args->flags); req.wbflags = args->wbflags; req.path = (char *)args->loc->path; @@ -3761,18 +3662,14 @@ client3_1_opendir (call_frame_t *frame, xlator_t *this, op_errno = ENOMEM; goto unwind; } + if (!(args->loc && args->loc->inode)) + goto unwind; + local->fd = fd_ref (args->fd); loc_copy (&local->loc, args->loc); frame->local = local; - ret = inode_ctx_get2 (args->loc->inode, this, &req.ino, &req.gen); - if (args->loc->inode->ino && ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, - "OPEN %"PRId64" (%s): " - "failed to get remote inode number", - args->loc->inode->ino, args->loc->path); - goto unwind; - } + memcpy (req.gfid, args->loc->inode->gfid, 16); req.path = (char *)args->loc->path; req.gfs_id = GFS3_OP_OPENDIR; @@ -3872,22 +3769,10 @@ client3_1_statfs (call_frame_t *frame, xlator_t *this, args = data; - if (args->loc && args->loc->inode) { - if (args->loc->inode->ino == 1) { - req.ino = 1; - req.gen = 0; - } else { - ret = inode_ctx_get2 (args->loc->inode, this, - &req.ino, &req.gen); - if (args->loc->inode->ino && ret < 0) { - gf_log (this->name, GF_LOG_TRACE, - "STATFS %"PRId64" (%s): " - "failed to get remote inode number", - args->loc->inode->ino, args->loc->path); - goto unwind; - } - } - } + if (!(args->loc && args->loc->inode)) + goto unwind; + + memcpy (req.gfid, args->loc->inode->gfid, 16); req.path = (char *)args->loc->path; req.gfs_id = GFS3_OP_STATFS; @@ -3925,14 +3810,10 @@ client3_1_setxattr (call_frame_t *frame, xlator_t *this, args = data; - ret = inode_ctx_get2 (args->loc->inode, this, &req.ino, &req.gen); - if (args->loc->inode->ino && ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, - "SETXATTR %"PRId64" (%s): " - "failed to get remote inode number", - args->loc->inode->ino, args->loc->path); - goto unwind; - } + if (!(args->loc && args->loc->inode)) + goto unwind; + + memcpy (req.gfid, args->loc->inode->gfid, 16); if (args->dict) { ret = dict_allocate_and_serialize (args->dict, &req.dict.dict_val, @@ -4015,7 +3896,7 @@ client3_1_fsetxattr (call_frame_t *frame, xlator_t *this, req.fd = fdctx->remote_fd; req.flags = args->flags; - req.ino = args->fd->inode->ino; + memcpy (req.gfid, args->fd->inode->gfid, 16); req.gfs_id = GFS3_OP_FSETXATTR; if (args->dict) { @@ -4135,15 +4016,10 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this, args = data; - ret = inode_ctx_get2 (args->loc->inode, this, &req.ino, &req.gen); - if (args->loc->inode->ino && ret < 0) { - gf_log (this->name, GF_LOG_TRACE, - "STAT %"PRId64" (%s): " - "failed to get remote inode number", - args->loc->inode->ino, args->loc->path); - goto unwind; - } + if (!(args->loc && args->loc->inode)) + goto unwind; + memcpy (req.gfid, args->loc->inode->gfid, 16); req.namelen = 1; /* Use it as a flag */ req.path = (char *)args->loc->path; req.name = (char *)args->name; @@ -4189,14 +4065,10 @@ client3_1_xattrop (call_frame_t *frame, xlator_t *this, args = data; - ret = inode_ctx_get2 (args->loc->inode, this, &req.ino, &req.gen); - if (args->loc->inode->ino && ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, - "SETXATTR %"PRId64" (%s): " - "failed to get remote inode number", - args->loc->inode->ino, args->loc->path); - goto unwind; - } + if (!(args->loc && args->loc->inode)) + goto unwind; + + memcpy (req.gfid, args->loc->inode->gfid, 16); if (args->dict) { ret = dict_allocate_and_serialize (args->dict, &req.dict.dict_val, @@ -4278,9 +4150,9 @@ client3_1_fxattrop (call_frame_t *frame, xlator_t *this, goto unwind; } - req.fd = fdctx->remote_fd; - req.flags = args->flags; - req.ino = args->fd->inode->ino; + req.fd = fdctx->remote_fd; + req.flags = args->flags; + memcpy (req.gfid, args->fd->inode->gfid, 16); req.gfs_id = GFS3_OP_FXATTROP; if (args->dict) { @@ -4335,14 +4207,10 @@ client3_1_removexattr (call_frame_t *frame, xlator_t *this, args = data; - ret = inode_ctx_get2 (args->loc->inode, this, &req.ino, &req.gen); - if (args->loc->inode->ino && ret < 0) { - gf_log (this->name, GF_LOG_TRACE, - "REMOVEXATTR %"PRId64" (%s): " - "failed to get remote inode number", - args->loc->inode->ino, args->loc->path); - goto unwind; - } + if (!(args->loc && args->loc->inode)) + goto unwind; + + memcpy (req.gfid, args->loc->inode->gfid, 16); req.path = (char *)args->loc->path; req.name = (char *)args->name; req.gfs_id = GFS3_OP_REMOVEXATTR; @@ -4467,15 +4335,10 @@ client3_1_inodelk (call_frame_t *frame, xlator_t *this, goto unwind; args = data; - ret = inode_ctx_get2 (args->loc->inode, this, &req.ino, &req.gen); - if (args->loc->inode->ino && ret < 0) { - gf_log (this->name, GF_LOG_TRACE, - "INODELK %"PRId64" (%s): " - "failed to get remote inode number", - args->loc->inode->ino, args->loc->path); - goto unwind; - } + if (!(args->loc && args->loc->inode)) + goto unwind; + memcpy (req.gfid, args->loc->inode->gfid, 16); if (args->cmd == F_GETLK || args->cmd == F_GETLK64) gf_cmd = GF_LK_GETLK; else if (args->cmd == F_SETLK || args->cmd == F_SETLK64) @@ -4631,14 +4494,10 @@ client3_1_entrylk (call_frame_t *frame, xlator_t *this, args = data; - ret = inode_ctx_get2 (args->loc->inode, this, &req.ino, &req.gen); - if (args->loc->inode->ino && ret < 0) { - gf_log (this->name, GF_LOG_TRACE, - "STAT %"PRId64" (%s): " - "failed to get remote inode number", - args->loc->inode->ino, args->loc->path); - goto unwind; - } + if (!(args->loc && args->loc->inode)) + goto unwind; + + memcpy (req.gfid, args->loc->inode->gfid, 16); req.path = (char *)args->loc->path; req.cmd = args->cmd_entrylk; req.type = args->type; @@ -4932,15 +4791,10 @@ client3_1_setattr (call_frame_t *frame, xlator_t *this, args = data; - ret = inode_ctx_get2 (args->loc->inode, this, &req.ino, &req.gen); - if (args->loc->inode->ino && ret < 0) { - gf_log (this->name, GF_LOG_TRACE, - "STAT %"PRId64" (%s): " - "failed to get remote inode number", - args->loc->inode->ino, args->loc->path); - op_errno = ENOENT; - goto unwind; - } + if (!(args->loc && args->loc->inode)) + goto unwind; + + memcpy (req.gfid, args->loc->inode->gfid, 16); req.path = (char *)args->loc->path; req.valid = args->valid; gf_stat_from_iatt (&req.stbuf, args->stbuf); diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c index eba34bdf7..1a489f6ef 100644 --- a/xlators/protocol/server/src/server-resolve.c +++ b/xlators/protocol/server/src/server-resolve.c @@ -150,9 +150,9 @@ resolve_deep_continue (call_frame_t *frame) resolve->op_ret = 0; resolve->op_errno = 0; - if (resolve->par) + if (resolve->pargfid) ret = resolve_entry_simple (frame); - else if (resolve->ino) + else if (resolve->gfid) ret = resolve_inode_simple (frame); else if (resolve->path) ret = resolve_path_simple (frame); diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h index 453eee57e..a86c6b318 100644 --- a/xlators/protocol/server/src/server.h +++ b/xlators/protocol/server/src/server.h @@ -126,6 +126,8 @@ typedef struct { ino_t ino; uint64_t gen; ino_t par; + u_char gfid[16]; + u_char pargfid[16]; char *path; char *bname; char *resolved; diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c index 173481628..ddcc423fd 100644 --- a/xlators/protocol/server/src/server3_1-fops.c +++ b/xlators/protocol/server/src/server3_1-fops.c @@ -2682,8 +2682,7 @@ server_stat (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_MUST; - state->resolve.ino = args.ino; - state->resolve.gen = args.gen; + memcpy (state->resolve.gfid, args.gfid, 16); state->resolve.path = gf_strdup (args.path); resolve_and_resume (frame, server_stat_resume); @@ -2727,8 +2726,7 @@ server_setattr (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_MUST; - state->resolve.ino = args.ino; - state->resolve.gen = args.gen; + memcpy (state->resolve.gfid, args.gfid, 16); state->resolve.path = gf_strdup (args.path); gf_stat_to_iatt (&args.stbuf, &state->stbuf); @@ -2818,8 +2816,7 @@ server_readlink (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_MUST; - state->resolve.ino = args.ino; - state->resolve.gen = args.gen; + memcpy (state->resolve.gfid, args.gfid, 16); state->resolve.path = gf_strdup (args.path); state->size = args.size; @@ -2835,10 +2832,12 @@ server_create (rpcsvc_request_t *req) { server_state_t *state = NULL; call_frame_t *frame = NULL; + dict_t *params = NULL; + char *buf = NULL; gfs3_create_req args = {0,}; char path[SERVER_PATH_MAX] = {0,}; char bname[SERVER_PATH_MAX] = {0,}; - + int ret = 0; if (!req) return 0; @@ -2865,18 +2864,53 @@ server_create (rpcsvc_request_t *req) req->rpc_err = GARBAGE_ARGS; goto out; } + if (args.dict.dict_len) { + /* Unserialize the dictionary */ + params = dict_new (); + + buf = memdup (args.dict.dict_val, args.dict.dict_len); + if (buf == NULL) { + gf_log (state->conn->bound_xl->name, GF_LOG_ERROR, + "out of memory"); + goto out; + } + + ret = dict_unserialize (buf, args.dict.dict_len, + ¶ms); + if (ret < 0) { + gf_log (state->conn->bound_xl->name, GF_LOG_ERROR, + "%"PRId64": %s (%"PRId64"): failed to " + "unserialize req-buffer to dictionary", + frame->root->unique, state->resolve.path, + state->resolve.ino); + goto out; + } + + state->dict = params; + + params->extra_free = buf; + + buf = NULL; + } state->resolve.type = RESOLVE_NOT; - state->resolve.par = args.par; - state->resolve.gen = args.gen; 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); + memcpy (state->resolve.pargfid, args.pargfid, 16); resolve_and_resume (frame, server_create_resume); + return 0; out: + if (params) + dict_unref (params); + + if (buf) { + GF_FREE (buf); + } return 0; + } @@ -2915,8 +2949,7 @@ server_open (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_MUST; - state->resolve.ino = args.ino; - state->resolve.gen = args.gen; + memcpy (state->resolve.gfid, args.gfid, 16); state->resolve.path = gf_strdup (args.path); state->flags = gf_flags_to_flags (args.flags); @@ -3283,8 +3316,7 @@ server_truncate (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.path = gf_strdup (args.path); - state->resolve.ino = args.ino; - state->resolve.gen = args.gen; + memcpy (state->resolve.gfid, args.gfid, 16); state->offset = args.offset; resolve_and_resume (frame, server_truncate_resume); @@ -3331,10 +3363,9 @@ server_unlink (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_MUST; - state->resolve.par = args.par; - state->resolve.gen = args.gen; state->resolve.path = gf_strdup (args.path); state->resolve.bname = gf_strdup (args.bname); + memcpy (state->resolve.pargfid, args.pargfid, 16); resolve_and_resume (frame, server_unlink_resume); out: @@ -3386,9 +3417,8 @@ server_setxattr (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.path = gf_strdup (args.path); - state->resolve.ino = args.ino; - state->resolve.gen = args.gen; state->flags = args.flags; + memcpy (state->resolve.gfid, args.gfid, 16); if (args.dict.dict_len) { dict = dict_new (); @@ -3547,10 +3577,8 @@ server_fxattrop (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.fd_no = args.fd; - - state->resolve.ino = args.ino; - state->resolve.gen = args.gen; state->flags = args.flags; + memcpy (state->resolve.gfid, args.gfid, 16); if (args.dict.dict_len) { /* Unserialize the dictionary */ @@ -3631,9 +3659,8 @@ server_xattrop (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.path = gf_strdup (args.path); - state->resolve.ino = args.ino; - state->resolve.gen = args.gen; state->flags = args.flags; + memcpy (state->resolve.gfid, args.gfid, 16); if (args.dict.dict_len) { /* Unserialize the dictionary */ @@ -3707,8 +3734,7 @@ server_getxattr (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.path = gf_strdup (args.path); - state->resolve.ino = args.ino; - state->resolve.gen = args.gen; + memcpy (state->resolve.gfid, args.gfid, 16); if (args.namelen) state->name = gf_strdup (args.name); @@ -3802,8 +3828,7 @@ server_removexattr (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.path = gf_strdup (args.path); - state->resolve.ino = args.ino; - state->resolve.gen = args.gen; + memcpy (state->resolve.gfid, args.gfid, 16); state->name = gf_strdup (args.name); resolve_and_resume (frame, server_removexattr_resume); @@ -3850,8 +3875,7 @@ server_opendir (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.path = gf_strdup (args.path); - state->resolve.ino = args.ino; - state->resolve.gen = args.gen; + memcpy (state->resolve.gfid, args.gfid, 16); resolve_and_resume (frame, server_opendir_resume); out: @@ -4010,9 +4034,12 @@ server_mknod (rpcsvc_request_t *req) { server_state_t *state = NULL; call_frame_t *frame = NULL; + dict_t *params = NULL; + char *buf = NULL; gfs3_mknod_req args = {0,}; char bname[SERVER_PATH_MAX] = {0,}; char path[SERVER_PATH_MAX] = {0,}; + int ret = 0; if (!req) return 0; @@ -4041,9 +4068,37 @@ server_mknod (rpcsvc_request_t *req) goto out; } + if (args.dict.dict_len) { + /* Unserialize the dictionary */ + params = dict_new (); + + buf = memdup (args.dict.dict_val, args.dict.dict_len); + if (buf == NULL) { + gf_log (state->conn->bound_xl->name, GF_LOG_ERROR, + "out of memory"); + goto out; + } + + ret = dict_unserialize (buf, args.dict.dict_len, + ¶ms); + if (ret < 0) { + gf_log (state->conn->bound_xl->name, GF_LOG_ERROR, + "%"PRId64": %s (%"PRId64"): failed to " + "unserialize req-buffer to dictionary", + frame->root->unique, state->resolve.path, + state->resolve.ino); + goto out; + } + + state->dict = params; + + params->extra_free = buf; + + buf = NULL; + } + state->resolve.type = RESOLVE_NOT; - state->resolve.par = args.par; - state->resolve.gen = args.gen; + memcpy (state->resolve.pargfid, args.pargfid, 16); state->resolve.path = gf_strdup (args.path); state->resolve.bname = gf_strdup (args.bname); @@ -4051,8 +4106,16 @@ server_mknod (rpcsvc_request_t *req) state->dev = args.dev; resolve_and_resume (frame, server_mknod_resume); + return 0; out: + if (params) + dict_unref (params); + + if (buf) { + GF_FREE (buf); + } return 0; + } @@ -4061,9 +4124,12 @@ server_mkdir (rpcsvc_request_t *req) { server_state_t *state = NULL; call_frame_t *frame = NULL; + dict_t *params = NULL; + char *buf = NULL; gfs3_mkdir_req args = {0,}; char bname[SERVER_PATH_MAX] = {0,}; char path[SERVER_PATH_MAX] = {0,}; + int ret = 0; if (!req) return 0; @@ -4091,18 +4157,53 @@ server_mkdir (rpcsvc_request_t *req) req->rpc_err = GARBAGE_ARGS; goto out; } + if (args.dict.dict_len) { + /* Unserialize the dictionary */ + params = dict_new (); + + buf = memdup (args.dict.dict_val, args.dict.dict_len); + if (buf == NULL) { + gf_log (state->conn->bound_xl->name, GF_LOG_ERROR, + "out of memory"); + goto out; + } + + ret = dict_unserialize (buf, args.dict.dict_len, + ¶ms); + if (ret < 0) { + gf_log (state->conn->bound_xl->name, GF_LOG_ERROR, + "%"PRId64": %s (%"PRId64"): failed to " + "unserialize req-buffer to dictionary", + frame->root->unique, state->resolve.path, + state->resolve.ino); + goto out; + } + + state->dict = params; + + params->extra_free = buf; + + buf = NULL; + } state->resolve.type = RESOLVE_NOT; - state->resolve.par = args.par; - state->resolve.gen = args.gen; + 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; resolve_and_resume (frame, server_mkdir_resume); + return 0; out: + if (params) + dict_unref (params); + + if (buf) { + GF_FREE (buf); + } return 0; + } @@ -4143,8 +4244,7 @@ server_rmdir (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_MUST; - state->resolve.par = args.par; - state->resolve.gen = args.gen; + memcpy (state->resolve.pargfid, args.pargfid, 16); state->resolve.path = gf_strdup (args.path); state->resolve.bname = gf_strdup (args.bname); @@ -4193,8 +4293,7 @@ server_inodelk (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_EXACT; - state->resolve.ino = args.ino; - state->resolve.gen = args.gen; + memcpy (state->resolve.gfid, args.gfid, 16); state->resolve.path = gf_strdup (args.path); cmd = args.cmd; @@ -4344,8 +4443,7 @@ server_entrylk (rpcsvc_request_t *req) state->resolve.type = RESOLVE_EXACT; state->resolve.path = gf_strdup (args.path); - state->resolve.ino = args.ino; - state->resolve.gen = args.gen; + memcpy (state->resolve.gfid, args.gfid, 16); if (args.namelen) state->name = gf_strdup (args.name); @@ -4442,8 +4540,7 @@ server_access (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_MUST; - state->resolve.ino = args.ino; - state->resolve.gen = args.gen; + memcpy (state->resolve.gfid, args.gfid, 16); state->resolve.path = gf_strdup (args.path); state->mask = args.mask; @@ -4459,10 +4556,13 @@ server_symlink (rpcsvc_request_t *req) { server_state_t *state = NULL; call_frame_t *frame = NULL; + dict_t *params = NULL; + char *buf = NULL; gfs3_symlink_req args = {0,}; char linkname[4096] = {0,}; char path[SERVER_PATH_MAX] = {0,}; char bname[4096] = {0,}; + int ret = 0; if (!req) return 0; @@ -4492,15 +4592,50 @@ server_symlink (rpcsvc_request_t *req) goto out; } + if (args.dict.dict_len) { + /* Unserialize the dictionary */ + params = dict_new (); + + buf = memdup (args.dict.dict_val, args.dict.dict_len); + if (buf == NULL) { + gf_log (state->conn->bound_xl->name, GF_LOG_ERROR, + "out of memory"); + goto out; + } + + ret = dict_unserialize (buf, args.dict.dict_len, + ¶ms); + if (ret < 0) { + gf_log (state->conn->bound_xl->name, GF_LOG_ERROR, + "%"PRId64": %s (%"PRId64"): failed to " + "unserialize req-buffer to dictionary", + frame->root->unique, state->resolve.path, + state->resolve.ino); + goto out; + } + + state->dict = params; + + params->extra_free = buf; + + buf = NULL; + } + state->resolve.type = RESOLVE_NOT; - state->resolve.par = args.par; - state->resolve.gen = args.gen; + 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); resolve_and_resume (frame, server_symlink_resume); + return 0; out: + if (params) + dict_unref (params); + + if (buf) { + GF_FREE (buf); + } return 0; } @@ -4546,14 +4681,12 @@ server_link (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.path = gf_strdup (args.oldpath); - state->resolve.ino = args.oldino; - state->resolve.gen = args.oldgen; + memcpy (state->resolve.gfid, args.oldgfid, 16); state->resolve2.type = RESOLVE_NOT; state->resolve2.path = gf_strdup (args.newpath); state->resolve2.bname = gf_strdup (args.newbname); - state->resolve2.par = args.newpar; - state->resolve2.gen = args.newgen; + memcpy (state->resolve2.pargfid, args.newgfid, 16); resolve_and_resume (frame, server_link_resume); out: @@ -4603,14 +4736,12 @@ server_rename (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.path = gf_strdup (args.oldpath); state->resolve.bname = gf_strdup (args.oldbname); - state->resolve.par = args.oldpar; - state->resolve.gen = args.oldgen; + memcpy (state->resolve.pargfid, args.oldgfid, 16); state->resolve2.type = RESOLVE_MAY; state->resolve2.path = gf_strdup (args.newpath); state->resolve2.bname = gf_strdup (args.newbname); - state->resolve2.par = args.newpar; - state->resolve2.gen = args.newgen; + memcpy (state->resolve2.pargfid, args.newgfid, 16); resolve_and_resume (frame, server_rename_resume); out: @@ -4796,13 +4927,10 @@ server_lookup (rpcsvc_request_t *req) req->rpc_err = GARBAGE_ARGS; goto out; } - state->resolve.ino = args.ino; - if (state->resolve.ino != 1) - state->resolve.ino = 0; + memcpy (state->resolve.gfid, args.gfid, 16); state->resolve.type = RESOLVE_DONTCARE; - state->resolve.par = args.par; - state->resolve.gen = args.gen; + memcpy (state->resolve.pargfid, args.pargfid, 16); state->resolve.path = gf_strdup (args.path); if (IS_NOT_ROOT (STRLEN_0 (args.path))) { @@ -4889,9 +5017,7 @@ server_statfs (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_MUST; - state->resolve.ino = args.ino; - if (!state->resolve.ino) - state->resolve.ino = 1; + memcpy (state->resolve.gfid, args.gfid, 16); state->resolve.gen = args.gen; state->resolve.path = gf_strdup (args.path); |