summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-helpers.c
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2017-05-29 21:38:14 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2017-05-31 14:34:46 +0000
commitde92c363c95d16966dbcc9d8763fd4448dd84d13 (patch)
tree01f708ce7234a479cac0711ce714b6c2ddff4ba3 /xlators/storage/posix/src/posix-helpers.c
parentb9406e210717621bc672a63c1cbd1b0183834056 (diff)
posix: use the correct op_errno
Problem: If readdir/fstat was performed on a directory that was removed, posix_fd_ctx_get() fails with ENOENT but we incorrectly use the ret value (-1 in this case) as op_errno, logging "Operation not permitted" messages in the brick logs. Also in case of fstat, the -1 op_errno was also propagated to the client via stack unwind, causing the message to appear in protocol/client logs as well. Fix: Use the right op_errno in readdir, fstat and writev. Also, if posix_fd_ctx_get() failed with ENOENT, convert it into EBADF because ENOENT is not a valid error for an fd operation. Change-Id: Ie43c0789d5040ec73b7cf885d015a183b8c64d70 BUG: 1456582 Signed-off-by: Ravishankar N <ravishankar@redhat.com> Reviewed-on: https://review.gluster.org/17414 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Amar Tumballi <amarts@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index b38c3659fea..1a49af47a8b 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -1684,7 +1684,13 @@ __posix_fd_ctx_get (fd_t *fd, xlator_t *this, struct posix_fd **pfd_p,
if (fd->inode->ia_type == IA_IFDIR) {
dir = sys_opendir (real_path);
if (!dir) {
- op_errno = errno;
+ (errno == ENOENT) ? (op_errno = EBADF) :
+ (op_errno = errno);
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ P_MSG_READ_FAILED,
+ "Failed to get anonymous fd for "
+ "real_path: %s. Returning %s.", real_path,
+ strerror(op_errno));
GF_FREE (pfd);
pfd = NULL;
goto out;
@@ -1705,11 +1711,13 @@ __posix_fd_ctx_get (fd_t *fd, xlator_t *this, struct posix_fd **pfd_p,
_fd = open (unlink_path, fd->flags);
}
if (_fd == -1) {
- op_errno = errno;
- gf_msg (this->name, GF_LOG_ERROR, op_errno,
+ (errno == ENOENT) ? (op_errno = EBADF) :
+ (op_errno = errno);
+ gf_msg (this->name, GF_LOG_ERROR, errno,
P_MSG_READ_FAILED,
- "Failed to get anonymous "
- "real_path: %s _fd = %d", real_path, _fd);
+ "Failed to get anonymous fd for "
+ "real_path: %s. Returning %s.", real_path,
+ strerror(op_errno));
GF_FREE (pfd);
pfd = NULL;
goto out;