summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunaid <junaid@gluster.com>2011-09-07 17:36:09 +0530
committerVijay Bellur <vijay@gluster.com>2011-09-12 05:23:06 -0700
commit96ebf45d1d62c6626303727dce3ea5be3000742c (patch)
tree1e82a99a560e2249de8080be799fcea4a3fe411f
parent61fb0ceaecab8d60928e70b8c8af3583b60c6fc6 (diff)
features/marker-quota: Perform xattr related operations with root permissions in rename fop.
Change-Id: Id9ac1ecdd9753377c9eb24464f51dcbdc0cd2821 BUG: 3194 Reviewed-on: http://review.gluster.com/366 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r--xlators/features/marker/src/marker.c29
-rw-r--r--xlators/features/marker/src/marker.h16
2 files changed, 39 insertions, 6 deletions
diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c
index 6b89cfa91..89da08932 100644
--- a/xlators/features/marker/src/marker.c
+++ b/xlators/features/marker/src/marker.c
@@ -31,6 +31,8 @@
#include "marker-common.h"
#include "byte-order.h"
+#define _GF_UID_GID_CHANGED 1
+
void
fini (xlator_t *this);
@@ -1021,8 +1023,9 @@ marker_rename_release_oldp_lock (call_frame_t *frame, void *cookie,
local->err = op_errno;
}
- //Reset frame uid and gid if reset.
- MARKER_SET_UID_GID (frame->root, local);
+ //Reset frame uid and gid if set.
+ if (cookie == (void *) _GF_UID_GID_CHANGED)
+ MARKER_RESET_UID_GID (frame, frame->root, local);
lock.l_type = F_UNLCK;
lock.l_whence = SEEK_SET;
@@ -1094,9 +1097,7 @@ marker_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* Removexattr requires uid and gid to be 0,
* reset them in the callback.
*/
- MARKER_SET_UID_GID (local, frame->root);
- frame->root->uid = 0;
- frame->root->gid = 0;
+ MARKER_SET_UID_GID (frame, local, frame->root);
STACK_WIND (frame, marker_rename_release_oldp_lock,
FIRST_CHILD(this),
@@ -1147,6 +1148,10 @@ marker_do_rename (call_frame_t *frame, void *cookie, xlator_t *this,
local = frame->local;
oplocal = local->oplocal;
+ //Reset frame uid and gid if set.
+ if (cookie == (void *) _GF_UID_GID_CHANGED)
+ MARKER_RESET_UID_GID (frame, frame->root, local);
+
if ((op_ret < 0) && (op_errno != ENOATTR)) {
local->err = op_errno;
gf_log (this->name, GF_LOG_WARNING,
@@ -1196,6 +1201,10 @@ marker_get_newpath_contribution (call_frame_t *frame, void *cookie,
local = frame->local;
oplocal = local->oplocal;
+ //Reset frame uid and gid if set.
+ if (cookie == (void *) _GF_UID_GID_CHANGED)
+ MARKER_RESET_UID_GID (frame, frame->root, local);
+
if ((op_ret < 0) && (op_errno != ENOATTR)) {
local->err = op_errno;
gf_log (this->name, GF_LOG_WARNING,
@@ -1223,6 +1232,11 @@ marker_get_newpath_contribution (call_frame_t *frame, void *cookie,
goto err;
}
+ /* getxattr requires uid and gid to be 0,
+ * reset them in the callback.
+ */
+ MARKER_SET_UID_GID (frame, local, frame->root);
+
STACK_WIND (frame, marker_do_rename,
FIRST_CHILD(this),
FIRST_CHILD(this)->fops->getxattr, &local->loc,
@@ -1268,6 +1282,11 @@ marker_get_oldpath_contribution (call_frame_t *frame, void *cookie,
goto quota_err;
}
+ /* getxattr requires uid and gid to be 0,
+ * reset them in the callback.
+ */
+ MARKER_SET_UID_GID (frame, local, frame->root);
+
STACK_WIND (frame, marker_get_newpath_contribution, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->getxattr, &oplocal->loc,
contri_key);
diff --git a/xlators/features/marker/src/marker.h b/xlators/features/marker/src/marker.h
index c8c775024..1fc57057c 100644
--- a/xlators/features/marker/src/marker.h
+++ b/xlators/features/marker/src/marker.h
@@ -64,7 +64,7 @@ enum {
} \
} while (0)
-#define MARKER_SET_UID_GID(dest, src) \
+#define _MARKER_SET_UID_GID(dest, src) \
do { \
if (src->uid != -1 && \
src->gid != -1) { \
@@ -73,6 +73,20 @@ enum {
} \
} while (0)
+#define MARKER_SET_UID_GID(frame, dest, src) \
+ do { \
+ _MARKER_SET_UID_GID (dest, src); \
+ frame->root->uid = 0; \
+ frame->root->gid = 0; \
+ frame->cookie = (void *) _GF_UID_GID_CHANGED; \
+ } while (0)
+
+#define MARKER_RESET_UID_GID(frame, dest, src) \
+ do { \
+ _MARKER_SET_UID_GID (dest, src); \
+ frame->cookie = NULL; \
+ } while (0)
+
struct marker_local{
uint32_t timebuf[2];
pid_t pid;