Commit d48cf356 authored by Trond Myklebust's avatar Trond Myklebust Committed by J. Bruce Fields

SUNRPC: Remove non-RCU protected lookup

Clean up the cache code by removing the non-RCU protected lookup.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent a6482733
...@@ -84,7 +84,7 @@ Creating a Cache ...@@ -84,7 +84,7 @@ Creating a Cache
A message from user space has arrived to fill out a A message from user space has arrived to fill out a
cache entry. It is in 'buf' of length 'len'. cache entry. It is in 'buf' of length 'len'.
cache_parse should parse this, find the item in the cache_parse should parse this, find the item in the
cache with sunrpc_cache_lookup, and update the item cache with sunrpc_cache_lookup_rcu, and update the item
with sunrpc_cache_update. with sunrpc_cache_update.
...@@ -95,7 +95,7 @@ Creating a Cache ...@@ -95,7 +95,7 @@ Creating a Cache
Using a cache Using a cache
------------- -------------
To find a value in a cache, call sunrpc_cache_lookup passing a pointer To find a value in a cache, call sunrpc_cache_lookup_rcu passing a pointer
to the cache_head in a sample item with the 'key' fields filled in. to the cache_head in a sample item with the 'key' fields filled in.
This will be passed to ->match to identify the target entry. If no This will be passed to ->match to identify the target entry. If no
entry is found, a new entry will be create, added to the cache, and entry is found, a new entry will be create, added to the cache, and
...@@ -116,7 +116,7 @@ item does become valid, the deferred copy of the request will be ...@@ -116,7 +116,7 @@ item does become valid, the deferred copy of the request will be
revisited (->revisit). It is expected that this method will revisited (->revisit). It is expected that this method will
reschedule the request for processing. reschedule the request for processing.
The value returned by sunrpc_cache_lookup can also be passed to The value returned by sunrpc_cache_lookup_rcu can also be passed to
sunrpc_cache_update to set the content for the item. A second item is sunrpc_cache_update to set the content for the item. A second item is
passed which should hold the content. If the item found by _lookup passed which should hold the content. If the item found by _lookup
has valid data, then it is discarded and a new item is created. This has valid data, then it is discarded and a new item is created. This
......
...@@ -171,9 +171,6 @@ extern struct cache_head * ...@@ -171,9 +171,6 @@ extern struct cache_head *
sunrpc_cache_lookup_rcu(struct cache_detail *detail, sunrpc_cache_lookup_rcu(struct cache_detail *detail,
struct cache_head *key, int hash); struct cache_head *key, int hash);
extern struct cache_head * extern struct cache_head *
sunrpc_cache_lookup(struct cache_detail *detail,
struct cache_head *key, int hash);
extern struct cache_head *
sunrpc_cache_update(struct cache_detail *detail, sunrpc_cache_update(struct cache_detail *detail,
struct cache_head *new, struct cache_head *old, int hash); struct cache_head *new, struct cache_head *old, int hash);
...@@ -233,9 +230,6 @@ extern void sunrpc_cache_unregister_pipefs(struct cache_detail *); ...@@ -233,9 +230,6 @@ extern void sunrpc_cache_unregister_pipefs(struct cache_detail *);
extern void sunrpc_cache_unhash(struct cache_detail *, struct cache_head *); extern void sunrpc_cache_unhash(struct cache_detail *, struct cache_head *);
/* Must store cache_detail in seq_file->private if using next three functions */ /* Must store cache_detail in seq_file->private if using next three functions */
extern void *cache_seq_start(struct seq_file *file, loff_t *pos);
extern void *cache_seq_next(struct seq_file *file, void *p, loff_t *pos);
extern void cache_seq_stop(struct seq_file *file, void *p);
extern void *cache_seq_start_rcu(struct seq_file *file, loff_t *pos); extern void *cache_seq_start_rcu(struct seq_file *file, loff_t *pos);
extern void *cache_seq_next_rcu(struct seq_file *file, void *p, loff_t *pos); extern void *cache_seq_next_rcu(struct seq_file *file, void *p, loff_t *pos);
extern void cache_seq_stop_rcu(struct seq_file *file, void *p); extern void cache_seq_stop_rcu(struct seq_file *file, void *p);
......
...@@ -75,27 +75,6 @@ static struct cache_head *sunrpc_cache_find_rcu(struct cache_detail *detail, ...@@ -75,27 +75,6 @@ static struct cache_head *sunrpc_cache_find_rcu(struct cache_detail *detail,
return NULL; return NULL;
} }
static struct cache_head *sunrpc_cache_find(struct cache_detail *detail,
struct cache_head *key, int hash)
{
struct hlist_head *head = &detail->hash_table[hash];
struct cache_head *tmp;
read_lock(&detail->hash_lock);
hlist_for_each_entry(tmp, head, cache_list) {
if (detail->match(tmp, key)) {
if (cache_is_expired(detail, tmp))
/* This entry is expired, we will discard it. */
break;
cache_get(tmp);
read_unlock(&detail->hash_lock);
return tmp;
}
}
read_unlock(&detail->hash_lock);
return NULL;
}
static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail, static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail,
struct cache_head *key, struct cache_head *key,
int hash) int hash)
...@@ -154,20 +133,6 @@ struct cache_head *sunrpc_cache_lookup_rcu(struct cache_detail *detail, ...@@ -154,20 +133,6 @@ struct cache_head *sunrpc_cache_lookup_rcu(struct cache_detail *detail,
} }
EXPORT_SYMBOL_GPL(sunrpc_cache_lookup_rcu); EXPORT_SYMBOL_GPL(sunrpc_cache_lookup_rcu);
struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail,
struct cache_head *key, int hash)
{
struct cache_head *ret;
ret = sunrpc_cache_find(detail, key, hash);
if (ret)
return ret;
/* Didn't find anything, insert an empty entry */
return sunrpc_cache_add_entry(detail, key, hash);
}
EXPORT_SYMBOL_GPL(sunrpc_cache_lookup);
static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch); static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch);
static void cache_fresh_locked(struct cache_head *head, time_t expiry, static void cache_fresh_locked(struct cache_head *head, time_t expiry,
...@@ -1369,17 +1334,7 @@ static void *__cache_seq_start(struct seq_file *m, loff_t *pos) ...@@ -1369,17 +1334,7 @@ static void *__cache_seq_start(struct seq_file *m, loff_t *pos)
struct cache_head, cache_list); struct cache_head, cache_list);
} }
void *cache_seq_start(struct seq_file *m, loff_t *pos) static void *cache_seq_next(struct seq_file *m, void *p, loff_t *pos)
__acquires(cd->hash_lock)
{
struct cache_detail *cd = m->private;
read_lock(&cd->hash_lock);
return __cache_seq_start(m, pos);
}
EXPORT_SYMBOL_GPL(cache_seq_start);
void *cache_seq_next(struct seq_file *m, void *p, loff_t *pos)
{ {
struct cache_head *ch = p; struct cache_head *ch = p;
int hash = (*pos >> 32); int hash = (*pos >> 32);
...@@ -1411,14 +1366,6 @@ void *cache_seq_next(struct seq_file *m, void *p, loff_t *pos) ...@@ -1411,14 +1366,6 @@ void *cache_seq_next(struct seq_file *m, void *p, loff_t *pos)
} }
EXPORT_SYMBOL_GPL(cache_seq_next); EXPORT_SYMBOL_GPL(cache_seq_next);
void cache_seq_stop(struct seq_file *m, void *p)
__releases(cd->hash_lock)
{
struct cache_detail *cd = m->private;
read_unlock(&cd->hash_lock);
}
EXPORT_SYMBOL_GPL(cache_seq_stop);
void *cache_seq_start_rcu(struct seq_file *m, loff_t *pos) void *cache_seq_start_rcu(struct seq_file *m, loff_t *pos)
__acquires(RCU) __acquires(RCU)
{ {
...@@ -1466,9 +1413,9 @@ static int c_show(struct seq_file *m, void *p) ...@@ -1466,9 +1413,9 @@ static int c_show(struct seq_file *m, void *p)
} }
static const struct seq_operations cache_content_op = { static const struct seq_operations cache_content_op = {
.start = cache_seq_start, .start = cache_seq_start_rcu,
.next = cache_seq_next, .next = cache_seq_next_rcu,
.stop = cache_seq_stop, .stop = cache_seq_stop_rcu,
.show = c_show, .show = c_show,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment