aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-03-27 04:15:09 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-27 11:44:43 -0500
commitbaab935ff3bdac20c558809da0d8e8f761840219 (patch)
treea22c3189505fe8e7ab3820c988ffd771c0b64fa6
parentebd0cb1af3be2729cc1f574681dfba01fcf458d9 (diff)
[PATCH] knfsd: Convert sunrpc_cache to use krefs
.. it makes some of the code nicer. 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.c51
-rw-r--r--fs/nfsd/nfs4idmap.c18
-rw-r--r--fs/nfsd/nfsfh.c2
-rw-r--r--include/linux/nfsd/export.h4
-rw-r--r--include/linux/sunrpc/cache.h13
-rw-r--r--net/sunrpc/auth_gss/svcauth_gss.c28
-rw-r--r--net/sunrpc/cache.c20
-rw-r--r--net/sunrpc/svcauth_unix.c20
8 files changed, 72 insertions, 84 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index abd68965822f..cc811a1094cb 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -57,18 +57,17 @@ static int exp_verify_string(char *cp, int max);
57#define EXPKEY_HASHMASK (EXPKEY_HASHMAX -1) 57#define EXPKEY_HASHMASK (EXPKEY_HASHMAX -1)
58static struct cache_head *expkey_table[EXPKEY_HASHMAX]; 58static struct cache_head *expkey_table[EXPKEY_HASHMAX];
59 59
60void expkey_put(struct cache_head *item, struct cache_detail *cd) 60void expkey_put(struct kref *ref)
61{ 61{
62 if (cache_put(item, cd)) { 62 struct svc_expkey *key = container_of(ref, struct svc_expkey, h.ref);
63 struct svc_expkey *key = container_of(item, struct svc_expkey, h); 63
64 if (test_bit(CACHE_VALID, &item->flags) && 64 if (test_bit(CACHE_VALID, &key->h.flags) &&
65 !test_bit(CACHE_NEGATIVE, &item->flags)) { 65 !test_bit(CACHE_NEGATIVE, &key->h.flags)) {
66 dput(key->ek_dentry); 66 dput(key->ek_dentry);
67 mntput(key->ek_mnt); 67 mntput(key->ek_mnt);
68 }
69 auth_domain_put(key->ek_client);
70 kfree(key);
71 } 68 }
69 auth_domain_put(key->ek_client);
70 kfree(key);
72} 71}
73 72
74static void expkey_request(struct cache_detail *cd, 73static void expkey_request(struct cache_detail *cd,
@@ -158,7 +157,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
158 set_bit(CACHE_NEGATIVE, &key.h.flags); 157 set_bit(CACHE_NEGATIVE, &key.h.flags);
159 ek = svc_expkey_update(&key, ek); 158 ek = svc_expkey_update(&key, ek);
160 if (ek) 159 if (ek)
161 expkey_put(&ek->h, &svc_expkey_cache); 160 cache_put(&ek->h, &svc_expkey_cache);
162 else err = -ENOMEM; 161 else err = -ENOMEM;
163 } else { 162 } else {
164 struct nameidata nd; 163 struct nameidata nd;
@@ -172,7 +171,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
172 171
173 ek = svc_expkey_update(&key, ek); 172 ek = svc_expkey_update(&key, ek);
174 if (ek) 173 if (ek)
175 expkey_put(&ek->h, &svc_expkey_cache); 174 cache_put(&ek->h, &svc_expkey_cache);
176 else 175 else
177 err = -ENOMEM; 176 err = -ENOMEM;
178 path_release(&nd); 177 path_release(&nd);
@@ -318,15 +317,13 @@ svc_expkey_update(struct svc_expkey *new, struct svc_expkey *old)
318 317
319static struct cache_head *export_table[EXPORT_HASHMAX]; 318static struct cache_head *export_table[EXPORT_HASHMAX];
320 319
321void svc_export_put(struct cache_head *item, struct cache_detail *cd) 320static void svc_export_put(struct kref *ref)
322{ 321{
323 if (cache_put(item, cd)) { 322 struct svc_export *exp = container_of(ref, struct svc_export, h.ref);
324 struct svc_export *exp = container_of(item, struct svc_export, h); 323 dput(exp->ex_dentry);
325 dput(exp->ex_dentry); 324 mntput(exp->ex_mnt);
326 mntput(exp->ex_mnt); 325 auth_domain_put(exp->ex_client);
327 auth_domain_put(exp->ex_client); 326 kfree(exp);
328 kfree(exp);
329 }
330} 327}
331 328
332static void svc_export_request(struct cache_detail *cd, 329static void svc_export_request(struct cache_detail *cd,
@@ -633,7 +630,7 @@ static int exp_set_key(svc_client *clp, int fsid_type, u32 *fsidv,
633 if (ek) 630 if (ek)
634 ek = svc_expkey_update(&key,ek); 631 ek = svc_expkey_update(&key,ek);
635 if (ek) { 632 if (ek) {
636 expkey_put(&ek->h, &svc_expkey_cache); 633 cache_put(&ek->h, &svc_expkey_cache);
637 return 0; 634 return 0;
638 } 635 }
639 return -ENOMEM; 636 return -ENOMEM;
@@ -762,7 +759,7 @@ static void exp_fsid_unhash(struct svc_export *exp)
762 ek = exp_get_fsid_key(exp->ex_client, exp->ex_fsid); 759 ek = exp_get_fsid_key(exp->ex_client, exp->ex_fsid);
763 if (ek && !IS_ERR(ek)) { 760 if (ek && !IS_ERR(ek)) {
764 ek->h.expiry_time = get_seconds()-1; 761 ek->h.expiry_time = get_seconds()-1;
765 expkey_put(&ek->h, &svc_expkey_cache); 762 cache_put(&ek->h, &svc_expkey_cache);
766 } 763 }
767 svc_expkey_cache.nextcheck = get_seconds(); 764 svc_expkey_cache.nextcheck = get_seconds();
768} 765}
@@ -800,7 +797,7 @@ static void exp_unhash(struct svc_export *exp)
800 ek = exp_get_key(exp->ex_client, inode->i_sb->s_dev, inode->i_ino); 797 ek = exp_get_key(exp->ex_client, inode->i_sb->s_dev, inode->i_ino);
801 if (ek && !IS_ERR(ek)) { 798 if (ek && !IS_ERR(ek)) {
802 ek->h.expiry_time = get_seconds()-1; 799 ek->h.expiry_time = get_seconds()-1;
803 expkey_put(&ek->h, &svc_expkey_cache); 800 cache_put(&ek->h, &svc_expkey_cache);
804 } 801 }
805 svc_expkey_cache.nextcheck = get_seconds(); 802 svc_expkey_cache.nextcheck = get_seconds();
806} 803}
@@ -902,7 +899,7 @@ finish:
902 if (exp) 899 if (exp)
903 exp_put(exp); 900 exp_put(exp);
904 if (fsid_key && !IS_ERR(fsid_key)) 901 if (fsid_key && !IS_ERR(fsid_key))
905 expkey_put(&fsid_key->h, &svc_expkey_cache); 902 cache_put(&fsid_key->h, &svc_expkey_cache);
906 if (clp) 903 if (clp)
907 auth_domain_put(clp); 904 auth_domain_put(clp);
908 path_release(&nd); 905 path_release(&nd);
@@ -1030,7 +1027,7 @@ exp_find(struct auth_domain *clp, int fsid_type, u32 *fsidv,
1030 return ERR_PTR(PTR_ERR(ek)); 1027 return ERR_PTR(PTR_ERR(ek));
1031 1028
1032 exp = exp_get_by_name(clp, ek->ek_mnt, ek->ek_dentry, reqp); 1029 exp = exp_get_by_name(clp, ek->ek_mnt, ek->ek_dentry, reqp);
1033 expkey_put(&ek->h, &svc_expkey_cache); 1030 cache_put(&ek->h, &svc_expkey_cache);
1034 1031
1035 if (!exp || IS_ERR(exp)) 1032 if (!exp || IS_ERR(exp))
1036 return ERR_PTR(PTR_ERR(exp)); 1033 return ERR_PTR(PTR_ERR(exp));
@@ -1068,7 +1065,7 @@ exp_pseudoroot(struct auth_domain *clp, struct svc_fh *fhp,
1068 else 1065 else
1069 rv = fh_compose(fhp, exp, 1066 rv = fh_compose(fhp, exp,
1070 fsid_key->ek_dentry, NULL); 1067 fsid_key->ek_dentry, NULL);
1071 expkey_put(&fsid_key->h, &svc_expkey_cache); 1068 cache_put(&fsid_key->h, &svc_expkey_cache);
1072 return rv; 1069 return rv;
1073} 1070}
1074 1071
@@ -1187,7 +1184,7 @@ static int e_show(struct seq_file *m, void *p)
1187 cache_get(&exp->h); 1184 cache_get(&exp->h);
1188 if (cache_check(&svc_export_cache, &exp->h, NULL)) 1185 if (cache_check(&svc_export_cache, &exp->h, NULL))
1189 return 0; 1186 return 0;
1190 if (cache_put(&exp->h, &svc_export_cache)) BUG(); 1187 cache_put(&exp->h, &svc_export_cache);
1191 return svc_export_show(m, &svc_export_cache, cp); 1188 return svc_export_show(m, &svc_export_cache, cp);
1192} 1189}
1193 1190
diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
index 75cfbb68b205..4b6aa60dfceb 100644
--- a/fs/nfsd/nfs4idmap.c
+++ b/fs/nfsd/nfs4idmap.c
@@ -96,12 +96,10 @@ ent_init(struct cache_head *cnew, struct cache_head *citm)
96} 96}
97 97
98static void 98static void
99ent_put(struct cache_head *ch, struct cache_detail *cd) 99ent_put(struct kref *ref)
100{ 100{
101 if (cache_put(ch, cd)) { 101 struct ent *map = container_of(ref, struct ent, h.ref);
102 struct ent *map = container_of(ch, struct ent, h); 102 kfree(map);
103 kfree(map);
104 }
105} 103}
106 104
107static struct cache_head * 105static struct cache_head *
@@ -270,7 +268,7 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
270 if (res == NULL) 268 if (res == NULL)
271 goto out; 269 goto out;
272 270
273 ent_put(&res->h, &idtoname_cache); 271 cache_put(&res->h, &idtoname_cache);
274 272
275 error = 0; 273 error = 0;
276out: 274out:
@@ -433,7 +431,7 @@ nametoid_parse(struct cache_detail *cd, char *buf, int buflen)
433 if (res == NULL) 431 if (res == NULL)
434 goto out; 432 goto out;
435 433
436 ent_put(&res->h, &nametoid_cache); 434 cache_put(&res->h, &nametoid_cache);
437 error = 0; 435 error = 0;
438out: 436out:
439 kfree(buf1); 437 kfree(buf1);
@@ -562,7 +560,7 @@ do_idmap_lookup_nowait(struct ent *(*lookup_fn)(struct ent *),
562 goto out_put; 560 goto out_put;
563 return 0; 561 return 0;
564out_put: 562out_put:
565 ent_put(&(*item)->h, detail); 563 cache_put(&(*item)->h, detail);
566out_err: 564out_err:
567 *item = NULL; 565 *item = NULL;
568 return ret; 566 return ret;
@@ -613,7 +611,7 @@ idmap_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen
613 if (ret) 611 if (ret)
614 return ret; 612 return ret;
615 *id = item->id; 613 *id = item->id;
616 ent_put(&item->h, &nametoid_cache); 614 cache_put(&item->h, &nametoid_cache);
617 return 0; 615 return 0;
618} 616}
619 617
@@ -635,7 +633,7 @@ idmap_id_to_name(struct svc_rqst *rqstp, int type, uid_t id, char *name)
635 ret = strlen(item->name); 633 ret = strlen(item->name);
636 BUG_ON(ret > IDMAP_NAMESZ); 634 BUG_ON(ret > IDMAP_NAMESZ);
637 memcpy(name, item->name, ret); 635 memcpy(name, item->name, ret);
638 ent_put(&item->h, &idtoname_cache); 636 cache_put(&item->h, &idtoname_cache);
639 return ret; 637 return ret;
640} 638}
641 639
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index 7a3e397b4ed3..3f2ec2e6d06c 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -506,7 +506,7 @@ fh_put(struct svc_fh *fhp)
506 nfsd_nr_put++; 506 nfsd_nr_put++;
507 } 507 }
508 if (exp) { 508 if (exp) {
509 svc_export_put(&exp->h, &svc_export_cache); 509 cache_put(&exp->h, &svc_export_cache);
510 fhp->fh_export = NULL; 510 fhp->fh_export = NULL;
511 } 511 }
512 return; 512 return;
diff --git a/include/linux/nfsd/export.h b/include/linux/nfsd/export.h
index d52e0b7ad37b..a6c08a47b25c 100644
--- a/include/linux/nfsd/export.h
+++ b/include/linux/nfsd/export.h
@@ -102,13 +102,11 @@ int exp_rootfh(struct auth_domain *,
102int exp_pseudoroot(struct auth_domain *, struct svc_fh *fhp, struct cache_req *creq); 102int exp_pseudoroot(struct auth_domain *, struct svc_fh *fhp, struct cache_req *creq);
103int nfserrno(int errno); 103int nfserrno(int errno);
104 104
105extern void expkey_put(struct cache_head *item, struct cache_detail *cd);
106extern void svc_export_put(struct cache_head *item, struct cache_detail *cd);
107extern struct cache_detail svc_export_cache, svc_expkey_cache; 105extern struct cache_detail svc_export_cache, svc_expkey_cache;
108 106
109static inline void exp_put(struct svc_export *exp) 107static inline void exp_put(struct svc_export *exp)
110{ 108{
111 svc_export_put(&exp->h, &svc_export_cache); 109 cache_put(&exp->h, &svc_export_cache);
112} 110}
113 111
114static inline void exp_get(struct svc_export *exp) 112static inline void exp_get(struct svc_export *exp)
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
index a37fead1873b..ad3f5cbdb770 100644
--- a/include/linux/sunrpc/cache.h
+++ b/include/linux/sunrpc/cache.h
@@ -50,7 +50,7 @@ struct cache_head {
50 time_t last_refresh; /* If CACHE_PENDING, this is when upcall 50 time_t last_refresh; /* If CACHE_PENDING, this is when upcall
51 * was sent, else this is when update was received 51 * was sent, else this is when update was received
52 */ 52 */
53 atomic_t refcnt; 53 struct kref ref;
54 unsigned long flags; 54 unsigned long flags;
55}; 55};
56#define CACHE_VALID 0 /* Entry contains valid data */ 56#define CACHE_VALID 0 /* Entry contains valid data */
@@ -68,8 +68,7 @@ struct cache_detail {
68 atomic_t inuse; /* active user-space update or lookup */ 68 atomic_t inuse; /* active user-space update or lookup */
69 69
70 char *name; 70 char *name;
71 void (*cache_put)(struct cache_head *, 71 void (*cache_put)(struct kref *);
72 struct cache_detail*);
73 72
74 void (*cache_request)(struct cache_detail *cd, 73 void (*cache_request)(struct cache_detail *cd,
75 struct cache_head *h, 74 struct cache_head *h,
@@ -151,17 +150,17 @@ extern void cache_clean_deferred(void *owner);
151 150
152static inline struct cache_head *cache_get(struct cache_head *h) 151static inline struct cache_head *cache_get(struct cache_head *h)
153{ 152{
154 atomic_inc(&h->refcnt); 153 kref_get(&h->ref);
155 return h; 154 return h;
156} 155}
157 156
158 157
159static inline int cache_put(struct cache_head *h, struct cache_detail *cd) 158static inline void cache_put(struct cache_head *h, struct cache_detail *cd)
160{ 159{
161 if (atomic_read(&h->refcnt) <= 2 && 160 if (atomic_read(&h->ref.refcount) <= 2 &&
162 h->expiry_time < cd->nextcheck) 161 h->expiry_time < cd->nextcheck)
163 cd->nextcheck = h->expiry_time; 162 cd->nextcheck = h->expiry_time;
164 return atomic_dec_and_test(&h->refcnt); 163 kref_put(&h->ref, cd->cache_put);
165} 164}
166 165
167extern void cache_init(struct cache_head *h); 166extern void cache_init(struct cache_head *h);
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 380152603d1e..4d7eb9e704da 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -89,13 +89,11 @@ static void rsi_free(struct rsi *rsii)
89 kfree(rsii->out_token.data); 89 kfree(rsii->out_token.data);
90} 90}
91 91
92static void rsi_put(struct cache_head *item, struct cache_detail *cd) 92static void rsi_put(struct kref *ref)
93{ 93{
94 struct rsi *rsii = container_of(item, struct rsi, h); 94 struct rsi *rsii = container_of(ref, struct rsi, h.ref);
95 if (cache_put(item, cd)) { 95 rsi_free(rsii);
96 rsi_free(rsii); 96 kfree(rsii);
97 kfree(rsii);
98 }
99} 97}
100 98
101static inline int rsi_hash(struct rsi *item) 99static inline int rsi_hash(struct rsi *item)
@@ -267,7 +265,7 @@ static int rsi_parse(struct cache_detail *cd,
267out: 265out:
268 rsi_free(&rsii); 266 rsi_free(&rsii);
269 if (rsip) 267 if (rsip)
270 rsi_put(&rsip->h, &rsi_cache); 268 cache_put(&rsip->h, &rsi_cache);
271 else 269 else
272 status = -ENOMEM; 270 status = -ENOMEM;
273 return status; 271 return status;
@@ -357,14 +355,12 @@ static void rsc_free(struct rsc *rsci)
357 put_group_info(rsci->cred.cr_group_info); 355 put_group_info(rsci->cred.cr_group_info);
358} 356}
359 357
360static void rsc_put(struct cache_head *item, struct cache_detail *cd) 358static void rsc_put(struct kref *ref)
361{ 359{
362 struct rsc *rsci = container_of(item, struct rsc, h); 360 struct rsc *rsci = container_of(ref, struct rsc, h.ref);
363 361
364 if (cache_put(item, cd)) { 362 rsc_free(rsci);
365 rsc_free(rsci); 363 kfree(rsci);
366 kfree(rsci);
367 }
368} 364}
369 365
370static inline int 366static inline int
@@ -509,7 +505,7 @@ static int rsc_parse(struct cache_detail *cd,
509out: 505out:
510 rsc_free(&rsci); 506 rsc_free(&rsci);
511 if (rscp) 507 if (rscp)
512 rsc_put(&rscp->h, &rsc_cache); 508 cache_put(&rscp->h, &rsc_cache);
513 else 509 else
514 status = -ENOMEM; 510 status = -ENOMEM;
515 return status; 511 return status;
@@ -1076,7 +1072,7 @@ drop:
1076 ret = SVC_DROP; 1072 ret = SVC_DROP;
1077out: 1073out:
1078 if (rsci) 1074 if (rsci)
1079 rsc_put(&rsci->h, &rsc_cache); 1075 cache_put(&rsci->h, &rsc_cache);
1080 return ret; 1076 return ret;
1081} 1077}
1082 1078
@@ -1168,7 +1164,7 @@ out_err:
1168 put_group_info(rqstp->rq_cred.cr_group_info); 1164 put_group_info(rqstp->rq_cred.cr_group_info);
1169 rqstp->rq_cred.cr_group_info = NULL; 1165 rqstp->rq_cred.cr_group_info = NULL;
1170 if (gsd->rsci) 1166 if (gsd->rsci)
1171 rsc_put(&gsd->rsci->h, &rsc_cache); 1167 cache_put(&gsd->rsci->h, &rsc_cache);
1172 gsd->rsci = NULL; 1168 gsd->rsci = NULL;
1173 1169
1174 return stat; 1170 return stat;
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index edcda4fd88e8..dd81e5928172 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -42,7 +42,7 @@ void cache_init(struct cache_head *h)
42 time_t now = get_seconds(); 42 time_t now = get_seconds();
43 h->next = NULL; 43 h->next = NULL;
44 h->flags = 0; 44 h->flags = 0;
45 atomic_set(&h->refcnt, 1); 45 kref_init(&h->ref);
46 h->expiry_time = now + CACHE_NEW_EXPIRY; 46 h->expiry_time = now + CACHE_NEW_EXPIRY;
47 h->last_refresh = now; 47 h->last_refresh = now;
48} 48}
@@ -81,7 +81,7 @@ struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail,
81 if (detail->match(tmp, key)) { 81 if (detail->match(tmp, key)) {
82 cache_get(tmp); 82 cache_get(tmp);
83 write_unlock(&detail->hash_lock); 83 write_unlock(&detail->hash_lock);
84 detail->cache_put(new, detail); 84 cache_put(new, detail);
85 return tmp; 85 return tmp;
86 } 86 }
87 } 87 }
@@ -145,7 +145,7 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail,
145 /* We need to insert a new entry */ 145 /* We need to insert a new entry */
146 tmp = detail->alloc(); 146 tmp = detail->alloc();
147 if (!tmp) { 147 if (!tmp) {
148 detail->cache_put(old, detail); 148 cache_put(old, detail);
149 return NULL; 149 return NULL;
150 } 150 }
151 cache_init(tmp); 151 cache_init(tmp);
@@ -165,7 +165,7 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail,
165 write_unlock(&detail->hash_lock); 165 write_unlock(&detail->hash_lock);
166 cache_fresh_unlocked(tmp, detail, is_new); 166 cache_fresh_unlocked(tmp, detail, is_new);
167 cache_fresh_unlocked(old, detail, 0); 167 cache_fresh_unlocked(old, detail, 0);
168 detail->cache_put(old, detail); 168 cache_put(old, detail);
169 return tmp; 169 return tmp;
170} 170}
171EXPORT_SYMBOL(sunrpc_cache_update); 171EXPORT_SYMBOL(sunrpc_cache_update);
@@ -234,7 +234,7 @@ int cache_check(struct cache_detail *detail,
234 cache_defer_req(rqstp, h); 234 cache_defer_req(rqstp, h);
235 235
236 if (rv) 236 if (rv)
237 detail->cache_put(h, detail); 237 cache_put(h, detail);
238 return rv; 238 return rv;
239} 239}
240 240
@@ -431,7 +431,7 @@ static int cache_clean(void)
431 if (test_and_clear_bit(CACHE_PENDING, &ch->flags)) 431 if (test_and_clear_bit(CACHE_PENDING, &ch->flags))
432 queue_loose(current_detail, ch); 432 queue_loose(current_detail, ch);
433 433
434 if (atomic_read(&ch->refcnt) == 1) 434 if (atomic_read(&ch->ref.refcount) == 1)
435 break; 435 break;
436 } 436 }
437 if (ch) { 437 if (ch) {
@@ -446,7 +446,7 @@ static int cache_clean(void)
446 current_index ++; 446 current_index ++;
447 spin_unlock(&cache_list_lock); 447 spin_unlock(&cache_list_lock);
448 if (ch) 448 if (ch)
449 d->cache_put(ch, d); 449 cache_put(ch, d);
450 } else 450 } else
451 spin_unlock(&cache_list_lock); 451 spin_unlock(&cache_list_lock);
452 452
@@ -723,7 +723,7 @@ cache_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
723 !test_bit(CACHE_PENDING, &rq->item->flags)) { 723 !test_bit(CACHE_PENDING, &rq->item->flags)) {
724 list_del(&rq->q.list); 724 list_del(&rq->q.list);
725 spin_unlock(&queue_lock); 725 spin_unlock(&queue_lock);
726 cd->cache_put(rq->item, cd); 726 cache_put(rq->item, cd);
727 kfree(rq->buf); 727 kfree(rq->buf);
728 kfree(rq); 728 kfree(rq);
729 } else 729 } else
@@ -906,7 +906,7 @@ static void queue_loose(struct cache_detail *detail, struct cache_head *ch)
906 continue; 906 continue;
907 list_del(&cr->q.list); 907 list_del(&cr->q.list);
908 spin_unlock(&queue_lock); 908 spin_unlock(&queue_lock);
909 detail->cache_put(cr->item, detail); 909 cache_put(cr->item, detail);
910 kfree(cr->buf); 910 kfree(cr->buf);
911 kfree(cr); 911 kfree(cr);
912 return; 912 return;
@@ -1192,7 +1192,7 @@ static int c_show(struct seq_file *m, void *p)
1192 1192
1193 ifdebug(CACHE) 1193 ifdebug(CACHE)
1194 seq_printf(m, "# expiry=%ld refcnt=%d flags=%lx\n", 1194 seq_printf(m, "# expiry=%ld refcnt=%d flags=%lx\n",
1195 cp->expiry_time, atomic_read(&cp->refcnt), cp->flags); 1195 cp->expiry_time, atomic_read(&cp->ref.refcount), cp->flags);
1196 cache_get(cp); 1196 cache_get(cp);
1197 if (cache_check(cd, cp, NULL)) 1197 if (cache_check(cd, cp, NULL))
1198 /* cache_check does a cache_put on failure */ 1198 /* cache_check does a cache_put on failure */
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index 7e38621a20b7..11020c0b7db5 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -84,15 +84,15 @@ struct ip_map {
84}; 84};
85static struct cache_head *ip_table[IP_HASHMAX]; 85static struct cache_head *ip_table[IP_HASHMAX];
86 86
87static void ip_map_put(struct cache_head *item, struct cache_detail *cd) 87static void ip_map_put(struct kref *kref)
88{ 88{
89 struct cache_head *item = container_of(kref, struct cache_head, ref);
89 struct ip_map *im = container_of(item, struct ip_map,h); 90 struct ip_map *im = container_of(item, struct ip_map,h);
90 if (cache_put(item, cd)) { 91
91 if (test_bit(CACHE_VALID, &item->flags) && 92 if (test_bit(CACHE_VALID, &item->flags) &&
92 !test_bit(CACHE_NEGATIVE, &item->flags)) 93 !test_bit(CACHE_NEGATIVE, &item->flags))
93 auth_domain_put(&im->m_client->h); 94 auth_domain_put(&im->m_client->h);
94 kfree(im); 95 kfree(im);
95 }
96} 96}
97 97
98#if IP_HASHBITS == 8 98#if IP_HASHBITS == 8
@@ -315,7 +315,7 @@ static int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t ex
315 hash_ip((unsigned long)ipm->m_addr.s_addr)); 315 hash_ip((unsigned long)ipm->m_addr.s_addr));
316 if (!ch) 316 if (!ch)
317 return -ENOMEM; 317 return -ENOMEM;
318 ip_map_put(ch, &ip_map_cache); 318 cache_put(ch, &ip_map_cache);
319 return 0; 319 return 0;
320} 320}
321 321
@@ -369,7 +369,7 @@ struct auth_domain *auth_unix_lookup(struct in_addr addr)
369 rv = &ipm->m_client->h; 369 rv = &ipm->m_client->h;
370 kref_get(&rv->ref); 370 kref_get(&rv->ref);
371 } 371 }
372 ip_map_put(&ipm->h, &ip_map_cache); 372 cache_put(&ipm->h, &ip_map_cache);
373 return rv; 373 return rv;
374} 374}
375 375
@@ -403,7 +403,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)
403 case 0: 403 case 0:
404 rqstp->rq_client = &ipm->m_client->h; 404 rqstp->rq_client = &ipm->m_client->h;
405 kref_get(&rqstp->rq_client->ref); 405 kref_get(&rqstp->rq_client->ref);
406 ip_map_put(&ipm->h, &ip_map_cache); 406 cache_put(&ipm->h, &ip_map_cache);
407 break; 407 break;
408 } 408 }
409 return SVC_OK; 409 return SVC_OK;