From 517316470e8e309e0e572264ee3c02b0748acab1 Mon Sep 17 00:00:00 2001 From: Ravishankar N Date: Tue, 8 Aug 2017 21:42:03 +0530 Subject: posix: add null gfid checks (Backport of https://review.gluster.org/17975) ...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: 1479474 Signed-off-by: Ravishankar N Reviewed-on: https://review.gluster.org/17996 Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: Shyamsundar Ranganathan --- xlators/storage/posix/src/posix.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'xlators/storage/posix/src/posix.h') diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h index 81ea3d0f0b8..c2dcfdae9a1 100644 --- a/xlators/storage/posix/src/posix.h +++ b/xlators/storage/posix/src/posix.h @@ -76,6 +76,35 @@ struct posix_fd { struct list_head list; /* to add to the janitor list */ }; +#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) + struct posix_private { char *base_path; -- cgit