mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
SUNRPC: Allow cache lookups to use RCU protection rather than the r/w spinlock
Instead of the reader/writer spinlock, allow cache lookups to use RCU for looking up entries. This is more efficient since modifications can occur while other entries are being looked up. Note that for now, we keep the reader/writer spinlock until all users have been converted to use RCU-safe freeing of their cache entries. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
parent
b92a8fabab
commit
ae74136b4b
2 changed files with 91 additions and 14 deletions
|
@ -167,6 +167,9 @@ extern const struct file_operations cache_file_operations_pipefs;
|
|||
extern const struct file_operations content_file_operations_pipefs;
|
||||
extern const struct file_operations cache_flush_operations_pipefs;
|
||||
|
||||
extern struct cache_head *
|
||||
sunrpc_cache_lookup_rcu(struct cache_detail *detail,
|
||||
struct cache_head *key, int hash);
|
||||
extern struct cache_head *
|
||||
sunrpc_cache_lookup(struct cache_detail *detail,
|
||||
struct cache_head *key, int hash);
|
||||
|
@ -186,6 +189,12 @@ static inline struct cache_head *cache_get(struct cache_head *h)
|
|||
return h;
|
||||
}
|
||||
|
||||
static inline struct cache_head *cache_get_rcu(struct cache_head *h)
|
||||
{
|
||||
if (kref_get_unless_zero(&h->ref))
|
||||
return h;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void cache_put(struct cache_head *h, struct cache_detail *cd)
|
||||
{
|
||||
|
@ -227,6 +236,9 @@ extern void sunrpc_cache_unhash(struct cache_detail *, struct cache_head *);
|
|||
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_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 qword_add(char **bpp, int *lp, char *str);
|
||||
extern void qword_addhex(char **bpp, int *lp, char *buf, int blen);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue