aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2018-12-02 19:30:30 -0500
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2018-12-19 13:52:45 -0500
commitfc0664fd9bccafb00bd2dfe0d5218147994f81ee (patch)
tree6e7ac6a488fa60ae7a4f877610d595982ceb9434
parent97f68c6b02e0225b38d327103c59cfe2ab5ecda7 (diff)
SUNRPC: remove groupinfo from struct auth_cred.
We can use cred->groupinfo (from the 'struct cred') instead. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.c14
-rw-r--r--include/linux/sunrpc/auth.h1
-rw-r--r--net/sunrpc/auth.c1
-rw-r--r--net/sunrpc/auth_generic.c17
-rw-r--r--net/sunrpc/auth_unix.c12
5 files changed, 14 insertions, 31 deletions
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 22e164106333..c6e64ce5ca42 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -28,9 +28,6 @@
28#define FF_LAYOUT_POLL_RETRY_MAX (15*HZ) 28#define FF_LAYOUT_POLL_RETRY_MAX (15*HZ)
29#define FF_LAYOUTRETURN_MAXERR 20 29#define FF_LAYOUTRETURN_MAXERR 20
30 30
31
32static struct group_info *ff_zero_group;
33
34static void ff_layout_read_record_layoutstats_done(struct rpc_task *task, 31static void ff_layout_read_record_layoutstats_done(struct rpc_task *task,
35 struct nfs_pgio_header *hdr); 32 struct nfs_pgio_header *hdr);
36static int ff_layout_mirror_prepare_stats(struct pnfs_layout_hdr *lo, 33static int ff_layout_mirror_prepare_stats(struct pnfs_layout_hdr *lo,
@@ -414,7 +411,7 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh,
414 411
415 for (i = 0; i < fls->mirror_array_cnt; i++) { 412 for (i = 0; i < fls->mirror_array_cnt; i++) {
416 struct nfs4_ff_layout_mirror *mirror; 413 struct nfs4_ff_layout_mirror *mirror;
417 struct auth_cred acred = { .group_info = ff_zero_group }; 414 struct auth_cred acred = {};
418 struct rpc_cred __rcu *cred; 415 struct rpc_cred __rcu *cred;
419 struct cred *kcred; 416 struct cred *kcred;
420 u32 ds_count, fh_count, id; 417 u32 ds_count, fh_count, id;
@@ -2400,11 +2397,6 @@ static int __init nfs4flexfilelayout_init(void)
2400{ 2397{
2401 printk(KERN_INFO "%s: NFSv4 Flexfile Layout Driver Registering...\n", 2398 printk(KERN_INFO "%s: NFSv4 Flexfile Layout Driver Registering...\n",
2402 __func__); 2399 __func__);
2403 if (!ff_zero_group) {
2404 ff_zero_group = groups_alloc(0);
2405 if (!ff_zero_group)
2406 return -ENOMEM;
2407 }
2408 return pnfs_register_layoutdriver(&flexfilelayout_type); 2400 return pnfs_register_layoutdriver(&flexfilelayout_type);
2409} 2401}
2410 2402
@@ -2413,10 +2405,6 @@ static void __exit nfs4flexfilelayout_exit(void)
2413 printk(KERN_INFO "%s: NFSv4 Flexfile Layout Driver Unregistering...\n", 2405 printk(KERN_INFO "%s: NFSv4 Flexfile Layout Driver Unregistering...\n",
2414 __func__); 2406 __func__);
2415 pnfs_unregister_layoutdriver(&flexfilelayout_type); 2407 pnfs_unregister_layoutdriver(&flexfilelayout_type);
2416 if (ff_zero_group) {
2417 put_group_info(ff_zero_group);
2418 ff_zero_group = NULL;
2419 }
2420} 2408}
2421 2409
2422MODULE_ALIAS("nfs-layouttype4-4"); 2410MODULE_ALIAS("nfs-layouttype4-4");
diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h
index 1f95bd612053..30eb9b9b9c8c 100644
--- a/include/linux/sunrpc/auth.h
+++ b/include/linux/sunrpc/auth.h
@@ -49,7 +49,6 @@ struct auth_cred {
49 const struct cred *cred; 49 const struct cred *cred;
50 kuid_t uid; 50 kuid_t uid;
51 kgid_t gid; 51 kgid_t gid;
52 struct group_info *group_info;
53 const char *principal; 52 const char *principal;
54 unsigned long ac_flags; 53 unsigned long ac_flags;
55 unsigned char machine_cred : 1; 54 unsigned char machine_cred : 1;
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index a7e08e44f92b..e1053b96e0e5 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -658,7 +658,6 @@ rpcauth_lookupcred(struct rpc_auth *auth, int flags)
658 memset(&acred, 0, sizeof(acred)); 658 memset(&acred, 0, sizeof(acred));
659 acred.uid = cred->fsuid; 659 acred.uid = cred->fsuid;
660 acred.gid = cred->fsgid; 660 acred.gid = cred->fsgid;
661 acred.group_info = cred->group_info;
662 acred.cred = cred; 661 acred.cred = cred;
663 ret = auth->au_ops->lookup_cred(auth, &acred, flags); 662 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
664 return ret; 663 return ret;
diff --git a/net/sunrpc/auth_generic.c b/net/sunrpc/auth_generic.c
index 16a0a4b89bb4..a4ae7bd7ca7b 100644
--- a/net/sunrpc/auth_generic.c
+++ b/net/sunrpc/auth_generic.c
@@ -113,11 +113,8 @@ generic_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags, g
113 113
114 gcred->acred.uid = acred->uid; 114 gcred->acred.uid = acred->uid;
115 gcred->acred.gid = acred->gid; 115 gcred->acred.gid = acred->gid;
116 gcred->acred.group_info = acred->group_info;
117 gcred->acred.cred = gcred->gc_base.cr_cred; 116 gcred->acred.cred = gcred->gc_base.cr_cred;
118 gcred->acred.ac_flags = 0; 117 gcred->acred.ac_flags = 0;
119 if (gcred->acred.group_info != NULL)
120 get_group_info(gcred->acred.group_info);
121 gcred->acred.machine_cred = acred->machine_cred; 118 gcred->acred.machine_cred = acred->machine_cred;
122 gcred->acred.principal = acred->principal; 119 gcred->acred.principal = acred->principal;
123 120
@@ -135,8 +132,6 @@ generic_free_cred(struct rpc_cred *cred)
135 struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base); 132 struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base);
136 133
137 dprintk("RPC: generic_free_cred %p\n", gcred); 134 dprintk("RPC: generic_free_cred %p\n", gcred);
138 if (gcred->acred.group_info != NULL)
139 put_group_info(gcred->acred.group_info);
140 put_cred(cred->cr_cred); 135 put_cred(cred->cr_cred);
141 kfree(gcred); 136 kfree(gcred);
142} 137}
@@ -173,6 +168,7 @@ generic_match(struct auth_cred *acred, struct rpc_cred *cred, int flags)
173{ 168{
174 struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base); 169 struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base);
175 int i; 170 int i;
171 struct group_info *a, *g;
176 172
177 if (acred->machine_cred) 173 if (acred->machine_cred)
178 return machine_cred_match(acred, gcred, flags); 174 return machine_cred_match(acred, gcred, flags);
@@ -182,16 +178,17 @@ generic_match(struct auth_cred *acred, struct rpc_cred *cred, int flags)
182 gcred->acred.machine_cred != 0) 178 gcred->acred.machine_cred != 0)
183 goto out_nomatch; 179 goto out_nomatch;
184 180
181 a = acred->cred->group_info;
182 g = gcred->acred.cred->group_info;
185 /* Optimisation in the case where pointers are identical... */ 183 /* Optimisation in the case where pointers are identical... */
186 if (gcred->acred.group_info == acred->group_info) 184 if (a == g)
187 goto out_match; 185 goto out_match;
188 186
189 /* Slow path... */ 187 /* Slow path... */
190 if (gcred->acred.group_info->ngroups != acred->group_info->ngroups) 188 if (g->ngroups != a->ngroups)
191 goto out_nomatch; 189 goto out_nomatch;
192 for (i = 0; i < gcred->acred.group_info->ngroups; i++) { 190 for (i = 0; i < g->ngroups; i++) {
193 if (!gid_eq(gcred->acred.group_info->gid[i], 191 if (!gid_eq(g->gid[i], a->gid[i]))
194 acred->group_info->gid[i]))
195 goto out_nomatch; 192 goto out_nomatch;
196 } 193 }
197out_match: 194out_match:
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c
index 36e01384f082..0a6397a099d6 100644
--- a/net/sunrpc/auth_unix.c
+++ b/net/sunrpc/auth_unix.c
@@ -79,14 +79,14 @@ unx_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags, gfp_t
79 rpcauth_init_cred(&cred->uc_base, acred, auth, &unix_credops); 79 rpcauth_init_cred(&cred->uc_base, acred, auth, &unix_credops);
80 cred->uc_base.cr_flags = 1UL << RPCAUTH_CRED_UPTODATE; 80 cred->uc_base.cr_flags = 1UL << RPCAUTH_CRED_UPTODATE;
81 81
82 if (acred->group_info != NULL) 82 if (acred->cred && acred->cred->group_info != NULL)
83 groups = acred->group_info->ngroups; 83 groups = acred->cred->group_info->ngroups;
84 if (groups > UNX_NGROUPS) 84 if (groups > UNX_NGROUPS)
85 groups = UNX_NGROUPS; 85 groups = UNX_NGROUPS;
86 86
87 cred->uc_gid = acred->gid; 87 cred->uc_gid = acred->gid;
88 for (i = 0; i < groups; i++) 88 for (i = 0; i < groups; i++)
89 cred->uc_gids[i] = acred->group_info->gid[i]; 89 cred->uc_gids[i] = acred->cred->group_info->gid[i];
90 if (i < UNX_NGROUPS) 90 if (i < UNX_NGROUPS)
91 cred->uc_gids[i] = INVALID_GID; 91 cred->uc_gids[i] = INVALID_GID;
92 92
@@ -130,12 +130,12 @@ unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags)
130 if (!uid_eq(cred->uc_uid, acred->uid) || !gid_eq(cred->uc_gid, acred->gid)) 130 if (!uid_eq(cred->uc_uid, acred->uid) || !gid_eq(cred->uc_gid, acred->gid))
131 return 0; 131 return 0;
132 132
133 if (acred->group_info != NULL) 133 if (acred->cred && acred->cred->group_info != NULL)
134 groups = acred->group_info->ngroups; 134 groups = acred->cred->group_info->ngroups;
135 if (groups > UNX_NGROUPS) 135 if (groups > UNX_NGROUPS)
136 groups = UNX_NGROUPS; 136 groups = UNX_NGROUPS;
137 for (i = 0; i < groups ; i++) 137 for (i = 0; i < groups ; i++)
138 if (!gid_eq(cred->uc_gids[i], acred->group_info->gid[i])) 138 if (!gid_eq(cred->uc_gids[i], acred->cred->group_info->gid[i]))
139 return 0; 139 return 0;
140 if (groups < UNX_NGROUPS && gid_valid(cred->uc_gids[groups])) 140 if (groups < UNX_NGROUPS && gid_valid(cred->uc_gids[groups]))
141 return 0; 141 return 0;