Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Trond Myklebust and committed by
J. Bruce Fields
d48cf356 a6482733

+7 -66
+3 -3
Documentation/filesystems/nfs/rpc-cache.txt
··· 84 84 A message from user space has arrived to fill out a 85 85 cache entry. It is in 'buf' of length 'len'. 86 86 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 88 88 with sunrpc_cache_update. 89 89 90 90 ··· 95 95 Using a cache 96 96 ------------- 97 97 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 99 99 to the cache_head in a sample item with the 'key' fields filled in. 100 100 This will be passed to ->match to identify the target entry. If no 101 101 entry is found, a new entry will be create, added to the cache, and ··· 116 116 revisited (->revisit). It is expected that this method will 117 117 reschedule the request for processing. 118 118 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 120 120 sunrpc_cache_update to set the content for the item. A second item is 121 121 passed which should hold the content. If the item found by _lookup 122 122 has valid data, then it is discarded and a new item is created. This
-6
include/linux/sunrpc/cache.h
··· 171 171 sunrpc_cache_lookup_rcu(struct cache_detail *detail, 172 172 struct cache_head *key, int hash); 173 173 extern struct cache_head * 174 - sunrpc_cache_lookup(struct cache_detail *detail, 175 - struct cache_head *key, int hash); 176 - extern struct cache_head * 177 174 sunrpc_cache_update(struct cache_detail *detail, 178 175 struct cache_head *new, struct cache_head *old, int hash); 179 176 ··· 230 233 extern void sunrpc_cache_unhash(struct cache_detail *, struct cache_head *); 231 234 232 235 /* Must store cache_detail in seq_file->private if using next three functions */ 233 - extern void *cache_seq_start(struct seq_file *file, loff_t *pos); 234 - extern void *cache_seq_next(struct seq_file *file, void *p, loff_t *pos); 235 - extern void cache_seq_stop(struct seq_file *file, void *p); 236 236 extern void *cache_seq_start_rcu(struct seq_file *file, loff_t *pos); 237 237 extern void *cache_seq_next_rcu(struct seq_file *file, void *p, loff_t *pos); 238 238 extern void cache_seq_stop_rcu(struct seq_file *file, void *p);
+4 -57
net/sunrpc/cache.c
··· 75 75 return NULL; 76 76 } 77 77 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 - 99 78 static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail, 100 79 struct cache_head *key, 101 80 int hash) ··· 132 153 return sunrpc_cache_add_entry(detail, key, hash); 133 154 } 134 155 EXPORT_SYMBOL_GPL(sunrpc_cache_lookup_rcu); 135 - 136 - struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail, 137 - struct cache_head *key, int hash) 138 - { 139 - struct cache_head *ret; 140 - 141 - ret = sunrpc_cache_find(detail, key, hash); 142 - if (ret) 143 - return ret; 144 - /* Didn't find anything, insert an empty entry */ 145 - return sunrpc_cache_add_entry(detail, key, hash); 146 - } 147 - EXPORT_SYMBOL_GPL(sunrpc_cache_lookup); 148 - 149 156 150 157 static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch); 151 158 ··· 1334 1369 struct cache_head, cache_list); 1335 1370 } 1336 1371 1337 - void *cache_seq_start(struct seq_file *m, loff_t *pos) 1338 - __acquires(cd->hash_lock) 1339 - { 1340 - struct cache_detail *cd = m->private; 1341 - 1342 - read_lock(&cd->hash_lock); 1343 - return __cache_seq_start(m, pos); 1344 - } 1345 - EXPORT_SYMBOL_GPL(cache_seq_start); 1346 - 1347 - void *cache_seq_next(struct seq_file *m, void *p, loff_t *pos) 1372 + static void *cache_seq_next(struct seq_file *m, void *p, loff_t *pos) 1348 1373 { 1349 1374 struct cache_head *ch = p; 1350 1375 int hash = (*pos >> 32); ··· 1365 1410 struct cache_head, cache_list); 1366 1411 } 1367 1412 EXPORT_SYMBOL_GPL(cache_seq_next); 1368 - 1369 - void cache_seq_stop(struct seq_file *m, void *p) 1370 - __releases(cd->hash_lock) 1371 - { 1372 - struct cache_detail *cd = m->private; 1373 - read_unlock(&cd->hash_lock); 1374 - } 1375 - EXPORT_SYMBOL_GPL(cache_seq_stop); 1376 1413 1377 1414 void *cache_seq_start_rcu(struct seq_file *m, loff_t *pos) 1378 1415 __acquires(RCU) ··· 1413 1466 } 1414 1467 1415 1468 static const struct seq_operations cache_content_op = { 1416 - .start = cache_seq_start, 1417 - .next = cache_seq_next, 1418 - .stop = cache_seq_stop, 1469 + .start = cache_seq_start_rcu, 1470 + .next = cache_seq_next_rcu, 1471 + .stop = cache_seq_stop_rcu, 1419 1472 .show = c_show, 1420 1473 }; 1421 1474