summaryrefslogtreecommitdiffstats
path: root/xlators/storage
diff options
context:
space:
mode:
authorEmmanuel Dreyfus <manu@netbsd.org>2014-09-01 14:07:15 +0200
committerVijay Bellur <vbellur@redhat.com>2014-09-08 02:06:52 -0700
commit72324ef5e6a1749fbdb1944b2f088f58090f81b3 (patch)
tree17a70306319cde7b86474b3e5c3781b96693a9aa /xlators/storage
parent165cf459cf2a61c391d16928d58b34543a7ec94e (diff)
Always check for ENODATA with ENOATTR
Linux defines ENODATA and ENOATTR with the same value, which means that code can miss on on the two without breaking. FreeBSD does not have ENODATA and GlusterFS defines it as ENOATTR just like Linux does. On NetBSD, ENODATA != ENOATTR, hence we need to check for both values to get portable behavior. BUG: 764655 Change-Id: I003a3af055fdad285d235f2a0c192c9cce56fab8 Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org> Reviewed-on: http://review.gluster.org/8447 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'xlators/storage')
-rw-r--r--xlators/storage/posix/src/posix-handle.c2
-rw-r--r--xlators/storage/posix/src/posix-handle.h2
-rw-r--r--xlators/storage/posix/src/posix.c20
3 files changed, 14 insertions, 10 deletions
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c
index 48ca77d9e01..9439b295cb9 100644
--- a/xlators/storage/posix/src/posix-handle.c
+++ b/xlators/storage/posix/src/posix-handle.c
@@ -549,7 +549,7 @@ posix_does_old_trash_exists (char *old_trash)
ret = lstat (old_trash, &stbuf);
if ((ret == 0) && S_ISDIR (stbuf.st_mode)) {
ret = sys_lgetxattr (old_trash, "trusted.gfid", gfid, 16);
- if ((ret < 0) && (errno == ENODATA))
+ if ((ret < 0) && (errno == ENODATA || errno == ENOATTR) )
exists = _gf_true;
}
return exists;
diff --git a/xlators/storage/posix/src/posix-handle.h b/xlators/storage/posix/src/posix-handle.h
index fec1447982b..a30e0296140 100644
--- a/xlators/storage/posix/src/posix-handle.h
+++ b/xlators/storage/posix/src/posix-handle.h
@@ -68,7 +68,7 @@
op_ret = sys_lgetxattr (path, key, &value, sizeof (value)); \
if (op_ret == -1) { \
op_errno = errno; \
- if (op_errno == ENOATTR) { \
+ if (op_errno == ENOATTR || op_errno == ENODATA) { \
value = 1; \
} else { \
gf_log (this->name, GF_LOG_WARNING,"getting xattr " \
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index e0fff819c6c..e8d6a8bd66a 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -3910,8 +3910,9 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
size = sys_fgetxattr (_fd, key, NULL, 0);
if (size <= 0) {
op_errno = errno;
- gf_log (this->name, ((errno == ENODATA) ?
- GF_LOG_DEBUG : GF_LOG_ERROR),
+ gf_log (this->name,
+ ((errno == ENODATA || errno == ENOATTR) ?
+ GF_LOG_DEBUG : GF_LOG_ERROR),
"fgetxattr failed on key %s (%s)", key,
strerror (op_errno));
goto done;
@@ -4131,7 +4132,7 @@ _posix_remove_xattr (dict_t *dict, char *key, data_t *value, void *data)
op_ret = sys_lremovexattr (filler->real_path, key);
if (op_ret == -1) {
filler->op_errno = errno;
- if (errno != ENOATTR && errno != EPERM)
+ if (errno != ENOATTR && errno != ENODATA && errno != EPERM)
gf_log (this->name, GF_LOG_ERROR,
"removexattr failed on %s (for %s): %s",
filler->real_path, key, strerror (errno));
@@ -4191,7 +4192,8 @@ posix_removexattr (call_frame_t *frame, xlator_t *this,
op_ret = sys_lremovexattr (real_path, name);
if (op_ret == -1) {
op_errno = errno;
- if (op_errno != ENOATTR && op_errno != EPERM)
+ if (op_errno != ENOATTR && op_errno != ENODATA &&
+ op_errno != EPERM)
gf_log (this->name, GF_LOG_ERROR,
"removexattr on %s (for %s): %s", real_path,
name, strerror (op_errno));
@@ -4246,7 +4248,8 @@ posix_fremovexattr (call_frame_t *frame, xlator_t *this,
op_ret = sys_fremovexattr (_fd, name);
if (op_ret == -1) {
op_errno = errno;
- if (op_errno != ENOATTR && op_errno != EPERM)
+ if (op_errno != ENOATTR && op_errno != ENODATA &&
+ op_errno != EPERM)
gf_log (this->name, GF_LOG_ERROR,
"fremovexattr (for %s): %s",
name, strerror (op_errno));
@@ -5516,15 +5519,16 @@ init (xlator_t *this)
ret = -1;
goto out;
}
- } else if ((size == -1) && (errno == ENODATA)) {
-
+ } else if ((size == -1) &&
+ (errno == ENODATA || errno == ENOATTR)) {
gf_log (this->name, GF_LOG_ERROR,
"Extended attribute trusted.glusterfs."
"volume-id is absent");
ret = -1;
goto out;
- } else if ((size == -1) && (errno != ENODATA)) {
+ } else if ((size == -1) && (errno != ENODATA) &&
+ (errno != ENOATTR)) {
/* Wrong 'volume-id' is set, it should be error */
gf_log (this->name, GF_LOG_WARNING,
"%s: failed to fetch volume-id (%s)",