summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmmanuel Dreyfus <manu@netbsd.org>2014-09-06 06:27:03 +0200
committerVijay Bellur <vbellur@redhat.com>2014-09-07 23:23:42 -0700
commite2c916078ea33fe14a208c5b4ba6fe8e52ecda1a (patch)
treeab52913999553247ee09a995b812246b8e2f6168
parentb59ec2c308b19bc1c1be825e6049a3f435039d8a (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. This is a backport of I003a3af055fdad285d235f2a0c192c9cce56fab8 BUG: 1138897 Change-Id: I272cd53e637993c7fd2ac74bd607001d3581ced7 Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org> Reviewed-on: http://review.gluster.org/8634 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--libglusterfs/src/compat-errno.c6
-rw-r--r--xlators/features/marker/src/marker.c6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c3
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c2
-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
7 files changed, 27 insertions, 14 deletions
diff --git a/libglusterfs/src/compat-errno.c b/libglusterfs/src/compat-errno.c
index fd5cc49cef..d8ab82a5d2 100644
--- a/libglusterfs/src/compat-errno.c
+++ b/libglusterfs/src/compat-errno.c
@@ -859,6 +859,12 @@ init_compat_errno_arrays ()
gf_error_to_errno_array[GF_ERROR_CODE_BADMSG] = EBADMSG;
gf_errno_to_error_array[EBADMSG] = GF_ERROR_CODE_BADMSG;
+#ifdef __NetBSD__
+ /* ENODATA 89 / * No message available */
+ gf_error_to_errno_array[GF_ERROR_CODE_NODATA] = ENODATA;
+ gf_errno_to_error_array[ENODATA] = GF_ERROR_CODE_NODATA;
+#endif
+
/* EMULTIHOP 90 / * Multihop attempted */
gf_error_to_errno_array[GF_ERROR_CODE_MULTIHOP] = EMULTIHOP;
gf_errno_to_error_array[EMULTIHOP] = GF_ERROR_CODE_MULTIHOP;
diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c
index adcf3d8e7b..fb86469857 100644
--- a/xlators/features/marker/src/marker.c
+++ b/xlators/features/marker/src/marker.c
@@ -1130,7 +1130,7 @@ marker_rename_release_oldp_lock (call_frame_t *frame, void *cookie,
local = frame->local;
oplocal = local->oplocal;
- if ((op_ret < 0) && (op_errno != ENOATTR)) {
+ if ((op_ret < 0) && (op_errno != ENOATTR) && (op_errno != ENODATA)) {
local->err = op_errno;
}
@@ -1275,7 +1275,7 @@ marker_do_rename (call_frame_t *frame, void *cookie, xlator_t *this,
if (cookie == (void *) _GF_UID_GID_CHANGED)
MARKER_RESET_UID_GID (frame, frame->root, local);
- if ((op_ret < 0) && (op_errno != ENOATTR)) {
+ if ((op_ret < 0) && (op_errno != ENOATTR) && (op_errno != ENODATA)) {
local->err = op_errno ? op_errno : EINVAL;
gf_log (this->name, GF_LOG_WARNING,
"fetching contribution values from %s (gfid:%s) "
@@ -1327,7 +1327,7 @@ marker_get_newpath_contribution (call_frame_t *frame, void *cookie,
if (cookie == (void *) _GF_UID_GID_CHANGED)
MARKER_RESET_UID_GID (frame, frame->root, local);
- if ((op_ret < 0) && (op_errno != ENOATTR)) {
+ if ((op_ret < 0) && (op_errno != ENOATTR) && (op_errno != ENODATA)) {
local->err = op_errno ? op_errno : EINVAL;
gf_log (this->name, GF_LOG_WARNING,
"fetching contribution values from %s (gfid:%s) "
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index e4a4843981..b27204119f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -449,6 +449,9 @@ glusterd_set_quota_limit (char *volname, char *path, char *hard_limit,
sizeof (existing_limit));
if (ret < 0) {
switch (errno) {
+#if defined(ENOATTR) && (ENOATTR != ENODATA)
+ case ENODATA: /* FALLTHROUGH */
+#endif
case ENOATTR:
existing_limit.sl = -1;
break;
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index 0aadb649fb..81697593b7 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -3276,7 +3276,7 @@ fuse_xattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
} /* if(state->name)...else */
} else {
/* if failure - no need to check if listxattr or getxattr */
- if (op_errno != ENODATA) {
+ if (op_errno != ENODATA && op_errno != ENOATTR) {
if (op_errno == ENOTSUP) {
GF_LOG_OCCASIONALLY (gf_fuse_xattr_enotsup_log,
"glusterfs-fuse",
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c
index b6cfbd081e..46ef5ada1f 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 0f596b6069..0654bcd5ee 100644
--- a/xlators/storage/posix/src/posix-handle.h
+++ b/xlators/storage/posix/src/posix-handle.h
@@ -66,7 +66,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 eb0bac66d0..561b8f7f01 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -3792,8 +3792,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;
@@ -4013,7 +4014,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));
@@ -4073,7 +4074,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));
@@ -4128,7 +4130,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));
@@ -5398,15 +5401,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)",