@@ -54,13 +54,11 @@ static void cache_init(struct cache_head *h, struct cache_detail *detail)
5454 h -> last_refresh = now ;
5555}
5656
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 )
5959{
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 ;
6462
6563 read_lock (& detail -> hash_lock );
6664
@@ -75,7 +73,15 @@ struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail,
7573 }
7674 }
7775 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 ];
7985
8086 new = detail -> alloc ();
8187 if (!new )
@@ -114,8 +120,19 @@ struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail,
114120 cache_put (freeme , detail );
115121 return new ;
116122}
117- EXPORT_SYMBOL_GPL (sunrpc_cache_lookup );
118123
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 );
119136
120137static void cache_dequeue (struct cache_detail * detail , struct cache_head * ch );
121138
0 commit comments