Skip to content

Commit d48cf35

Browse files
trondmyJ. Bruce Fields
authored andcommitted
SUNRPC: Remove non-RCU protected lookup
Clean up the cache code by removing the non-RCU protected lookup. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent a648273 commit d48cf35

File tree

3 files changed

+7
-66
lines changed

3 files changed

+7
-66
lines changed

Documentation/filesystems/nfs/rpc-cache.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Creating a Cache
8484
A message from user space has arrived to fill out a
8585
cache entry. It is in 'buf' of length 'len'.
8686
cache_parse should parse this, find the item in the
87-
cache with sunrpc_cache_lookup, and update the item
87+
cache with sunrpc_cache_lookup_rcu, and update the item
8888
with sunrpc_cache_update.
8989

9090

@@ -95,7 +95,7 @@ Creating a Cache
9595
Using a cache
9696
-------------
9797

98-
To find a value in a cache, call sunrpc_cache_lookup passing a pointer
98+
To find a value in a cache, call sunrpc_cache_lookup_rcu passing a pointer
9999
to the cache_head in a sample item with the 'key' fields filled in.
100100
This will be passed to ->match to identify the target entry. If no
101101
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
116116
revisited (->revisit). It is expected that this method will
117117
reschedule the request for processing.
118118

119-
The value returned by sunrpc_cache_lookup can also be passed to
119+
The value returned by sunrpc_cache_lookup_rcu can also be passed to
120120
sunrpc_cache_update to set the content for the item. A second item is
121121
passed which should hold the content. If the item found by _lookup
122122
has valid data, then it is discarded and a new item is created. This

include/linux/sunrpc/cache.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ extern struct cache_head *
171171
sunrpc_cache_lookup_rcu(struct cache_detail *detail,
172172
struct cache_head *key, int hash);
173173
extern struct cache_head *
174-
sunrpc_cache_lookup(struct cache_detail *detail,
175-
struct cache_head *key, int hash);
176-
extern struct cache_head *
177174
sunrpc_cache_update(struct cache_detail *detail,
178175
struct cache_head *new, struct cache_head *old, int hash);
179176

@@ -233,9 +230,6 @@ extern void sunrpc_cache_unregister_pipefs(struct cache_detail *);
233230
extern void sunrpc_cache_unhash(struct cache_detail *, struct cache_head *);
234231

235232
/* Must store cache_detail in seq_file->private if using next three functions */
236-
extern void *cache_seq_start(struct seq_file *file, loff_t *pos);
237-
extern void *cache_seq_next(struct seq_file *file, void *p, loff_t *pos);
238-
extern void cache_seq_stop(struct seq_file *file, void *p);
239233
extern void *cache_seq_start_rcu(struct seq_file *file, loff_t *pos);
240234
extern void *cache_seq_next_rcu(struct seq_file *file, void *p, loff_t *pos);
241235
extern void cache_seq_stop_rcu(struct seq_file *file, void *p);

net/sunrpc/cache.c

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -75,27 +75,6 @@ static struct cache_head *sunrpc_cache_find_rcu(struct cache_detail *detail,
7575
return NULL;
7676
}
7777

78-
static struct cache_head *sunrpc_cache_find(struct cache_detail *detail,
79-
struct cache_head *key, int hash)
80-
{
81-
struct hlist_head *head = &detail->hash_table[hash];
82-
struct cache_head *tmp;
83-
84-
read_lock(&detail->hash_lock);
85-
hlist_for_each_entry(tmp, head, cache_list) {
86-
if (detail->match(tmp, key)) {
87-
if (cache_is_expired(detail, tmp))
88-
/* This entry is expired, we will discard it. */
89-
break;
90-
cache_get(tmp);
91-
read_unlock(&detail->hash_lock);
92-
return tmp;
93-
}
94-
}
95-
read_unlock(&detail->hash_lock);
96-
return NULL;
97-
}
98-
9978
static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail,
10079
struct cache_head *key,
10180
int hash)
@@ -154,20 +133,6 @@ struct cache_head *sunrpc_cache_lookup_rcu(struct cache_detail *detail,
154133
}
155134
EXPORT_SYMBOL_GPL(sunrpc_cache_lookup_rcu);
156135

157-
struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail,
158-
struct cache_head *key, int hash)
159-
{
160-
struct cache_head *ret;
161-
162-
ret = sunrpc_cache_find(detail, key, hash);
163-
if (ret)
164-
return ret;
165-
/* Didn't find anything, insert an empty entry */
166-
return sunrpc_cache_add_entry(detail, key, hash);
167-
}
168-
EXPORT_SYMBOL_GPL(sunrpc_cache_lookup);
169-
170-
171136
static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch);
172137

173138
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)
13691334
struct cache_head, cache_list);
13701335
}
13711336

1372-
void *cache_seq_start(struct seq_file *m, loff_t *pos)
1373-
__acquires(cd->hash_lock)
1374-
{
1375-
struct cache_detail *cd = m->private;
1376-
1377-
read_lock(&cd->hash_lock);
1378-
return __cache_seq_start(m, pos);
1379-
}
1380-
EXPORT_SYMBOL_GPL(cache_seq_start);
1381-
1382-
void *cache_seq_next(struct seq_file *m, void *p, loff_t *pos)
1337+
static void *cache_seq_next(struct seq_file *m, void *p, loff_t *pos)
13831338
{
13841339
struct cache_head *ch = p;
13851340
int hash = (*pos >> 32);
@@ -1411,14 +1366,6 @@ void *cache_seq_next(struct seq_file *m, void *p, loff_t *pos)
14111366
}
14121367
EXPORT_SYMBOL_GPL(cache_seq_next);
14131368

1414-
void cache_seq_stop(struct seq_file *m, void *p)
1415-
__releases(cd->hash_lock)
1416-
{
1417-
struct cache_detail *cd = m->private;
1418-
read_unlock(&cd->hash_lock);
1419-
}
1420-
EXPORT_SYMBOL_GPL(cache_seq_stop);
1421-
14221369
void *cache_seq_start_rcu(struct seq_file *m, loff_t *pos)
14231370
__acquires(RCU)
14241371
{
@@ -1466,9 +1413,9 @@ static int c_show(struct seq_file *m, void *p)
14661413
}
14671414

14681415
static const struct seq_operations cache_content_op = {
1469-
.start = cache_seq_start,
1470-
.next = cache_seq_next,
1471-
.stop = cache_seq_stop,
1416+
.start = cache_seq_start_rcu,
1417+
.next = cache_seq_next_rcu,
1418+
.stop = cache_seq_stop_rcu,
14721419
.show = c_show,
14731420
};
14741421

0 commit comments

Comments
 (0)