From 7660b98f1987c24746fe912065a474c7fa189644 Mon Sep 17 00:00:00 2001
From: vmallika <vmallika@redhat.com>
Date: Fri, 7 Aug 2015 15:51:53 +0530
Subject: [PATCH 260/279] posix: posix_make_ancestryfromgfid shouldn't log ENOENT
This is a backport of http://review.gluster.org/11861
posix_make_ancestryfromgfid shouldn't log ENOENT
and it should set proper op_errno
> Change-Id: I8a87f30bc04d33cab06c91c74baa9563a1c7b45d
> BUG: 1251449
> Signed-off-by: vmallika <vmallika@redhat.com>
> Reviewed-on: http://review.gluster.org/11861
> Tested-by: NetBSD Build System <jenkins@build.gluster.org>
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
> Reviewed-by: Manikandan Selvaganesh <mselvaga@redhat.com>
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Change-Id: I5e17413b09ef726b1eeec46adbbce1e5f0503da9
BUG: 1229621
Signed-off-by: vmallika <vmallika@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/55078
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
---
xlators/storage/posix/src/posix-handle.c | 17 ++++++++++++-----
xlators/storage/posix/src/posix-handle.h | 2 +-
xlators/storage/posix/src/posix.c | 5 +++--
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c
index 281d52f..96e7098 100644
--- a/xlators/storage/posix/src/posix-handle.c
+++ b/xlators/storage/posix/src/posix-handle.c
@@ -102,7 +102,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,
gf_dirent_t *head, int type, uuid_t gfid,
const size_t handle_size,
const char *priv_base_path, inode_table_t *itable,
- inode_t **parent, dict_t *xdata)
+ inode_t **parent, dict_t *xdata, int32_t *op_errno)
{
char *linkname = NULL; /* "../../<gfid[0]>/<gfid[1]/"
"<gfidstr>/<NAME_MAX>" */
@@ -117,6 +117,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,
uuid_t tmp_gfid = {0, };
if (!path || !parent || !priv_base_path || gf_uuid_is_null (gfid)) {
+ *op_errno = EINVAL;
goto out;
}
@@ -138,6 +139,8 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,
ret = posix_make_ancestral_node (priv_base_path, path, pathsize,
head, "/", &iabuf, inode, type,
xdata);
+ if (ret < 0)
+ *op_errno = ENOMEM;
return ret;
}
@@ -149,9 +152,12 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,
len = readlink (dir_handle, linkname, PATH_MAX);
if (len < 0) {
- gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READLINK_FAILED,
- "could not read the link from the gfid handle %s ",
- dir_handle);
+ gf_msg (this->name, (errno == ENOENT || errno == ESTALE)
+ ? GF_LOG_DEBUG:GF_LOG_ERROR, errno,
+ P_MSG_READLINK_FAILED, "could not read the link from "
+ "the gfid handle %s ", dir_handle);
+ ret = -1;
+ *op_errno = errno;
goto out;
}
@@ -165,7 +171,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,
ret = posix_make_ancestryfromgfid (this, path, pathsize, head, type,
tmp_gfid, handle_size,
priv_base_path, itable, parent,
- xdata);
+ xdata, op_errno);
if (ret < 0) {
goto out;
}
@@ -174,6 +180,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,
inode = posix_resolve (this, itable, *parent, dir_name, &iabuf);
if (inode == NULL) {
+ *op_errno = ESTALE;
ret = -1;
goto out;
}
diff --git a/xlators/storage/posix/src/posix-handle.h b/xlators/storage/posix/src/posix-handle.h
index 356b7b9..76ef854 100644
--- a/xlators/storage/posix/src/posix-handle.h
+++ b/xlators/storage/posix/src/posix-handle.h
@@ -260,7 +260,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,
const size_t handle_size,
const char *priv_base_path,
inode_table_t *table, inode_t **parent,
- dict_t *xdata);
+ dict_t *xdata, int32_t *op_errno);
int
posix_handle_path_safe (xlator_t *this, uuid_t gfid, const char *basename,
char *buf, size_t len);
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 58f68eb..60acac4 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -3482,7 +3482,8 @@ posix_get_ancestry_directory (xlator_t *this, inode_t *leaf_inode,
type | POSIX_ANCESTRY_PATH,
leaf_inode->gfid,
handle_size, priv->base_path,
- leaf_inode->table, &inode, xdata);
+ leaf_inode->table, &inode, xdata,
+ op_errno);
if (ret < 0)
goto out;
@@ -3736,7 +3737,7 @@ posix_get_ancestry_non_directory (xlator_t *this, inode_t *leaf_inode,
handle_size,
priv->base_path,
leaf_inode->table,
- &parent, xdata);
+ &parent, xdata, op_errno);
if (op_ret < 0) {
goto next;
}
--
1.7.1