summaryrefslogtreecommitdiffstats
path: root/xlators/storage
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2017-08-08 21:42:03 +0530
committerShyamsundar Ranganathan <srangana@redhat.com>2017-08-12 13:29:47 +0000
commit517316470e8e309e0e572264ee3c02b0748acab1 (patch)
tree188b20ed185fc4e8475ff8cd4fe3a0a8b81619d8 /xlators/storage
parent40d65fb360afac01c593a4cf47851cf9ee50ad96 (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: 1479474 Signed-off-by: Ravishankar N <ravishankar@redhat.com> Reviewed-on: https://review.gluster.org/17996 Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Diffstat (limited to 'xlators/storage')
-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
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 2095b56e5ef..827209e22f9 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 4e4076701a2..72c65a18c5f 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -1347,6 +1347,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);
@@ -1565,6 +1567,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) {
@@ -2389,6 +2393,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);
@@ -3036,6 +3042,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 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;