diff options
author | NeilBrown <neilb@suse.de> | 2010-08-12 02:55:22 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2010-09-07 19:21:19 -0400 |
commit | 17cebf658e088935d4bdebfc7ad9800e9fc4a0b2 (patch) | |
tree | 7bc6c1d8de35bce17da188cba13688671d517907 | |
parent | 1132b26029918aa8fb5ba24a81b5c234e61f356c (diff) |
sunrpc: extract some common sunrpc_cache code from nfsd
Rather can duplicating this idiom twice, put it in an inline function.
This reduces the usage of 'expiry_time' out side the sunrpc/cache.c
code and thus the impact of a change that is about to be made to that
field.
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r-- | fs/nfsd/export.c | 9 | ||||
-rw-r--r-- | include/linux/sunrpc/cache.h | 6 |
2 files changed, 9 insertions, 6 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index c2a4f71d87dd..e56827b88fd2 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c | |||
@@ -935,10 +935,9 @@ static void exp_fsid_unhash(struct svc_export *exp) | |||
935 | 935 | ||
936 | ek = exp_get_fsid_key(exp->ex_client, exp->ex_fsid); | 936 | ek = exp_get_fsid_key(exp->ex_client, exp->ex_fsid); |
937 | if (!IS_ERR(ek)) { | 937 | if (!IS_ERR(ek)) { |
938 | ek->h.expiry_time = get_seconds()-1; | 938 | sunrpc_invalidate(&ek->h, &svc_expkey_cache); |
939 | cache_put(&ek->h, &svc_expkey_cache); | 939 | cache_put(&ek->h, &svc_expkey_cache); |
940 | } | 940 | } |
941 | svc_expkey_cache.nextcheck = get_seconds(); | ||
942 | } | 941 | } |
943 | 942 | ||
944 | static int exp_fsid_hash(svc_client *clp, struct svc_export *exp) | 943 | static int exp_fsid_hash(svc_client *clp, struct svc_export *exp) |
@@ -973,10 +972,9 @@ static void exp_unhash(struct svc_export *exp) | |||
973 | 972 | ||
974 | ek = exp_get_key(exp->ex_client, inode->i_sb->s_dev, inode->i_ino); | 973 | ek = exp_get_key(exp->ex_client, inode->i_sb->s_dev, inode->i_ino); |
975 | if (!IS_ERR(ek)) { | 974 | if (!IS_ERR(ek)) { |
976 | ek->h.expiry_time = get_seconds()-1; | 975 | sunrpc_invalidate(&ek->h, &svc_expkey_cache); |
977 | cache_put(&ek->h, &svc_expkey_cache); | 976 | cache_put(&ek->h, &svc_expkey_cache); |
978 | } | 977 | } |
979 | svc_expkey_cache.nextcheck = get_seconds(); | ||
980 | } | 978 | } |
981 | 979 | ||
982 | /* | 980 | /* |
@@ -1097,8 +1095,7 @@ out: | |||
1097 | static void | 1095 | static void |
1098 | exp_do_unexport(svc_export *unexp) | 1096 | exp_do_unexport(svc_export *unexp) |
1099 | { | 1097 | { |
1100 | unexp->h.expiry_time = get_seconds()-1; | 1098 | sunrpc_invalidate(&unexp->h, &svc_export_cache); |
1101 | svc_export_cache.nextcheck = get_seconds(); | ||
1102 | exp_unhash(unexp); | 1099 | exp_unhash(unexp); |
1103 | exp_fsid_unhash(unexp); | 1100 | exp_fsid_unhash(unexp); |
1104 | } | 1101 | } |
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 7bf3e84b92f4..0e1febf4e5bc 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h | |||
@@ -228,4 +228,10 @@ static inline time_t get_expiry(char **bpp) | |||
228 | return rv; | 228 | return rv; |
229 | } | 229 | } |
230 | 230 | ||
231 | static inline void sunrpc_invalidate(struct cache_head *h, | ||
232 | struct cache_detail *detail) | ||
233 | { | ||
234 | h->expiry_time = get_seconds() - 1; | ||
235 | detail->nextcheck = get_seconds(); | ||
236 | } | ||
231 | #endif /* _LINUX_SUNRPC_CACHE_H_ */ | 237 | #endif /* _LINUX_SUNRPC_CACHE_H_ */ |