aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/svcauth_unix.c
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 /net/sunrpc/svcauth_unix.c
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>
Diffstat (limited to 'net/sunrpc/svcauth_unix.c')
-rw-r--r--net/sunrpc/svcauth_unix.c69
1 files changed, 31 insertions, 38 deletions
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index 3e6c694bbad1..17e8b2a3130c 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -27,41 +27,35 @@ struct unix_domain {
27 /* other stuff later */ 27 /* other stuff later */
28}; 28};
29 29
30extern struct auth_ops svcauth_unix;
31
30struct auth_domain *unix_domain_find(char *name) 32struct auth_domain *unix_domain_find(char *name)
31{ 33{
32 struct auth_domain *rv, ud; 34 struct auth_domain *rv;
33 struct unix_domain *new; 35 struct unix_domain *new = NULL;
34 36
35 ud.name = name; 37 rv = auth_domain_lookup(name, NULL);
36 38 while(1) {
37 rv = auth_domain_lookup(&ud, 0); 39 if (rv != &new->h) {
38 40 if (new) auth_domain_put(&new->h);
39 foundit: 41 return rv;
40 if (rv && rv->flavour != RPC_AUTH_UNIX) { 42 }
41 auth_domain_put(rv); 43 if (rv && rv->flavour != &svcauth_unix) {
42 return NULL; 44 auth_domain_put(rv);
43 } 45 return NULL;
44 if (rv) 46 }
45 return rv; 47 if (rv)
46 48 return rv;
47 new = kmalloc(sizeof(*new), GFP_KERNEL); 49
48 if (new == NULL) 50 new = kmalloc(sizeof(*new), GFP_KERNEL);
49 return NULL; 51 if (new == NULL)
50 cache_init(&new->h.h); 52 return NULL;
51 new->h.name = kstrdup(name, GFP_KERNEL); 53 kref_init(&new->h.ref);
52 new->h.flavour = RPC_AUTH_UNIX; 54 new->h.name = kstrdup(name, GFP_KERNEL);
53 new->addr_changes = 0; 55 new->h.flavour = &svcauth_unix;
54 new->h.h.expiry_time = NEVER; 56 new->addr_changes = 0;
55 57 rv = auth_domain_lookup(name, &new->h);
56 rv = auth_domain_lookup(&new->h, 2);
57 if (rv == &new->h) {
58 if (atomic_dec_and_test(&new->h.h.refcnt)) BUG();
59 } else {
60 auth_domain_put(&new->h);
61 goto foundit;
62 } 58 }
63
64 return rv;
65} 59}
66 60
67static void svcauth_unix_domain_release(struct auth_domain *dom) 61static void svcauth_unix_domain_release(struct auth_domain *dom)
@@ -130,7 +124,7 @@ static inline void ip_map_init(struct ip_map *new, struct ip_map *item)
130} 124}
131static inline void ip_map_update(struct ip_map *new, struct ip_map *item) 125static inline void ip_map_update(struct ip_map *new, struct ip_map *item)
132{ 126{
133 cache_get(&item->m_client->h.h); 127 kref_get(&item->m_client->h.ref);
134 new->m_client = item->m_client; 128 new->m_client = item->m_client;
135 new->m_add_change = item->m_add_change; 129 new->m_add_change = item->m_add_change;
136} 130}
@@ -272,7 +266,7 @@ int auth_unix_add_addr(struct in_addr addr, struct auth_domain *dom)
272 struct unix_domain *udom; 266 struct unix_domain *udom;
273 struct ip_map ip, *ipmp; 267 struct ip_map ip, *ipmp;
274 268
275 if (dom->flavour != RPC_AUTH_UNIX) 269 if (dom->flavour != &svcauth_unix)
276 return -EINVAL; 270 return -EINVAL;
277 udom = container_of(dom, struct unix_domain, h); 271 udom = container_of(dom, struct unix_domain, h);
278 strcpy(ip.m_class, "nfsd"); 272 strcpy(ip.m_class, "nfsd");
@@ -295,7 +289,7 @@ int auth_unix_forget_old(struct auth_domain *dom)
295{ 289{
296 struct unix_domain *udom; 290 struct unix_domain *udom;
297 291
298 if (dom->flavour != RPC_AUTH_UNIX) 292 if (dom->flavour != &svcauth_unix)
299 return -EINVAL; 293 return -EINVAL;
300 udom = container_of(dom, struct unix_domain, h); 294 udom = container_of(dom, struct unix_domain, h);
301 udom->addr_changes++; 295 udom->addr_changes++;
@@ -323,7 +317,7 @@ struct auth_domain *auth_unix_lookup(struct in_addr addr)
323 rv = NULL; 317 rv = NULL;
324 } else { 318 } else {
325 rv = &ipm->m_client->h; 319 rv = &ipm->m_client->h;
326 cache_get(&rv->h); 320 kref_get(&rv->ref);
327 } 321 }
328 ip_map_put(&ipm->h, &ip_map_cache); 322 ip_map_put(&ipm->h, &ip_map_cache);
329 return rv; 323 return rv;
@@ -332,7 +326,6 @@ struct auth_domain *auth_unix_lookup(struct in_addr addr)
332void svcauth_unix_purge(void) 326void svcauth_unix_purge(void)
333{ 327{
334 cache_purge(&ip_map_cache); 328 cache_purge(&ip_map_cache);
335 cache_purge(&auth_domain_cache);
336} 329}
337 330
338static int 331static int
@@ -361,7 +354,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)
361 return SVC_DENIED; 354 return SVC_DENIED;
362 case 0: 355 case 0:
363 rqstp->rq_client = &ipm->m_client->h; 356 rqstp->rq_client = &ipm->m_client->h;
364 cache_get(&rqstp->rq_client->h); 357 kref_get(&rqstp->rq_client->ref);
365 ip_map_put(&ipm->h, &ip_map_cache); 358 ip_map_put(&ipm->h, &ip_map_cache);
366 break; 359 break;
367 } 360 }