summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2017-09-15 14:12:47 +0530
committerShyamsundar Ranganathan <srangana@redhat.com>2017-09-17 12:55:23 +0000
commit0240a6d5ceb507376abaf97ec25409612c137891 (patch)
treeadc442b8886eea7f96f39bcd35014952786be291
parent4d121709766c10bdb7900dd9066dcec5b16678c3 (diff)
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: 1491985 Signed-off-by: Ravishankar N <ravishankar@redhat.com> Reviewed-on: https://review.gluster.org/18302 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
-rw-r--r--xlators/features/trash/src/trash.c7
-rw-r--r--xlators/storage/posix/src/posix-helpers.c6
-rw-r--r--xlators/storage/posix/src/posix.c8
-rw-r--r--xlators/storage/posix/src/posix.h29
4 files changed, 50 insertions, 0 deletions
diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c
index ab01832bb8b..4a41a14f427 100644
--- a/xlators/features/trash/src/trash.c
+++ b/xlators/features/trash/src/trash.c
@@ -1579,6 +1579,8 @@ trash_truncate_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local = frame->local;
GF_VALIDATE_OR_GOTO ("trash", local, out);
+ TRASH_UNSET_PID (frame, local);
+
/* Checks whether path is present in trash directory or not */
if ((op_ret == -1) && (op_errno == ENOENT)) {
@@ -1753,6 +1755,9 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
strcat (real_path, local->origpath);
/* Call create again once directory structure
is created. */
+
+ TRASH_SET_PID (frame, local);
+
STACK_WIND (frame, trash_truncate_create_cbk,
FIRST_CHILD(this),
FIRST_CHILD(this)->fops->create,
@@ -1957,6 +1962,8 @@ trash_truncate_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
flags = O_CREAT|O_EXCL|O_WRONLY;
+ TRASH_SET_PID (frame, local);
+
STACK_WIND (frame, trash_truncate_create_cbk,
FIRST_CHILD(this),
FIRST_CHILD(this)->fops->create,
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 9b945c271bc..3dfae4df684 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -870,6 +870,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 5f3f3388046..51d49d772de 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -1282,6 +1282,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);
MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, NULL);
@@ -1493,6 +1495,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);
MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, NULL);
if (!real_path || !par_path) {
@@ -2276,6 +2280,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);
MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &stbuf);
@@ -2886,6 +2892,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);
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 febd4326aa1..40ce4cdb5ac 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;