summaryrefslogtreecommitdiffstats
path: root/xlators/storage
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2018-05-04 12:25:48 -0400
committerAmar Tumballi <amarts@redhat.com>2018-05-18 04:19:32 +0000
commitc2cf3f686f3ea0efd936d2eafc404fc9d2e0acc7 (patch)
tree05cf07ba57fa8510d698e6f9c049146aa98b5c3e /xlators/storage
parent7588be808db3fcfda337971990f02d2ebccba3d7 (diff)
make posix return errors when gfid2path key is absent
Change-Id: I3a8d452d00560dac5e0b7ff0b1835d1f20a59f91 updates: bz#1570962 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'xlators/storage')
-rw-r--r--xlators/storage/posix/src/posix-gfid-path.c26
-rw-r--r--xlators/storage/posix/src/posix-gfid-path.h1
2 files changed, 27 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix-gfid-path.c b/xlators/storage/posix/src/posix-gfid-path.c
index 2834c2fc4fd..9873e7e5a84 100644
--- a/xlators/storage/posix/src/posix-gfid-path.c
+++ b/xlators/storage/posix/src/posix-gfid-path.c
@@ -123,6 +123,7 @@ posix_get_gfid2path (xlator_t *this, inode_t *inode, const char *real_path,
gf_boolean_t have_val = _gf_false;
struct posix_private *priv = NULL;
char pargfid_str[UUID_CANONICAL_FORM_LEN + 1] = {0,};
+ gf_boolean_t found = _gf_false;
priv = this->private;
@@ -141,6 +142,7 @@ posix_get_gfid2path (xlator_t *this, inode_t *inode, const char *real_path,
"value for key (%s)", GFID2PATH_VIRT_XATTR_KEY);
goto err;
}
+ found = _gf_true;
} else {
have_val = _gf_false;
memset (value_buf, '\0', sizeof(value_buf));
@@ -202,6 +204,7 @@ posix_get_gfid2path (xlator_t *this, inode_t *inode, const char *real_path,
goto ignore;
}
+ found = _gf_true;
memset (value_buf, '\0', sizeof(value_buf));
size = sys_lgetxattr (real_path, keybuffer, value_buf,
sizeof (value_buf) - 1);
@@ -231,6 +234,29 @@ ignore:
list_offset += strlen (keybuffer) + 1;
} /* while (remaining_size > 0) */
+ /* gfid2path xattr is absent in the list of xattrs */
+ if (!found) {
+ ret = -1;
+ /*
+ * ENODATA because xattr is not present in the
+ * list of xattrs. Thus the consumer should
+ * face error instead of a success and a empty
+ * string in the dict for the key.
+ */
+ *op_errno = ENODATA;
+ goto err;
+ }
+
+ /*
+ * gfid2path xattr is found in list of xattrs, but getxattr
+ * on the 1st gfid2path xattr itself failed and the while
+ * loop above broke. So there is nothing in the value. So
+ * it would be better not to send "" as the value for any
+ * key, as it is not true.
+ */
+ if (found && !i)
+ goto err; /* both errno and ret are set before beak */
+
/* Calculate memory to be allocated */
for (j = 0; j < i; j++) {
bytes += strlen(paths[j]);
diff --git a/xlators/storage/posix/src/posix-gfid-path.h b/xlators/storage/posix/src/posix-gfid-path.h
index ac3d03e14c3..59799125bbb 100644
--- a/xlators/storage/posix/src/posix-gfid-path.h
+++ b/xlators/storage/posix/src/posix-gfid-path.h
@@ -13,6 +13,7 @@
#include "xlator.h"
#include "common-utils.h"
+#include "compat-errno.h"
#define MAX_GFID2PATH_LINK_SUP 500