summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix.c
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2016-06-07 21:27:10 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2016-06-26 23:18:13 -0700
commitd5088c056d5aee1bda2997ad5835379465fed3a1 (patch)
tree122fa5d61e5a0e4dd668fb77cbe814e8267b7131 /xlators/storage/posix/src/posix.c
parent0d280e0b7f2042e78b8d94a48d5e3bcc5c13f422 (diff)
storage/posix: Give correct errno for anon-fd operations
Change-Id: Ia9e61d3baa6881eb7dc03dd8ddb6bfdde5a01958 BUG: 1343906 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/14669 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix.c')
-rw-r--r--xlators/storage/posix/src/posix.c62
1 files changed, 27 insertions, 35 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 4294fa4fe36..deecb09a954 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -572,9 +572,8 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (this, out);
VALIDATE_OR_GOTO (fd, out);
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
- op_errno = -ret;
gf_msg_debug (this->name, 0, "pfd is NULL from fd=%p", fd);
goto out;
}
@@ -664,6 +663,7 @@ posix_do_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd,
struct iatt *statpre, struct iatt *statpost, dict_t *xdata)
{
int32_t ret = -1;
+ int32_t op_errno = 0;
struct posix_fd *pfd = NULL;
gf_boolean_t locked = _gf_false;
@@ -675,7 +675,7 @@ posix_do_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd,
VALIDATE_OR_GOTO (this, out);
VALIDATE_OR_GOTO (fd, out);
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
gf_msg_debug (this->name, 0, "pfd is NULL from fd=%p", fd);
goto out;
@@ -820,6 +820,7 @@ posix_do_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
dict_t *xdata)
{
int32_t ret = -1;
+ int32_t op_errno = 0;
struct posix_fd *pfd = NULL;
gf_boolean_t locked = _gf_false;
@@ -831,7 +832,7 @@ posix_do_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
VALIDATE_OR_GOTO (this, out);
VALIDATE_OR_GOTO (fd, out);
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
gf_msg_debug (this->name, 0, "pfd is NULL from fd=%p", fd);
goto out;
@@ -1011,7 +1012,7 @@ posix_seek (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
goto out;
}
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &err);
if (ret < 0) {
gf_msg_debug (this->name, 0, "pfd is NULL from fd=%p", fd);
goto out;
@@ -3060,9 +3061,8 @@ posix_readv (call_frame_t *frame, xlator_t *this,
priv = this->private;
VALIDATE_OR_GOTO (priv, out);
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
- op_errno = -ret;
gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
"pfd is NULL from fd=%p", fd);
goto out;
@@ -3315,7 +3315,7 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
VALIDATE_OR_GOTO (priv, out);
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
gf_msg (this->name, GF_LOG_WARNING, ret, P_MSG_PFD_NULL,
"pfd is NULL from fd=%p", fd);
@@ -3501,9 +3501,8 @@ posix_flush (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (this, out);
VALIDATE_OR_GOTO (fd, out);
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
- op_errno = -ret;
gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
"pfd is NULL on fd=%p", fd);
goto out;
@@ -3624,9 +3623,8 @@ posix_fsync (call_frame_t *frame, xlator_t *this,
return 0;
}
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
- op_errno = -ret;
gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
"pfd not found in fd's ctx");
goto out;
@@ -4731,10 +4729,9 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
SET_FS_ID (frame->root->uid, frame->root->gid);
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
op_ret = -1;
- op_errno = -ret;
gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
"pfd is NULL from fd=%p", fd);
goto out;
@@ -4973,9 +4970,8 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (fd, out);
VALIDATE_OR_GOTO (dict, out);
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
- op_errno = -ret;
gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
"pfd is NULL from fd=%p", fd);
goto out;
@@ -5204,9 +5200,8 @@ posix_fremovexattr (call_frame_t *frame, xlator_t *this,
goto out;
}
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
- op_errno = -ret;
gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
"pfd is NULL from fd=%p", fd);
goto out;
@@ -5265,9 +5260,8 @@ posix_fsyncdir (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (this, out);
VALIDATE_OR_GOTO (fd, out);
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
- op_errno = -ret;
gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
"pfd is NULL, fd=%p", fd);
goto out;
@@ -5637,12 +5631,12 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
VALIDATE_OR_GOTO (this, out);
if (fd) {
- op_ret = posix_fd_ctx_get (fd, this, &pfd);
+ op_ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (op_ret < 0) {
- gf_msg (this->name, GF_LOG_WARNING, EBADFD,
+ gf_msg (this->name, GF_LOG_WARNING,
+ fop_log_level(GF_FOP_FXATTROP, op_errno),
P_MSG_PFD_GET_FAILED, "failed to get pfd from"
" fd=%p", fd);
- op_errno = EBADFD;
goto out;
}
_fd = pfd->fd;
@@ -5772,11 +5766,10 @@ posix_ftruncate (call_frame_t *frame, xlator_t *this,
priv = this->private;
VALIDATE_OR_GOTO (priv, out);
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
- gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL,
+ gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
"pfd is NULL, fd=%p", fd);
- op_errno = -ret;
goto out;
}
@@ -5842,9 +5835,9 @@ posix_fstat (call_frame_t *frame, xlator_t *this,
priv = this->private;
VALIDATE_OR_GOTO (priv, out);
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
- gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL,
+ gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
"pfd is NULL, fd=%p", fd);
op_errno = -ret;
goto out;
@@ -5982,13 +5975,14 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size,
char *hpath = NULL;
int len = 0;
int ret = 0;
+ int op_errno = 0;
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
- gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL,
+ gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
"pfd is NULL, fd=%p", fd);
count = -1;
- errno = -ret;
+ errno = op_errno;
goto out;
}
@@ -6272,11 +6266,10 @@ posix_do_readdir (call_frame_t *frame, xlator_t *this,
INIT_LIST_HEAD (&entries.list);
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL,
"pfd is NULL, fd=%p", fd);
- op_errno = -ret;
goto out;
}
@@ -6445,11 +6438,10 @@ posix_rchecksum (call_frame_t *frame, xlator_t *this,
goto out;
}
- ret = posix_fd_ctx_get (fd, this, &pfd);
+ ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL,
"pfd is NULL, fd=%p", fd);
- op_errno = -ret;
goto out;
}