diff options
author | Anand Avati <avati@redhat.com> | 2013-09-12 08:16:40 -0700 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2013-09-19 14:06:33 -0700 |
commit | 0af0e6405d6911cf41d1ad1d4504baa842c1328e (patch) | |
tree | a0a7f94d1949b524f7571ff99562673a7a63404d | |
parent | 56e8bc6464d14ceaa42649dea1f5a4abef064668 (diff) |
rpcsvc: allocate large auxgid list on demand
For rpc requests having large aux group list, allocate large list
on demand. Else use small static array by default.
Without this patch, glusterfsd allocates 140+MB of resident memory
just to get started and initialized.
Change-Id: I3a07212b0076079cff67cdde18926e8f3b196258
Signed-off-by: Anand Avati <avati@redhat.com>
BUG: 953694
Reviewed-on: http://review.gluster.org/5927
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-on: http://review.gluster.org/5928
-rw-r--r-- | libglusterfs/src/mem-types.h | 3 | ||||
-rw-r--r-- | rpc/rpc-lib/src/auth-glusterfs.c | 32 | ||||
-rw-r--r-- | rpc/rpc-lib/src/auth-unix.c | 1 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpcsvc-auth.c | 3 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpcsvc.c | 2 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpcsvc.h | 4 |
6 files changed, 43 insertions, 2 deletions
diff --git a/libglusterfs/src/mem-types.h b/libglusterfs/src/mem-types.h index fea54c35e..7d9186a41 100644 --- a/libglusterfs/src/mem-types.h +++ b/libglusterfs/src/mem-types.h @@ -109,6 +109,7 @@ enum gf_common_mem_types_ { gf_common_mt_drc_rbtree_node_t = 93, gf_common_mt_iov_base_t = 94, gf_common_mt_groups_t = 95, - gf_common_mt_end = 96 + gf_common_mt_auxgids = 96, + gf_common_mt_end = 97 }; #endif diff --git a/rpc/rpc-lib/src/auth-glusterfs.c b/rpc/rpc-lib/src/auth-glusterfs.c index 9c6f8385b..db488434c 100644 --- a/rpc/rpc-lib/src/auth-glusterfs.c +++ b/rpc/rpc-lib/src/auth-glusterfs.c @@ -96,6 +96,22 @@ int auth_glusterfs_authenticate (rpcsvc_request_t *req, void *priv) goto err; } + if (req->auxgidcount > SMALL_GROUP_COUNT) { + req->auxgidlarge = GF_CALLOC(req->auxgidcount, + sizeof(req->auxgids[0]), + gf_common_mt_auxgids); + req->auxgids = req->auxgidlarge; + } else { + req->auxgids = req->auxgidsmall; + } + + if (!req->auxgids) { + gf_log ("auth-glusterfs", GF_LOG_WARNING, + "cannot allocate gid list"); + ret = RPCSVC_AUTH_REJECT; + goto err; + } + for (gidcount = 0; gidcount < au.ngrps; ++gidcount) req->auxgids[gidcount] = au.groups[gidcount]; @@ -203,6 +219,22 @@ int auth_glusterfs_v2_authenticate (rpcsvc_request_t *req, void *priv) goto err; } + if (req->auxgidcount > SMALL_GROUP_COUNT) { + req->auxgidlarge = GF_CALLOC(req->auxgidcount, + sizeof(req->auxgids[0]), + gf_common_mt_auxgids); + req->auxgids = req->auxgidlarge; + } else { + req->auxgids = req->auxgidsmall; + } + + if (!req->auxgids) { + gf_log ("auth-glusterfs-v2", GF_LOG_WARNING, + "cannot allocate gid list"); + ret = RPCSVC_AUTH_REJECT; + goto err; + } + for (i = 0; i < req->auxgidcount; ++i) req->auxgids[i] = au.groups.groups_val[i]; diff --git a/rpc/rpc-lib/src/auth-unix.c b/rpc/rpc-lib/src/auth-unix.c index 6251d60a8..fa5f0576e 100644 --- a/rpc/rpc-lib/src/auth-unix.c +++ b/rpc/rpc-lib/src/auth-unix.c @@ -42,6 +42,7 @@ int auth_unix_authenticate (rpcsvc_request_t *req, void *priv) if (!req) return ret; + req->auxgids = req->auxgidsmall; ret = xdr_to_auth_unix_cred (req->cred.authdata, req->cred.datalen, &aup, machname, req->auxgids); if (ret == -1) { diff --git a/rpc/rpc-lib/src/rpcsvc-auth.c b/rpc/rpc-lib/src/rpcsvc-auth.c index 04b66091f..c93b62d10 100644 --- a/rpc/rpc-lib/src/rpcsvc-auth.c +++ b/rpc/rpc-lib/src/rpcsvc-auth.c @@ -327,6 +327,9 @@ rpcsvc_auth_request_init (rpcsvc_request_t *req) if (!auth->authops->request_init) ret = auth->authops->request_init (req, auth->authprivate); + req->auxgids = req->auxgidsmall; /* reset to auxgidlarge during + unsersialize if necessary */ + req->auxgidlarge = NULL; err: return ret; } diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c index 107a0f9a1..d9bbb1c54 100644 --- a/rpc/rpc-lib/src/rpcsvc.c +++ b/rpc/rpc-lib/src/rpcsvc.c @@ -281,6 +281,8 @@ rpcsvc_request_destroy (rpcsvc_request_t *req) rpc_transport_unref (req->trans); + GF_FREE (req->auxgidlarge); + mem_put (req); out: diff --git a/rpc/rpc-lib/src/rpcsvc.h b/rpc/rpc-lib/src/rpcsvc.h index 1323c8b7a..4bb59a825 100644 --- a/rpc/rpc-lib/src/rpcsvc.h +++ b/rpc/rpc-lib/src/rpcsvc.h @@ -178,7 +178,9 @@ struct rpcsvc_request { /* Might want to move this to AUTH_UNIX specific state since this array * is not available for every authentication scheme. */ - gid_t auxgids[GF_MAX_AUX_GROUPS]; + gid_t *auxgids; + gid_t auxgidsmall[SMALL_GROUP_COUNT]; + gid_t *auxgidlarge; int auxgidcount; |