diff options
Diffstat (limited to 'xlators/protocol/client/src/client-rpc-fops.c')
| -rw-r--r-- | xlators/protocol/client/src/client-rpc-fops.c | 530 |
1 files changed, 433 insertions, 97 deletions
diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index d541c35eb..6355450c3 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -185,8 +185,7 @@ out: gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s. Path: (%s to %s)", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? local->loc.path : "--", - (local) ? local->loc2.path: "--"); + local->loc.path, local->loc2.path); } CLIENT_STACK_UNWIND (symlink, frame, rsp.op_ret, @@ -252,11 +251,9 @@ client3_3_mknod_cbk (struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, - "remote operation failed: %s. Path: %s (%s)", + "remote operation failed: %s. Path: %s", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? local->loc.path : "--", - (local && local->loc.inode) ? - uuid_utoa (local->loc.inode->gfid) : "--"); + local->loc.path); } CLIENT_STACK_UNWIND (mknod, frame, rsp.op_ret, @@ -320,11 +317,9 @@ client3_3_mkdir_cbk (struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, - "remote operation failed: %s. Path: %s (%s)", + "remote operation failed: %s. Path: %s", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? local->loc.path : "--", - (local && local->loc.inode) ? - uuid_utoa (local->loc.inode->gfid) : "--"); + local->loc.path); } CLIENT_STACK_UNWIND (mkdir, frame, rsp.op_ret, @@ -396,6 +391,7 @@ client_add_fd_to_saved_fds (xlator_t *this, fd_t *fd, loc_t *loc, int32_t flags, fdctx->flags = flags; fdctx->lk_ctx = fd_lk_ctx_ref (fd->lk_ctx); fdctx->lk_heal_state = GF_LK_HEAL_DONE; + fdctx->reopen_done = client_default_reopen_done; INIT_LIST_HEAD (&fdctx->sfd_pos); INIT_LIST_HEAD (&fdctx->lock_list); @@ -465,9 +461,7 @@ out: gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s. Path: %s (%s)", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? local->loc.path : "--", - (local && local->loc.inode) ? - uuid_utoa (local->loc.inode->gfid) : "--"); + local->loc.path, loc_gfid_utoa (&local->loc)); } CLIENT_STACK_UNWIND (open, frame, rsp.op_ret, @@ -575,8 +569,9 @@ client3_3_readlink_cbk (struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", - strerror (gf_error_to_errno (rsp.op_errno))); + gf_log (this->name, (gf_error_to_errno(rsp.op_errno) == ENOENT)? + GF_LOG_DEBUG:GF_LOG_WARNING, "remote operation failed:" + " %s", strerror (gf_error_to_errno (rsp.op_errno))); } CLIENT_STACK_UNWIND (readlink, frame, rsp.op_ret, @@ -636,9 +631,13 @@ client3_3_unlink_cbk (struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", + gf_log (this->name, + ((gf_error_to_errno (rsp.op_errno) == ENOENT) + ? GF_LOG_DEBUG : GF_LOG_WARNING), + "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); } + CLIENT_STACK_UNWIND (unlink, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), &preparent, &postparent, xdata); @@ -830,11 +829,13 @@ client3_3_writev_cbk (struct rpc_req *req, struct iovec *iov, int count, int ret = 0; xlator_t *this = NULL; dict_t *xdata = NULL; + clnt_local_t *local = NULL; this = THIS; frame = myframe; + local = frame->local; if (-1 == req->rpc_status) { rsp.op_ret = -1; @@ -863,6 +864,9 @@ out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); + } else if (rsp.op_ret >= 0) { + if (local->attempt_reopen) + client_attempt_reopen (local->fd, this); } CLIENT_STACK_UNWIND (writev, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), &prestat, @@ -1089,14 +1093,14 @@ client3_3_getxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_log (this->name, (((op_errno == ENOTSUP) || (op_errno == ENODATA)) ? + gf_log (this->name, (((op_errno == ENOTSUP) || + (op_errno == ENODATA) || + (op_errno == ENOENT)) ? GF_LOG_DEBUG : GF_LOG_WARNING), "remote operation failed: %s. Path: %s (%s). Key: %s", strerror (op_errno), - (local) ? local->loc.path : "--", - (local && local->loc.inode) ? - uuid_utoa (local->loc.inode->gfid) : "--", - (local) ? local->name : "(null)"); + local->loc.path, loc_gfid_utoa (&local->loc), + (local->name) ? local->name : "(null)"); } CLIENT_STACK_UNWIND (getxattr, frame, rsp.op_ret, op_errno, dict, xdata); @@ -1539,16 +1543,17 @@ int client3_3_finodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { - call_frame_t *frame = NULL; - gf_common_rsp rsp = {0,}; - int ret = 0; - xlator_t *this = NULL; - dict_t *xdata = NULL; - + call_frame_t *frame = NULL; + gf_common_rsp rsp = {0,}; + int ret = 0; + xlator_t *this = NULL; + dict_t *xdata = NULL; + clnt_local_t *local = NULL; - this = THIS; frame = myframe; + this = frame->this; + local = frame->local; if (-1 == req->rpc_status) { rsp.op_ret = -1; @@ -1572,6 +1577,9 @@ out: (EAGAIN != gf_error_to_errno (rsp.op_errno))) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); + } else if (rsp.op_ret == 0) { + if (local->attempt_reopen) + client_attempt_reopen (local->fd, this); } CLIENT_STACK_UNWIND (finodelk, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), xdata); @@ -1733,9 +1741,7 @@ out: gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s. Path: %s (%s)", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? local->loc.path : "--", - (local && local->loc.inode) ? - uuid_utoa (local->loc.inode->gfid) : "--"); + local->loc.path, loc_gfid_utoa (&local->loc)); } CLIENT_STACK_UNWIND (xattrop, frame, rsp.op_ret, @@ -1803,6 +1809,9 @@ out: gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (op_errno))); + } else if (rsp.op_ret == 0) { + if (local->attempt_reopen) + client_attempt_reopen (local->fd, this); } CLIENT_STACK_UNWIND (fxattrop, frame, rsp.op_ret, gf_error_to_errno (op_errno), dict, xdata); @@ -1927,6 +1936,172 @@ out: return 0; } +int +client3_3_fallocate_cbk (struct rpc_req *req, struct iovec *iov, int count, + void *myframe) +{ + call_frame_t *frame = NULL; + gfs3_fallocate_rsp rsp = {0,}; + struct iatt prestat = {0,}; + struct iatt poststat = {0,}; + int ret = 0; + xlator_t *this = NULL; + dict_t *xdata = NULL; + + + this = THIS; + + frame = myframe; + + if (-1 == req->rpc_status) { + rsp.op_ret = -1; + rsp.op_errno = ENOTCONN; + goto out; + } + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_fallocate_rsp); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + + if (-1 != rsp.op_ret) { + gf_stat_to_iatt (&rsp.statpre, &prestat); + gf_stat_to_iatt (&rsp.statpost, &poststat); + } + + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + +out: + if (rsp.op_ret == -1) { + gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (fallocate, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, + &poststat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); + + return 0; +} + +int +client3_3_discard_cbk(struct rpc_req *req, struct iovec *iov, int count, + void *myframe) +{ + call_frame_t *frame = NULL; + gfs3_discard_rsp rsp = {0,}; + struct iatt prestat = {0,}; + struct iatt poststat = {0,}; + int ret = 0; + xlator_t *this = NULL; + dict_t *xdata = NULL; + + this = THIS; + + frame = myframe; + + if (-1 == req->rpc_status) { + rsp.op_ret = -1; + rsp.op_errno = ENOTCONN; + goto out; + } + ret = xdr_to_generic(*iov, &rsp, (xdrproc_t) xdr_gfs3_discard_rsp); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + + if (-1 != rsp.op_ret) { + gf_stat_to_iatt (&rsp.statpre, &prestat); + gf_stat_to_iatt (&rsp.statpost, &poststat); + } + + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + +out: + if (rsp.op_ret == -1) { + gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (discard, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, + &poststat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); + + return 0; +} + +int +client3_3_zerofill_cbk(struct rpc_req *req, struct iovec *iov, int count, + void *myframe) +{ + call_frame_t *frame = NULL; + gfs3_zerofill_rsp rsp = {0,}; + struct iatt prestat = {0,}; + struct iatt poststat = {0,}; + int ret = 0; + xlator_t *this = NULL; + dict_t *xdata = NULL; + + this = THIS; + + frame = myframe; + + if (-1 == req->rpc_status) { + rsp.op_ret = -1; + rsp.op_errno = ENOTCONN; + goto out; + } + ret = xdr_to_generic(*iov, &rsp, (xdrproc_t) xdr_gfs3_zerofill_rsp); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + + if (-1 != rsp.op_ret) { + gf_stat_to_iatt (&rsp.statpre, &prestat); + gf_stat_to_iatt (&rsp.statpost, &poststat); + } + + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + +out: + if (rsp.op_ret == -1) { + gf_log (this->name, GF_LOG_WARNING, + "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (zerofill, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, + &poststat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); + + return 0; +} int client3_3_setattr_cbk (struct rpc_req *req, struct iovec *iov, int count, @@ -2044,11 +2219,9 @@ client3_3_create_cbk (struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, - "remote operation failed: %s. Path: %s (%s)", + "remote operation failed: %s. Path: %s", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? local->loc.path : "--", - (local && local->loc.inode) ? - uuid_utoa (local->loc.inode->gfid) : "--"); + local->loc.path); } CLIENT_STACK_UNWIND (create, frame, rsp.op_ret, @@ -2443,10 +2616,7 @@ out: gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s (%s -> %s)", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? ((local->loc.path)? local->loc.path : - uuid_utoa (local->loc.inode->gfid)) : "--", - (local) ? ((local->loc2.path)? local->loc2.path : - local->loc2.name) : "--"); + local->loc.path, local->loc2.path); } CLIENT_STACK_UNWIND (link, frame, rsp.op_ret, @@ -2516,9 +2686,7 @@ out: gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s. Path: %s (%s)", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? local->loc.path : "--", - (local && local->loc.inode) ? - uuid_utoa (local->loc.inode->gfid) : "--"); + local->loc.path, loc_gfid_utoa (&local->loc)); } CLIENT_STACK_UNWIND (opendir, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), fd, xdata); @@ -2598,10 +2766,8 @@ out: if (rsp.op_errno != ENOENT) gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s. Path: %s (%s)", - strerror (rsp.op_errno), - (local) ? local->loc.path : "--", - (local && local->loc.inode) ? - uuid_utoa (local->loc.inode->gfid) : "--"); + strerror (rsp.op_errno), local->loc.path, + loc_gfid_utoa (&local->loc)); else gf_log (this->name, GF_LOG_TRACE, "not found on remote node"); @@ -2675,6 +2841,9 @@ out: gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); + } else if (rsp.op_ret >= 0) { + if (local->attempt_reopen) + client_attempt_reopen (local->fd, this); } CLIENT_STACK_UNWIND (readv, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), vector, rspcount, @@ -2754,7 +2923,7 @@ client_fdctx_destroy (xlator_t *this, clnt_fd_ctx_t *fdctx) if (fdctx->is_dir) { gfs3_releasedir_req req = {{0,},}; req.fd = fdctx->remote_fd; - gf_log (this->name, GF_LOG_DEBUG, "sending releasedir on fd"); + gf_log (this->name, GF_LOG_TRACE, "sending releasedir on fd"); client_submit_request (this, &req, fr, &clnt3_3_fop_prog, GFS3_OP_RELEASEDIR, client3_3_releasedir_cbk, @@ -2763,7 +2932,7 @@ client_fdctx_destroy (xlator_t *this, clnt_fd_ctx_t *fdctx) } else { gfs3_release_req req = {{0,},}; req.fd = fdctx->remote_fd; - gf_log (this->name, GF_LOG_DEBUG, "sending release on fd"); + gf_log (this->name, GF_LOG_TRACE, "sending release on fd"); client_submit_request (this, &req, fr, &clnt3_3_fop_prog, GFS3_OP_RELEASE, client3_3_release_cbk, NULL, @@ -2903,6 +3072,7 @@ client3_3_lookup (call_frame_t *frame, xlator_t *this, goto unwind; loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); frame->local = local; if (args->loc->parent) { @@ -3111,7 +3281,8 @@ client3_3_ftruncate (call_frame_t *frame, xlator_t *this, conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); req.offset = args->offset; req.fd = remote_fd; @@ -3418,6 +3589,7 @@ client3_3_symlink (call_frame_t *frame, xlator_t *this, goto unwind; loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); if (!uuid_is_null (args->loc->parent->gfid)) memcpy (req.pargfid, args->loc->parent->gfid, 16); @@ -3567,7 +3739,9 @@ client3_3_link (call_frame_t *frame, xlator_t *this, } loc_copy (&local->loc, args->oldloc); + loc_path (&local->loc, NULL); loc_copy (&local->loc2, args->newloc); + loc_path (&local->loc2, NULL); frame->local = local; req.newbname = (char *)args->newloc->name; @@ -3622,6 +3796,7 @@ client3_3_mknod (call_frame_t *frame, xlator_t *this, goto unwind; loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); frame->local = local; if (!uuid_is_null (args->loc->parent->gfid)) @@ -3689,6 +3864,7 @@ client3_3_mkdir (call_frame_t *frame, xlator_t *this, goto unwind; loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); frame->local = local; if (!uuid_is_null (args->loc->parent->gfid)) @@ -3757,6 +3933,7 @@ client3_3_create (call_frame_t *frame, xlator_t *this, local->flags = args->flags; loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); frame->local = local; if (!uuid_is_null (args->loc->parent->gfid)) @@ -3826,6 +4003,7 @@ client3_3_open (call_frame_t *frame, xlator_t *this, local->fd = fd_ref (args->fd); local->flags = args->flags; loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); frame->local = local; if (!uuid_is_null (args->loc->inode->gfid)) @@ -3871,13 +4049,13 @@ client3_3_readv (call_frame_t *frame, xlator_t *this, clnt_args_t *args = NULL; int64_t remote_fd = -1; clnt_conf_t *conf = NULL; + clnt_local_t *local = NULL; int op_errno = ESTALE; gfs3_read_req req = {{0,},}; int ret = 0; struct iovec rsp_vec = {0, }; struct iobuf *rsp_iobuf = NULL; struct iobref *rsp_iobref = NULL; - clnt_local_t *local = NULL; if (!frame || !this || !data) goto unwind; @@ -3885,7 +4063,14 @@ client3_3_readv (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, FALLBACK_TO_ANON_FD, + remote_fd, op_errno, unwind); + ret = client_fd_fop_prepare_local (frame, args->fd, remote_fd); + if (ret) { + op_errno = -ret; + goto unwind; + } + local = frame->local; req.size = args->size; req.offset = args->offset; @@ -3923,15 +4108,8 @@ client3_3_readv (call_frame_t *frame, xlator_t *this, goto unwind; } - local = mem_get0 (this->local_pool); - if (local == NULL) { - op_errno = ENOMEM; - goto unwind; - } - local->iobref = rsp_iobref; rsp_iobref = NULL; - frame->local = local; GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), req.xdata.xdata_len, op_errno, unwind); @@ -3942,17 +4120,12 @@ client3_3_readv (call_frame_t *frame, xlator_t *this, local->iobref, (xdrproc_t)xdr_gfs3_read_req); if (ret) { + //unwind is done in the cbk gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } GF_FREE (req.xdata.xdata_val); - if (rsp_iobuf) - iobuf_unref (rsp_iobuf); - - if (rsp_iobref) - iobref_unref (rsp_iobref); - return 0; unwind: if (rsp_iobuf) @@ -3976,7 +4149,7 @@ client3_3_writev (call_frame_t *frame, xlator_t *this, void *data) clnt_conf_t *conf = NULL; gfs3_write_req req = {{0,},}; int op_errno = ESTALE; - int ret = 0; + int ret = 0; if (!frame || !this || !data) goto unwind; @@ -3984,7 +4157,13 @@ client3_3_writev (call_frame_t *frame, xlator_t *this, void *data) args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, FALLBACK_TO_ANON_FD, + remote_fd, op_errno, unwind); + ret = client_fd_fop_prepare_local (frame, args->fd, remote_fd); + if (ret) { + op_errno = -ret; + goto unwind; + } req.size = args->size; req.offset = args->offset; @@ -4048,7 +4227,8 @@ client3_3_flush (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); conf = this->private; @@ -4107,7 +4287,8 @@ client3_3_fsync (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); req.fd = remote_fd; req.data = args->flags; @@ -4155,7 +4336,8 @@ client3_3_fstat (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); req.fd = remote_fd; memcpy (req.gfid, args->fd->inode->gfid, 16); @@ -4210,6 +4392,7 @@ client3_3_opendir (call_frame_t *frame, xlator_t *this, local->fd = fd_ref (args->fd); loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); frame->local = local; if (!uuid_is_null (args->loc->inode->gfid)) @@ -4264,7 +4447,8 @@ client3_3_fsyncdir (call_frame_t *frame, xlator_t *this, void *data) args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); req.fd = remote_fd; req.data = args->flags; @@ -4433,7 +4617,8 @@ client3_3_fsetxattr (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); req.fd = remote_fd; req.flags = args->flags; @@ -4497,7 +4682,8 @@ client3_3_fgetxattr (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); local = mem_get0 (this->local_pool); if (!local) { @@ -4613,6 +4799,7 @@ client3_3_getxattr (call_frame_t *frame, xlator_t *this, } loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); if (args->name) local->name = gf_strdup (args->name); @@ -4777,6 +4964,8 @@ client3_3_xattrop (call_frame_t *frame, xlator_t *this, else memcpy (req.gfid, args->loc->gfid, 16); + loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); GF_ASSERT_AND_GOTO_WITH_ERROR (this->name, !uuid_is_null (*((uuid_t*)req.gfid)), unwind, op_errno, EINVAL); @@ -4840,11 +5029,11 @@ client3_3_fxattrop (call_frame_t *frame, xlator_t *this, clnt_args_t *args = NULL; int64_t remote_fd = -1; clnt_conf_t *conf = NULL; + clnt_local_t *local = NULL; gfs3_fxattrop_req req = {{0,},}; int op_errno = ESTALE; int ret = 0; int count = 0; - clnt_local_t *local = NULL; struct iobref *rsp_iobref = NULL; struct iobuf *rsp_iobuf = NULL; struct iovec *rsphdr = NULL; @@ -4856,19 +5045,20 @@ client3_3_fxattrop (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, FALLBACK_TO_ANON_FD, + remote_fd, op_errno, unwind); + ret = client_fd_fop_prepare_local (frame, args->fd, remote_fd); + if (ret) { + op_errno = -ret; + goto unwind; + } + + local = frame->local; req.fd = remote_fd; req.flags = args->flags; memcpy (req.gfid, args->fd->inode->gfid, 16); - local = mem_get0 (this->local_pool); - if (!local) { - op_errno = ENOMEM; - goto unwind; - } - frame->local = local; - rsp_iobref = iobref_new (); if (rsp_iobref == NULL) { op_errno = ENOMEM; @@ -4916,12 +5106,6 @@ client3_3_fxattrop (call_frame_t *frame, xlator_t *this, GF_FREE (req.xdata.xdata_val); - if (rsp_iobuf) - iobuf_unref (rsp_iobuf); - - if (rsp_iobref) - iobref_unref (rsp_iobref); - return 0; unwind: CLIENT_STACK_UNWIND (fxattrop, frame, -1, op_errno, NULL, NULL); @@ -5013,7 +5197,8 @@ client3_3_fremovexattr (call_frame_t *frame, xlator_t *this, conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); memcpy (req.gfid, args->fd->inode->gfid, 16); req.name = (char *)args->name; @@ -5066,7 +5251,8 @@ client3_3_lk (call_frame_t *frame, xlator_t *this, goto unwind; } - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); ret = client_cmd_to_gf_cmd (args->cmd, &gf_cmd); if (ret) { @@ -5216,15 +5402,20 @@ client3_3_finodelk (call_frame_t *frame, xlator_t *this, int64_t remote_fd = -1; clnt_conf_t *conf = NULL; int op_errno = ESTALE; - int ret = 0; + int ret = 0; if (!frame || !this || !data) goto unwind; args = data; conf = this->private; - - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, FALLBACK_TO_ANON_FD, + remote_fd, op_errno, unwind); + ret = client_fd_fop_prepare_local (frame, args->fd, remote_fd); + if (ret) { + op_errno = -ret; + goto unwind; + } if (args->cmd == F_GETLK || args->cmd == F_GETLK64) gf_cmd = GF_LK_GETLK; @@ -5357,7 +5548,8 @@ client3_3_fentrylk (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); req.fd = remote_fd; req.cmd = args->cmd_entrylk; @@ -5410,7 +5602,8 @@ client3_3_rchecksum (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); req.len = args->len; req.offset = args->offset; @@ -5466,7 +5659,8 @@ client3_3_readdir (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); readdir_rsp_size = xdr_sizeof ((xdrproc_t) xdr_gfs3_readdir_rsp, &rsp) + args->size; @@ -5575,7 +5769,8 @@ client3_3_readdirp (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); readdirp_rsp_size = xdr_sizeof ((xdrproc_t) xdr_gfs3_readdirp_rsp, &rsp) + args->size; @@ -5728,7 +5923,8 @@ client3_3_fsetattr (call_frame_t *frame, xlator_t *this, void *data) args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); req.fd = remote_fd; req.valid = args->valid; @@ -5756,7 +5952,140 @@ unwind: return 0; } +int32_t +client3_3_fallocate(call_frame_t *frame, xlator_t *this, void *data) +{ + clnt_args_t *args = NULL; + int64_t remote_fd = -1; + clnt_conf_t *conf = NULL; + gfs3_fallocate_req req = {{0},}; + int op_errno = ESTALE; + int ret = 0; + + if (!frame || !this || !data) + goto unwind; + + args = data; + conf = this->private; + + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); + + req.fd = remote_fd; + req.flags = args->flags; + req.offset = args->offset; + req.size = args->size; + memcpy(req.gfid, args->fd->inode->gfid, 16); + + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + + ret = client_submit_request (this, &req, frame, conf->fops, + GFS3_OP_FALLOCATE, + client3_3_fallocate_cbk, NULL, + NULL, 0, NULL, 0, + NULL, (xdrproc_t)xdr_gfs3_fallocate_req); + if (ret) { + gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); + + return 0; +unwind: + CLIENT_STACK_UNWIND (fallocate, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + + return 0; +} + +int32_t +client3_3_discard(call_frame_t *frame, xlator_t *this, void *data) +{ + clnt_args_t *args = NULL; + int64_t remote_fd = -1; + clnt_conf_t *conf = NULL; + gfs3_discard_req req = {{0},}; + int op_errno = ESTALE; + int ret = 0; + if (!frame || !this || !data) + goto unwind; + + args = data; + conf = this->private; + + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); + + req.fd = remote_fd; + req.offset = args->offset; + req.size = args->size; + memcpy(req.gfid, args->fd->inode->gfid, 16); + + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + + ret = client_submit_request(this, &req, frame, conf->fops, + GFS3_OP_DISCARD, client3_3_discard_cbk, + NULL, NULL, 0, NULL, 0, NULL, + (xdrproc_t) xdr_gfs3_discard_req); + if (ret) + gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); + + GF_FREE (req.xdata.xdata_val); + + return 0; +unwind: + CLIENT_STACK_UNWIND(discard, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + + return 0; +} + +int32_t +client3_3_zerofill(call_frame_t *frame, xlator_t *this, void *data) +{ + clnt_args_t *args = NULL; + int64_t remote_fd = -1; + clnt_conf_t *conf = NULL; + gfs3_zerofill_req req = {{0},}; + int op_errno = ESTALE; + int ret = 0; + + if (!frame || !this || !data) + goto unwind; + + args = data; + conf = this->private; + + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); + + req.fd = remote_fd; + req.offset = args->offset; + req.size = args->size; + memcpy(req.gfid, args->fd->inode->gfid, 16); + + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + + ret = client_submit_request(this, &req, frame, conf->fops, + GFS3_OP_ZEROFILL, client3_3_zerofill_cbk, + NULL, NULL, 0, NULL, 0, NULL, + (xdrproc_t) xdr_gfs3_zerofill_req); + if (ret) + gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); + + GF_FREE (req.xdata.xdata_val); + + return 0; +unwind: + CLIENT_STACK_UNWIND(zerofill, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + + return 0; +} /* Table Specific to FOPS */ @@ -5803,6 +6132,9 @@ rpc_clnt_procedure_t clnt3_3_fop_actors[GF_FOP_MAXVALUE] = { [GF_FOP_SETATTR] = { "SETATTR", client3_3_setattr }, [GF_FOP_FSETATTR] = { "FSETATTR", client3_3_fsetattr }, [GF_FOP_READDIRP] = { "READDIRP", client3_3_readdirp }, + [GF_FOP_FALLOCATE] = { "FALLOCATE", client3_3_fallocate }, + [GF_FOP_DISCARD] = { "DISCARD", client3_3_discard }, + [GF_FOP_ZEROFILL] = { "ZEROFILL", client3_3_zerofill}, [GF_FOP_RELEASE] = { "RELEASE", client3_3_release }, [GF_FOP_RELEASEDIR] = { "RELEASEDIR", client3_3_releasedir }, [GF_FOP_GETSPEC] = { "GETSPEC", client3_getspec }, @@ -5855,6 +6187,10 @@ char *clnt3_3_fop_names[GFS3_OP_MAXVALUE] = { [GFS3_OP_RELEASE] = "RELEASE", [GFS3_OP_RELEASEDIR] = "RELEASEDIR", [GFS3_OP_FREMOVEXATTR] = "FREMOVEXATTR", + [GFS3_OP_FALLOCATE] = "FALLOCATE", + [GFS3_OP_DISCARD] = "DISCARD", + [GFS3_OP_ZEROFILL] = "ZEROFILL", + }; rpc_clnt_prog_t clnt3_3_fop_prog = { |
