diff options
author | NeilBrown <neilb@suse.de> | 2006-03-27 04:15:09 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-27 11:44:43 -0500 |
commit | baab935ff3bdac20c558809da0d8e8f761840219 (patch) | |
tree | a22c3189505fe8e7ab3820c988ffd771c0b64fa6 /fs/nfsd | |
parent | ebd0cb1af3be2729cc1f574681dfba01fcf458d9 (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>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/export.c | 51 | ||||
-rw-r--r-- | fs/nfsd/nfs4idmap.c | 18 | ||||
-rw-r--r-- | fs/nfsd/nfsfh.c | 2 |
3 files changed, 33 insertions, 38 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) |
58 | static struct cache_head *expkey_table[EXPKEY_HASHMAX]; | 58 | static struct cache_head *expkey_table[EXPKEY_HASHMAX]; |
59 | 59 | ||
60 | void expkey_put(struct cache_head *item, struct cache_detail *cd) | 60 | void 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 | ||
74 | static void expkey_request(struct cache_detail *cd, | 73 | static 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 | ||
319 | static struct cache_head *export_table[EXPORT_HASHMAX]; | 318 | static struct cache_head *export_table[EXPORT_HASHMAX]; |
320 | 319 | ||
321 | void svc_export_put(struct cache_head *item, struct cache_detail *cd) | 320 | static 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 | ||
332 | static void svc_export_request(struct cache_detail *cd, | 329 | static 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 | ||
98 | static void | 98 | static void |
99 | ent_put(struct cache_head *ch, struct cache_detail *cd) | 99 | ent_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 | ||
107 | static struct cache_head * | 105 | static 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; |
276 | out: | 274 | out: |
@@ -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; |
438 | out: | 436 | out: |
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; |
564 | out_put: | 562 | out_put: |
565 | ent_put(&(*item)->h, detail); | 563 | cache_put(&(*item)->h, detail); |
566 | out_err: | 564 | out_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; |