]> git.hungrycats.org Git - linux/commitdiff
[PATCH] nfsd: make cache_init initialize reference count to 1
authorNeil Brown <neilb@cse.unsw.edu.au>
Mon, 23 Aug 2004 06:00:47 +0000 (23:00 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 23 Aug 2004 06:00:47 +0000 (23:00 -0700)
Presumably anyone creating a new cache entry is going to want a reference on
that cache; and indeed every caller of cache_init increments the reference
count immediately afterwards.  So may as well make cache_init set an initial
reference count of 1.

Also, note that cache_init initializes the flags; callers don't need to.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/linux/sunrpc/cache.h
net/sunrpc/auth_gss/svcauth_gss.c
net/sunrpc/cache.c
net/sunrpc/svcauth_unix.c

index 6c5f0060a317aaa043863dcc513d11081c75c1ea..a98b1981fc0a74c9c9c982d608e315fd63d3f07b 100644 (file)
@@ -233,7 +233,6 @@ RTN *FNAME ARGS                                                                             \
        new = kmalloc(sizeof(*new), GFP_KERNEL);                                        \
        if (new) {                                                                      \
                cache_init(&new->MEMBER);                                               \
-               cache_get(&new->MEMBER);                                                \
                goto retry;                                                             \
        }                                                                               \
        return NULL;                                                                    \
index 5822ab211707f627019b9b11bb950149ce9b19e4..ee2e9cef94c267ee7e657a2dc94415ae3c299a7e 100644 (file)
@@ -643,7 +643,6 @@ svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name)
        if (!new)
                goto out;
        cache_init(&new->h.h);
-       atomic_inc(&new->h.h.refcnt);
        new->h.name = kmalloc(strlen(name) + 1, GFP_KERNEL);
        if (!new->h.name)
                goto out_free_dom;
@@ -651,7 +650,6 @@ svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name)
        new->h.flavour = RPC_AUTH_GSS;
        new->pseudoflavor = pseudoflavor;
        new->h.h.expiry_time = NEVER;
-       new->h.h.flags = 0;
 
        test = auth_domain_lookup(&new->h, 1);
        if (test == &new->h) {
index bb54be85152326ff4d840810090e63d1fa3605bf..1ceeb11591bfbe7961466379ccd2f5c3cad960f4 100644 (file)
@@ -38,7 +38,7 @@ void cache_init(struct cache_head *h)
        time_t now = get_seconds();
        h->next = NULL;
        h->flags = 0;
-       atomic_set(&h->refcnt, 0);
+       atomic_set(&h->refcnt, 1);
        h->expiry_time = now + CACHE_NEW_EXPIRY;
        h->last_refresh = now;
 }
index 14e51e119716fd96c28e8c136423976dcd1e6013..949a33f753d91ab9577a3ced864cc41efd56e66b 100644 (file)
@@ -55,12 +55,10 @@ struct auth_domain *unix_domain_find(char *name)
        if (new == NULL)
                return NULL;
        cache_init(&new->h.h);
-       atomic_inc(&new->h.h.refcnt);
        new->h.name = strdup(name);
        new->h.flavour = RPC_AUTH_UNIX;
        new->addr_changes = 0;
        new->h.h.expiry_time = NEVER;
-       new->h.h.flags = 0;
 
        rv = auth_domain_lookup(&new->h, 2);
        if (rv == &new->h) {