@@ -54,13 +54,11 @@ static void cache_init(struct cache_head *h, struct cache_detail *detail)
54
54
h -> last_refresh = now ;
55
55
}
56
56
57
- struct cache_head * sunrpc_cache_lookup (struct cache_detail * detail ,
58
- struct cache_head * key , int hash )
57
+ static struct cache_head * sunrpc_cache_find (struct cache_detail * detail ,
58
+ struct cache_head * key , int hash )
59
59
{
60
- struct cache_head * new = NULL , * freeme = NULL , * tmp = NULL ;
61
- struct hlist_head * head ;
62
-
63
- head = & detail -> hash_table [hash ];
60
+ struct hlist_head * head = & detail -> hash_table [hash ];
61
+ struct cache_head * tmp ;
64
62
65
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
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
86
new = detail -> alloc ();
81
87
if (!new )
@@ -114,8 +120,19 @@ struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail,
114
120
cache_put (freeme , detail );
115
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
137
static void cache_dequeue (struct cache_detail * detail , struct cache_head * ch );
121
138
0 commit comments