diff options
author | Ravishankar N <ravishankar@redhat.com> | 2017-08-07 12:14:23 +0530 |
---|---|---|
committer | Raghavendra Bhat <raghavendra@redhat.com> | 2017-08-08 12:54:25 +0000 |
commit | c63aa2239bc682739328e0aa6cbcb3279a72a8e2 (patch) | |
tree | 2288cd9703ca902e8ac418eefb5eff89dce46708 /xlators/storage | |
parent | cdca1cb26a0aba390c6d8485c0d6d95e22ffc8bd (diff) |
posix: add null gfid checks
...in file/dir creation and lookup codepaths. The check is relaxed for
fops coming from trash xlator at the moment until trash has client side
logic to send the create fops with gfid-req.
Also fixed the missing trash pid assignment in creates sent by trash
xlator. Without this, truncated files won't be moved to .trashcan.
Change-Id: Ieddd7f0634850e7c7010e4fbb4ad1eead35888c8
BUG: 1478297
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: https://review.gluster.org/17975
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: jiffin tony Thottan <jthottan@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'xlators/storage')
-rw-r--r-- | xlators/storage/posix/src/posix-helpers.c | 6 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix.c | 8 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix.h | 29 |
3 files changed, 43 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index 1a05d65161a..e09c6d796cb 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -855,6 +855,12 @@ posix_gfid_set (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req) loc->path); 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; + goto out; + } ret = sys_lsetxattr (path, GFID_XATTR_KEY, uuid_req, 16, XATTR_CREATE); if (ret == -1) { diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index bb9865cab58..dc9fc0f8436 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -1365,6 +1365,8 @@ posix_mknod (call_frame_t *frame, xlator_t *this, priv = this->private; VALIDATE_OR_GOTO (priv, out); + GFID_NULL_CHECK_AND_GOTO (frame, this, loc, xdata, op_ret, op_errno, + out); DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out); MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, NULL); @@ -1584,6 +1586,8 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, priv = this->private; VALIDATE_OR_GOTO (priv, out); + GFID_NULL_CHECK_AND_GOTO (frame, this, loc, xdata, op_ret, op_errno, + out); DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out); MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, NULL); @@ -2409,6 +2413,8 @@ posix_symlink (call_frame_t *frame, xlator_t *this, priv = this->private; VALIDATE_OR_GOTO (priv, out); + GFID_NULL_CHECK_AND_GOTO (frame, this, loc, xdata, op_ret, op_errno, + out); DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out); MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &stbuf); @@ -3059,6 +3065,8 @@ posix_create (call_frame_t *frame, xlator_t *this, priv = this->private; VALIDATE_OR_GOTO (priv, out); + GFID_NULL_CHECK_AND_GOTO (frame, this, loc, xdata, op_ret, op_errno, + out); DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out); MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &stbuf); diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h index 3893cf3f9bd..4ba676fb7c0 100644 --- a/xlators/storage/posix/src/posix.h +++ b/xlators/storage/posix/src/posix.h @@ -74,6 +74,35 @@ } \ } while (0) +#define GFID_NULL_CHECK_AND_GOTO(frame, this, loc, xattr_req, op_ret, \ + op_errno, out) \ + do { \ + void *_uuid_req = NULL; \ + int _ret = 0; \ + /* TODO: Remove pid check once trash implements client side \ + * logic to assign gfid for entry creations inside .trashcan \ + */ \ + if (frame->root->pid == GF_SERVER_PID_TRASH) \ + break; \ + _ret = dict_get_ptr (xattr_req, "gfid-req", &_uuid_req); \ + if (_ret) { \ + gf_msg (this->name, GF_LOG_ERROR, EINVAL, \ + P_MSG_NULL_GFID, "failed to get the gfid from" \ + " dict for %s", loc->path); \ + op_ret = -1; \ + op_errno = EINVAL; \ + 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->path); \ + op_ret = -1; \ + op_errno = EINVAL; \ + goto out; \ + } \ + } while (0) + /** * posix_fd - internal structure common to file and directory fd's |