summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2017-07-06 16:39:37 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2018-01-15 05:00:35 +0000
commit9601ff350dd309714ec3fa746a86e13ac1165591 (patch)
tree0ff15e2b45bcd1e755d77fa1f489e4fa27c5b0ea
parent1a7c263ac670502d26367ac1f93414acf8ae6a0f (diff)
storage/posix: Handle [f]xattrop xdata
Updates #251 Change-Id: I13d89c3b5dc39aa0a232a70be8ec6b64394cfa6e Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: https://review.gluster.org/17740 Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Amar Tumballi <amarts@redhat.com> Reviewed-by: Xavier Hernandez <xhernandez@datalab.es> Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com> (cherry picked from commit 73b2b7fe57069eb85485465fb92c52a97d4d411c)
-rw-r--r--xlators/storage/posix/src/posix-helpers.c23
-rw-r--r--xlators/storage/posix/src/posix.c46
2 files changed, 43 insertions, 26 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 3dfae4df684..bdd6d5a98f8 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -679,6 +679,7 @@ posix_pstat (xlator_t *this, uuid_t gfid, const char *path,
struct stat lstatbuf = {0, };
struct iatt stbuf = {0, };
int ret = 0;
+ int op_errno = 0;
struct posix_private *priv = NULL;
@@ -690,22 +691,12 @@ posix_pstat (xlator_t *this, uuid_t gfid, const char *path,
posix_fill_gfid_path (this, path, &stbuf);
ret = sys_lstat (path, &lstatbuf);
-
- if (ret != 0) {
- if (ret == -1) {
- if (errno != ENOENT)
- gf_msg (this->name, GF_LOG_WARNING, errno,
- P_MSG_LSTAT_FAILED,
- "lstat failed on %s",
- path);
- } else {
- // may be some backend filesytem issue
- gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_LSTAT_FAILED,
- "lstat failed on %s and return value is %d "
- "instead of -1. Please see dmesg output to "
- "check whether the failure is due to backend "
- "filesystem issue", path, ret);
- ret = -1;
+ if (ret == -1) {
+ if (errno != ENOENT) {
+ op_errno = errno;
+ gf_msg (this->name, GF_LOG_WARNING, errno,
+ P_MSG_LSTAT_FAILED, "lstat failed on %s", path);
+ errno = op_errno;/*gf_msg could have changed errno*/
}
goto out;
}
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index d571bf4ac9a..3fd58b62454 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -5758,7 +5758,7 @@ out:
int
do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
- gf_xattrop_flags_t optype, dict_t *xattr)
+ gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata)
{
int op_ret = 0;
int op_errno = 0;
@@ -5767,7 +5767,9 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
struct posix_fd *pfd = NULL;
inode_t *inode = NULL;
posix_xattr_filler_t filler = {0,};
- dict_t *xdata = NULL;
+ dict_t *xattr_rsp = NULL;
+ dict_t *xdata_rsp = NULL;
+ struct iatt stbuf = {0};
VALIDATE_OR_GOTO (frame, out);
VALIDATE_OR_GOTO (xattr, out);
@@ -5800,8 +5802,8 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
inode = fd->inode;
}
- xdata = dict_new ();
- if (xdata == NULL) {
+ xattr_rsp = dict_new ();
+ if (xattr_rsp == NULL) {
op_ret = -1;
op_errno = ENOMEM;
goto out;
@@ -5812,19 +5814,43 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
filler.real_path = real_path;
filler.flags = (int)optype;
filler.inode = inode;
- filler.xattr = xdata;
+ filler.xattr = xattr_rsp;
op_ret = dict_foreach (xattr, _posix_handle_xattr_keyvalue_pair,
&filler);
op_errno = filler.op_errno;
+ if (op_ret < 0)
+ goto out;
+
+ if (!xdata)
+ goto out;
+ if (fd) {
+ op_ret = posix_fdstat (this, _fd, &stbuf);
+ } else {
+ op_ret = posix_pstat (this, inode->gfid, real_path,
+ &stbuf);
+ }
+ if (op_ret < 0) {
+ op_errno = errno;
+ goto out;
+ }
+ xdata_rsp = posix_xattr_fill (this, real_path, loc, fd, _fd,
+ xdata, &stbuf);
+ if (!xdata_rsp) {
+ op_ret = -1;
+ op_errno = ENOMEM;
+ }
out:
- STACK_UNWIND_STRICT (xattrop, frame, op_ret, op_errno, xdata, NULL);
+ STACK_UNWIND_STRICT (xattrop, frame, op_ret, op_errno, xattr_rsp,
+ xdata_rsp);
- if (xdata)
- dict_unref (xdata);
+ if (xattr_rsp)
+ dict_unref (xattr_rsp);
+ if (xdata_rsp)
+ dict_unref (xdata_rsp);
return 0;
}
@@ -5833,7 +5859,7 @@ int
posix_xattrop (call_frame_t *frame, xlator_t *this,
loc_t *loc, gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata)
{
- do_xattrop (frame, this, loc, NULL, optype, xattr);
+ do_xattrop (frame, this, loc, NULL, optype, xattr, xdata);
return 0;
}
@@ -5842,7 +5868,7 @@ int
posix_fxattrop (call_frame_t *frame, xlator_t *this,
fd_t *fd, gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata)
{
- do_xattrop (frame, this, NULL, fd, optype, xattr);
+ do_xattrop (frame, this, NULL, fd, optype, xattr, xdata);
return 0;
}