aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-03-27 04:14:59 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-27 11:44:41 -0500
commitefc36aa5608f5717338747e152c23f2cfdb14697 (patch)
treeab444f6e6c88ed07a8d5a034777c10de50e663fd
parent3e7b19198003fc25b11838e709f17d4fa173b2d7 (diff)
[PATCH] knfsd: Change the store of auth_domains to not be a 'cache'
The 'auth_domain's are simply handles on internal data structures. They do not cache information from user-space, and forcing them into the mold of a 'cache' misrepresents their true nature and causes confusion. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--fs/nfsd/export.c5
-rw-r--r--include/linux/sunrpc/svcauth.h12
-rw-r--r--net/sunrpc/auth_gss/svcauth_gss.c14
-rw-r--r--net/sunrpc/sunrpc_syms.c4
-rw-r--r--net/sunrpc/svcauth.c122
-rw-r--r--net/sunrpc/svcauth_unix.c69
6 files changed, 81 insertions, 145 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 417ec02df44f..ac0997731fce 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -242,7 +242,7 @@ static inline int svc_expkey_match (struct svc_expkey *a, struct svc_expkey *b)
242 242
243static inline void svc_expkey_init(struct svc_expkey *new, struct svc_expkey *item) 243static inline void svc_expkey_init(struct svc_expkey *new, struct svc_expkey *item)
244{ 244{
245 cache_get(&item->ek_client->h); 245 kref_get(&item->ek_client->ref);
246 new->ek_client = item->ek_client; 246 new->ek_client = item->ek_client;
247 new->ek_fsidtype = item->ek_fsidtype; 247 new->ek_fsidtype = item->ek_fsidtype;
248 new->ek_fsid[0] = item->ek_fsid[0]; 248 new->ek_fsid[0] = item->ek_fsid[0];
@@ -474,7 +474,7 @@ static inline int svc_export_match(struct svc_export *a, struct svc_export *b)
474} 474}
475static inline void svc_export_init(struct svc_export *new, struct svc_export *item) 475static inline void svc_export_init(struct svc_export *new, struct svc_export *item)
476{ 476{
477 cache_get(&item->ex_client->h); 477 kref_get(&item->ex_client->ref);
478 new->ex_client = item->ex_client; 478 new->ex_client = item->ex_client;
479 new->ex_dentry = dget(item->ex_dentry); 479 new->ex_dentry = dget(item->ex_dentry);
480 new->ex_mnt = mntget(item->ex_mnt); 480 new->ex_mnt = mntget(item->ex_mnt);
@@ -1129,7 +1129,6 @@ exp_delclient(struct nfsctl_client *ncp)
1129 */ 1129 */
1130 if (dom) { 1130 if (dom) {
1131 err = auth_unix_forget_old(dom); 1131 err = auth_unix_forget_old(dom);
1132 dom->h.expiry_time = get_seconds();
1133 auth_domain_put(dom); 1132 auth_domain_put(dom);
1134 } 1133 }
1135 1134
diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
index c119ce7cbd22..2fe2087edd66 100644
--- a/include/linux/sunrpc/svcauth.h
+++ b/include/linux/sunrpc/svcauth.h
@@ -45,9 +45,10 @@ struct svc_rqst; /* forward decl */
45 * of ip addresses to the given client. 45 * of ip addresses to the given client.
46 */ 46 */
47struct auth_domain { 47struct auth_domain {
48 struct cache_head h; 48 struct kref ref;
49 struct hlist_node hash;
49 char *name; 50 char *name;
50 int flavour; 51 struct auth_ops *flavour;
51}; 52};
52 53
53/* 54/*
@@ -86,6 +87,9 @@ struct auth_domain {
86 * 87 *
87 * domain_release() 88 * domain_release()
88 * This call releases a domain. 89 * This call releases a domain.
90 * set_client()
91 * Givens a pending request (struct svc_rqst), finds and assigns
92 * an appropriate 'auth_domain' as the client.
89 */ 93 */
90struct auth_ops { 94struct auth_ops {
91 char * name; 95 char * name;
@@ -117,7 +121,7 @@ extern void svc_auth_unregister(rpc_authflavor_t flavor);
117extern struct auth_domain *unix_domain_find(char *name); 121extern struct auth_domain *unix_domain_find(char *name);
118extern void auth_domain_put(struct auth_domain *item); 122extern void auth_domain_put(struct auth_domain *item);
119extern int auth_unix_add_addr(struct in_addr addr, struct auth_domain *dom); 123extern int auth_unix_add_addr(struct in_addr addr, struct auth_domain *dom);
120extern struct auth_domain *auth_domain_lookup(struct auth_domain *item, int set); 124extern struct auth_domain *auth_domain_lookup(char *name, struct auth_domain *new);
121extern struct auth_domain *auth_domain_find(char *name); 125extern struct auth_domain *auth_domain_find(char *name);
122extern struct auth_domain *auth_unix_lookup(struct in_addr addr); 126extern struct auth_domain *auth_unix_lookup(struct in_addr addr);
123extern int auth_unix_forget_old(struct auth_domain *dom); 127extern int auth_unix_forget_old(struct auth_domain *dom);
@@ -160,8 +164,6 @@ static inline unsigned long hash_mem(char *buf, int length, int bits)
160 return hash >> (BITS_PER_LONG - bits); 164 return hash >> (BITS_PER_LONG - bits);
161} 165}
162 166
163extern struct cache_detail auth_domain_cache, ip_map_cache;
164
165#endif /* __KERNEL__ */ 167#endif /* __KERNEL__ */
166 168
167#endif /* _LINUX_SUNRPC_SVCAUTH_H_ */ 169#endif /* _LINUX_SUNRPC_SVCAUTH_H_ */
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 23632d84d8d7..6b073c2e6930 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -645,6 +645,8 @@ find_gss_auth_domain(struct gss_ctx *ctx, u32 svc)
645 return auth_domain_find(name); 645 return auth_domain_find(name);
646} 646}
647 647
648static struct auth_ops svcauthops_gss;
649
648int 650int
649svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name) 651svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name)
650{ 652{
@@ -655,20 +657,18 @@ svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name)
655 new = kmalloc(sizeof(*new), GFP_KERNEL); 657 new = kmalloc(sizeof(*new), GFP_KERNEL);
656 if (!new) 658 if (!new)
657 goto out; 659 goto out;
658 cache_init(&new->h.h); 660 kref_init(&new->h.ref);
659 new->h.name = kmalloc(strlen(name) + 1, GFP_KERNEL); 661 new->h.name = kmalloc(strlen(name) + 1, GFP_KERNEL);
660 if (!new->h.name) 662 if (!new->h.name)
661 goto out_free_dom; 663 goto out_free_dom;
662 strcpy(new->h.name, name); 664 strcpy(new->h.name, name);
663 new->h.flavour = RPC_AUTH_GSS; 665 new->h.flavour = &svcauthops_gss;
664 new->pseudoflavor = pseudoflavor; 666 new->pseudoflavor = pseudoflavor;
665 new->h.h.expiry_time = NEVER;
666 667
667 test = auth_domain_lookup(&new->h, 1); 668 test = auth_domain_lookup(name, &new->h);
668 if (test == &new->h) { 669 if (test != &new->h) { /* XXX Duplicate registration? */
669 BUG_ON(atomic_dec_and_test(&new->h.h.refcnt));
670 } else { /* XXX Duplicate registration? */
671 auth_domain_put(&new->h); 670 auth_domain_put(&new->h);
671 /* dangling ref-count... */
672 goto out; 672 goto out;
673 } 673 }
674 return 0; 674 return 0;
diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c
index 9f7373203592..40401196e7de 100644
--- a/net/sunrpc/sunrpc_syms.c
+++ b/net/sunrpc/sunrpc_syms.c
@@ -142,6 +142,7 @@ EXPORT_SYMBOL(nlm_debug);
142 142
143extern int register_rpc_pipefs(void); 143extern int register_rpc_pipefs(void);
144extern void unregister_rpc_pipefs(void); 144extern void unregister_rpc_pipefs(void);
145extern struct cache_detail ip_map_cache;
145 146
146static int __init 147static int __init
147init_sunrpc(void) 148init_sunrpc(void)
@@ -158,7 +159,6 @@ init_sunrpc(void)
158#ifdef CONFIG_PROC_FS 159#ifdef CONFIG_PROC_FS
159 rpc_proc_init(); 160 rpc_proc_init();
160#endif 161#endif
161 cache_register(&auth_domain_cache);
162 cache_register(&ip_map_cache); 162 cache_register(&ip_map_cache);
163out: 163out:
164 return err; 164 return err;
@@ -169,8 +169,6 @@ cleanup_sunrpc(void)
169{ 169{
170 unregister_rpc_pipefs(); 170 unregister_rpc_pipefs();
171 rpc_destroy_mempool(); 171 rpc_destroy_mempool();
172 if (cache_unregister(&auth_domain_cache))
173 printk(KERN_ERR "sunrpc: failed to unregister auth_domain cache\n");
174 if (cache_unregister(&ip_map_cache)) 172 if (cache_unregister(&ip_map_cache))
175 printk(KERN_ERR "sunrpc: failed to unregister ip_map cache\n"); 173 printk(KERN_ERR "sunrpc: failed to unregister ip_map cache\n");
176#ifdef RPC_DEBUG 174#ifdef RPC_DEBUG
diff --git a/net/sunrpc/svcauth.c b/net/sunrpc/svcauth.c
index dda4f0c63511..5b28c6176806 100644
--- a/net/sunrpc/svcauth.c
+++ b/net/sunrpc/svcauth.c
@@ -106,112 +106,56 @@ svc_auth_unregister(rpc_authflavor_t flavor)
106EXPORT_SYMBOL(svc_auth_unregister); 106EXPORT_SYMBOL(svc_auth_unregister);
107 107
108/************************************************** 108/**************************************************
109 * cache for domain name to auth_domain 109 * 'auth_domains' are stored in a hash table indexed by name.
110 * Entries are only added by flavours which will normally 110 * When the last reference to an 'auth_domain' is dropped,
111 * have a structure that 'inherits' from auth_domain. 111 * the object is unhashed and freed.
112 * e.g. when an IP -> domainname is given to auth_unix, 112 * If auth_domain_lookup fails to find an entry, it will return
113 * and the domain name doesn't exist, it will create a 113 * it's second argument 'new'. If this is non-null, it will
114 * auth_unix_domain and add it to this hash table. 114 * have been atomically linked into the table.