diff options
author | Trond Myklebust <trondmy@gmail.com> | 2018-10-01 10:41:45 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2018-10-03 11:54:34 -0400 |
commit | b92a8fababa9d18910a54b957be55fef7f603531 (patch) | |
tree | 498ca9d300def4b34ec581463c59c3e395ae9abc | |
parent | 608a0ab2f54ab0e301ad76a41aad979ea0d02670 (diff) |
SUNRPC: Refactor sunrpc_cache_lookup
This is a trivial split into lookup and insert functions, no change in
behavior.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r-- | net/sunrpc/cache.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 109fbe591e7b..aa8e62d61f4d 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c | |||
@@ -54,13 +54,11 @@ static void cache_init(struct cache_head *h, struct cache_detail *detail) | |||
54 | h->last_refresh = now; | 54 | h->last_refresh = now; |
55 | } | 55 | } |
56 | 56 | ||
57 | struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail, | 57 | static struct cache_head *sunrpc_cache_find(struct cache_detail *detail, |
58 | struct cache_head *key, int hash) | 58 | struct cache_head *key, int hash) |
59 | { | 59 | { |
60 | struct cache_head *new = NULL, *freeme = NULL, *tmp = NULL; | 60 | struct hlist_head *head = &detail->hash_table[hash]; |
61 | struct hlist_head *head; | 61 | struct cache_head *tmp; |
62 | |||
63 | head = &detail->hash_table[hash]; | ||
64 | 62 | ||
65 | read_lock(&detail->hash_lock); | 63 | read_lock(&detail->hash_lock); |
66 | 64 | ||
@@ -75,7 +73,15 @@ struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail, | |||
75 | } | 73 | } |
76 | } | 74 | } |
77 | read_unlock(&detail->hash_lock); | 75 | read_unlock(&detail->hash_lock); |
78 | /* Didn't find anything, insert an empty entry */ | 76 | return NULL; |
77 | } | ||
78 | |||
79 | static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail, | ||
80 | struct cache_head *key, | ||
81 | int hash) | ||
82 | { | ||
83 | struct cache_head *new, *tmp, *freeme = NULL; | ||
84 | struct hlist_head *head = &detail->hash_table[hash]; | ||
79 | 85 | ||
80 | new = detail->alloc(); | 86 | new = detail->alloc(); |
81 | if (!new) | 87 | if (!new) |
@@ -114,8 +120,19 @@ struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail, | |||
114 | cache_put(freeme, detail); | 120 | cache_put(freeme, detail); |
115 | return new; | 121 | return new; |
116 | } | 122 | } |
117 | EXPORT_SYMBOL_GPL(sunrpc_cache_lookup); | ||
118 | 123 | ||
124 | struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail, | ||
125 | struct cache_head *key, int hash) | ||
126 | { | ||
127 | struct cache_head *ret; | ||
128 | |||
129 | ret = sunrpc_cache_find(detail, key, hash); | ||
130 | if (ret) | ||
131 | return ret; | ||
132 | /* Didn't find anything, insert an empty entry */ | ||
133 | return sunrpc_cache_add_entry(detail, key, hash); | ||
134 | } | ||
135 | EXPORT_SYMBOL_GPL(sunrpc_cache_lookup); | ||
119 | 136 | ||
120 | static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch); | 137 | static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch); |
121 | 138 | ||