diff options
-rw-r--r-- | include/linux/sunrpc/cache.h | 4 | ||||
-rw-r--r-- | net/sunrpc/cache.c | 26 |
2 files changed, 30 insertions, 0 deletions
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 590a8ab0cec3..259381ca811b 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h | |||
@@ -117,6 +117,7 @@ struct cache_detail { | |||
117 | struct cache_detail_procfs procfs; | 117 | struct cache_detail_procfs procfs; |
118 | struct cache_detail_pipefs pipefs; | 118 | struct cache_detail_pipefs pipefs; |
119 | } u; | 119 | } u; |
120 | struct net *net; | ||
120 | }; | 121 | }; |
121 | 122 | ||
122 | 123 | ||
@@ -202,6 +203,9 @@ extern int cache_register_net(struct cache_detail *cd, struct net *net); | |||
202 | extern void cache_unregister(struct cache_detail *cd); | 203 | extern void cache_unregister(struct cache_detail *cd); |
203 | extern void cache_unregister_net(struct cache_detail *cd, struct net *net); | 204 | extern void cache_unregister_net(struct cache_detail *cd, struct net *net); |
204 | 205 | ||
206 | extern struct cache_detail *cache_create_net(struct cache_detail *tmpl, struct net *net); | ||
207 | extern void cache_destroy_net(struct cache_detail *cd, struct net *net); | ||
208 | |||
205 | extern void sunrpc_init_cache_detail(struct cache_detail *cd); | 209 | extern void sunrpc_init_cache_detail(struct cache_detail *cd); |
206 | extern void sunrpc_destroy_cache_detail(struct cache_detail *cd); | 210 | extern void sunrpc_destroy_cache_detail(struct cache_detail *cd); |
207 | extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *, | 211 | extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *, |
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index fefe06729f9d..a450b8ac648b 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c | |||
@@ -1664,6 +1664,32 @@ void cache_unregister(struct cache_detail *cd) | |||
1664 | } | 1664 | } |
1665 | EXPORT_SYMBOL_GPL(cache_unregister); | 1665 | EXPORT_SYMBOL_GPL(cache_unregister); |
1666 | 1666 | ||
1667 | struct cache_detail *cache_create_net(struct cache_detail *tmpl, struct net *net) | ||
1668 | { | ||
1669 | struct cache_detail *cd; | ||
1670 | |||
1671 | cd = kmemdup(tmpl, sizeof(struct cache_detail), GFP_KERNEL); | ||
1672 | if (cd == NULL) | ||
1673 | return ERR_PTR(-ENOMEM); | ||
1674 | |||
1675 | cd->hash_table = kzalloc(cd->hash_size * sizeof(struct cache_head *), | ||
1676 | GFP_KERNEL); | ||
1677 | if (cd->hash_table == NULL) { | ||
1678 | kfree(cd); | ||
1679 | return ERR_PTR(-ENOMEM); | ||
1680 | } | ||
1681 | cd->net = net; | ||
1682 | return cd; | ||
1683 | } | ||
1684 | EXPORT_SYMBOL_GPL(cache_create_net); | ||
1685 | |||
1686 | void cache_destroy_net(struct cache_detail *cd, struct net *net) | ||
1687 | { | ||
1688 | kfree(cd->hash_table); | ||
1689 | kfree(cd); | ||
1690 | } | ||
1691 | EXPORT_SYMBOL_GPL(cache_destroy_net); | ||
1692 | |||
1667 | static ssize_t cache_read_pipefs(struct file *filp, char __user *buf, | 1693 | static ssize_t cache_read_pipefs(struct file *filp, char __user *buf, |
1668 | size_t count, loff_t *ppos) | 1694 | size_t count, loff_t *ppos) |
1669 | { | 1695 | { |