summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2013-05-02 23:36:01 -0700
committerVijay Bellur <vbellur@redhat.com>2013-07-24 11:36:46 -0700
commit7cfef511898ba2d555256e6d7f53bd97ed69e6e0 (patch)
treea138a2c0eb439610ca87f35607b1fae90e68829d /libglusterfs
parente45e0037f6df6a0fab846a83fb2c99bb09417cf4 (diff)
core: increase the auxillary group limit to 65536
Make the allocation of groups dynamic and increase the limit to 65536. Change-Id: I702364ff460e3a982e44ccbcb3e337cac9c2df51 BUG: 953694 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/5111 Reviewed-by: Xavier Hernandez <xhernandez@datalab.es> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/glusterfs.h2
-rw-r--r--libglusterfs/src/mem-types.h3
-rw-r--r--libglusterfs/src/stack.h33
-rw-r--r--libglusterfs/src/syncop.h17
4 files changed, 50 insertions, 5 deletions
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index dbb2b58d9..ac0c81267 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -148,7 +148,7 @@
/* TODO: Keeping it to 200, so that we can fit in 2KB buffer for auth data
* in RPC server code, if there is ever need for having more aux-gids, then
* we have to add aux-gid in payload of actors */
-#define GF_MAX_AUX_GROUPS 200
+#define GF_MAX_AUX_GROUPS 65536
#define GF_UUID_BUF_SIZE 50
diff --git a/libglusterfs/src/mem-types.h b/libglusterfs/src/mem-types.h
index 4c78f4607..fea54c35e 100644
--- a/libglusterfs/src/mem-types.h
+++ b/libglusterfs/src/mem-types.h
@@ -108,6 +108,7 @@ enum gf_common_mem_types_ {
gf_common_mt_drc_globals_t = 92,
gf_common_mt_drc_rbtree_node_t = 93,
gf_common_mt_iov_base_t = 94,
- gf_common_mt_end = 95,
+ gf_common_mt_groups_t = 95,
+ gf_common_mt_end = 96
};
#endif
diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h
index a91b635e4..0e8b705bd 100644
--- a/libglusterfs/src/stack.h
+++ b/libglusterfs/src/stack.h
@@ -82,6 +82,8 @@ struct _call_frame_t {
const char *unwind_to;
};
+#define SMALL_GROUP_COUNT 128
+
struct _call_stack_t {
union {
struct list_head all_frames;
@@ -99,7 +101,9 @@ struct _call_stack_t {
gid_t gid;
pid_t pid;
uint16_t ngrps;
- uint32_t groups[GF_MAX_AUX_GROUPS];
+ uint32_t groups_small[SMALL_GROUP_COUNT];
+ uint32_t *groups_large;
+ uint32_t *groups;
gf_lkowner_t lk_owner;
glusterfs_ctx_t *ctx;
@@ -174,6 +178,9 @@ STACK_DESTROY (call_stack_t *stack)
while (stack->frames.next) {
FRAME_DESTROY (stack->frames.next);
}
+
+ GF_FREE (stack->groups_large);
+
mem_put (stack);
if (local)
@@ -370,6 +377,24 @@ STACK_RESET (call_stack_t *stack)
} while (0)
+static inline int
+call_stack_alloc_groups (call_stack_t *stack, int ngrps)
+{
+ if (ngrps <= SMALL_GROUP_COUNT) {
+ stack->groups = stack->groups_small;
+ } else {
+ stack->groups_large = GF_CALLOC (sizeof (gid_t), ngrps,
+ gf_common_mt_groups_t);
+ if (!stack->groups_large)
+ return -1;
+ stack->groups = stack->groups_large;
+ }
+
+ stack->ngrps = ngrps;
+
+ return 0;
+}
+
static inline call_frame_t *
copy_frame (call_frame_t *frame)
{
@@ -393,8 +418,12 @@ copy_frame (call_frame_t *frame)
newstack->ngrps = oldstack->ngrps;
newstack->op = oldstack->op;
newstack->type = oldstack->type;
+ if (call_stack_alloc_groups (newstack, oldstack->ngrps) != 0) {
+ mem_put (newstack);
+ return NULL;
+ }
memcpy (newstack->groups, oldstack->groups,
- sizeof (gid_t) * GF_MAX_AUX_GROUPS);
+ sizeof (gid_t) * oldstack->ngrps);
newstack->unique = oldstack->unique;
newstack->frames.this = frame->this;
diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h
index 43e71c4f6..c4b339ee7 100644
--- a/libglusterfs/src/syncop.h
+++ b/libglusterfs/src/syncop.h
@@ -240,6 +240,7 @@ static inline call_frame_t *
syncop_create_frame (xlator_t *this)
{
call_frame_t *frame = NULL;
+ int ngrps = -1;
frame = create_frame (this, this->ctx->pool);
if (!frame)
@@ -248,7 +249,21 @@ syncop_create_frame (xlator_t *this)
frame->root->pid = getpid();
frame->root->uid = geteuid ();
frame->root->gid = getegid ();
- frame->root->ngrps = getgroups (GF_MAX_AUX_GROUPS, frame->root->groups);
+ ngrps = getgroups (0, 0);
+ if (ngrps < 0) {
+ STACK_DESTROY (frame->root);
+ return NULL;
+ }
+
+ if (call_stack_alloc_groups (frame->root, ngrps) != 0) {
+ STACK_DESTROY (frame->root);
+ return NULL;
+ }
+
+ if (getgroups (ngrps, frame->root->groups) < 0) {
+ STACK_DESTROY (frame->root);
+ return NULL;
+ }
return frame;
}