diff options
| author | Junaid <junaid@gluster.com> | 2011-09-07 17:36:09 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vijay@gluster.com> | 2011-09-09 01:39:44 -0700 | 
| commit | 0a2de8337e7111d9cb860329d83b5aae3ecacd2f (patch) | |
| tree | 46c105d6e93699a4837a9eedec4970d722df0efc | |
| parent | f655fa043fc65ecad1d633a52a40a4c20ff18c97 (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/367
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
| -rw-r--r-- | xlators/features/marker/src/marker.c | 29 | ||||
| -rw-r--r-- | xlators/features/marker/src/marker.h | 16 | 
2 files changed, 39 insertions, 6 deletions
diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index d0f01465ffa..2c60c3d50a2 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); @@ -1019,8 +1021,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; @@ -1092,9 +1095,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), @@ -1145,6 +1146,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, @@ -1194,6 +1199,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, @@ -1221,6 +1230,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, @@ -1266,6 +1280,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 5502c4ea137..f5ed9df399e 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;  | 
