diff options
author | karthik-us <ksubrahm@redhat.com> | 2018-08-03 15:55:18 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-08-20 12:14:22 +0000 |
commit | e37ee6d509aa98587d55f9ea73bc831c10761eaa (patch) | |
tree | 75fe0318642edd954d3c77b0bc5087b9e59184c8 /xlators/storage/posix/src/posix-helpers.c | |
parent | 788cda4cd36574092bef1449ecda579163d06776 (diff) |
posix: Delete the entry if gfid link creation fails
Problem:
If the gfid link file inside .glusterfs is not present for a file,
the operations which are dependent on the gfid will fail,
complaining the link file does not exists inside .glusterfs.
Fix:
If the link file creation fails, fail the entry creation operation
and delete the original file.
Change-Id: Id767511de2da46b1f45aea45cb68b98d965ac96d
fixes: bz#1612037
Signed-off-by: karthik-us <ksubrahm@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r-- | xlators/storage/posix/src/posix-helpers.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index 11265bb802b..d521d80e8aa 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -955,7 +955,8 @@ out: } int -posix_gfid_set (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req) +posix_gfid_set (xlator_t *this, const char *path, loc_t *loc, + dict_t *xattr_req, pid_t pid, int *op_errno) { uuid_t uuid_req; uuid_t uuid_curr; @@ -963,12 +964,24 @@ posix_gfid_set (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req) ssize_t size = 0; struct stat stat = {0, }; + *op_errno = 0; - if (!xattr_req) + if (!xattr_req) { + if (pid != GF_SERVER_PID_TRASH) { + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + P_MSG_INVALID_ARGUMENT, "xattr_req is null"); + *op_errno = EINVAL; + ret = -1; + } goto out; + } - if (sys_lstat (path, &stat) != 0) + if (sys_lstat (path, &stat) != 0) { + ret = -1; + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_LSTAT_FAILED, "lsatat on %s failed", path); goto out; + } size = sys_lgetxattr (path, GFID_XATTR_KEY, uuid_curr, 16); if (size == 16) { @@ -981,12 +994,15 @@ posix_gfid_set (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req) gf_msg_debug (this->name, 0, "failed to get the gfid from dict for %s", loc->path); + *op_errno = -ret; + ret = -1; goto out; } if (gf_uuid_is_null (uuid_req)) { gf_msg (this->name, GF_LOG_ERROR, EINVAL, P_MSG_NULL_GFID, "gfid is null for %s", loc ? loc->path : ""); ret = -1; + *op_errno = EINVAL; goto out; } @@ -1005,6 +1021,8 @@ verify_handle: ret = posix_handle_soft (this, path, loc, uuid_curr, &stat); out: + if (!(*op_errno)) + *op_errno = errno; return ret; } @@ -1712,7 +1730,7 @@ posix_gfid_heal (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req } } - posix_gfid_set (this, path, loc, xattr_req); + posix_gfid_set (this, path, loc, xattr_req, GF_CLIENT_PID_MAX, &ret); return 0; } |