aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sunrpc/cache.c')
-rw-r--r--net/sunrpc/cache.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 8c6598e0334a..de0b0f39d9d8 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -344,7 +344,7 @@ static int current_index;
344static void do_cache_clean(struct work_struct *work); 344static void do_cache_clean(struct work_struct *work);
345static struct delayed_work cache_cleaner; 345static struct delayed_work cache_cleaner;
346 346
347static void sunrpc_init_cache_detail(struct cache_detail *cd) 347void sunrpc_init_cache_detail(struct cache_detail *cd)
348{ 348{
349 rwlock_init(&cd->hash_lock); 349 rwlock_init(&cd->hash_lock);
350 INIT_LIST_HEAD(&cd->queue); 350 INIT_LIST_HEAD(&cd->queue);
@@ -360,8 +360,9 @@ static void sunrpc_init_cache_detail(struct cache_detail *cd)
360 /* start the cleaning process */ 360 /* start the cleaning process */
361 schedule_delayed_work(&cache_cleaner, 0); 361 schedule_delayed_work(&cache_cleaner, 0);
362} 362}
363EXPORT_SYMBOL_GPL(sunrpc_init_cache_detail);
363 364
364static void sunrpc_destroy_cache_detail(struct cache_detail *cd) 365void sunrpc_destroy_cache_detail(struct cache_detail *cd)
365{ 366{
366 cache_purge(cd); 367 cache_purge(cd);
367 spin_lock(&cache_list_lock); 368 spin_lock(&cache_list_lock);
@@ -384,6 +385,7 @@ static void sunrpc_destroy_cache_detail(struct cache_detail *cd)
384out: 385out:
385 printk(KERN_ERR "nfsd: failed to unregister %s cache\n", cd->name); 386 printk(KERN_ERR "nfsd: failed to unregister %s cache\n", cd->name);
386} 387}
388EXPORT_SYMBOL_GPL(sunrpc_destroy_cache_detail);
387 389
388/* clean cache tries to find something to clean 390/* clean cache tries to find something to clean
389 * and cleans it. 391 * and cleans it.
@@ -1645,12 +1647,6 @@ int cache_register_net(struct cache_detail *cd, struct net *net)
1645} 1647}
1646EXPORT_SYMBOL_GPL(cache_register_net); 1648EXPORT_SYMBOL_GPL(cache_register_net);
1647 1649
1648int cache_register(struct cache_detail *cd)
1649{
1650 return cache_register_net(cd, &init_net);
1651}
1652EXPORT_SYMBOL_GPL(cache_register);
1653
1654void cache_unregister_net(struct cache_detail *cd, struct net *net) 1650void cache_unregister_net(struct cache_detail *cd, struct net *net)
1655{ 1651{
1656 remove_cache_proc_entries(cd, net); 1652 remove_cache_proc_entries(cd, net);
@@ -1658,11 +1654,31 @@ void cache_unregister_net(struct cache_detail *cd, struct net *net)
1658} 1654}
1659EXPORT_SYMBOL_GPL(cache_unregister_net); 1655EXPORT_SYMBOL_GPL(cache_unregister_net);
1660 1656
1661void cache_unregister(struct cache_detail *cd) 1657struct cache_detail *cache_create_net(struct cache_detail *tmpl, struct net *net)
1658{
1659 struct cache_detail *cd;
1660
1661 cd = kmemdup(tmpl, sizeof(struct cache_detail), GFP_KERNEL);
1662 if (cd == NULL)
1663 return ERR_PTR(-ENOMEM);
1664
1665 cd->hash_table = kzalloc(cd->hash_size * sizeof(struct cache_head *),
1666 GFP_KERNEL);
1667 if (cd->hash_table == NULL) {
1668 kfree(cd);
1669 return ERR_PTR(-ENOMEM);
1670 }
1671 cd->net = net;
1672 return cd;
1673}
1674EXPORT_SYMBOL_GPL(cache_create_net);
1675
1676void cache_destroy_net(struct cache_detail *cd, struct net *net)
1662{ 1677{
1663 cache_unregister_net(cd, &init_net); 1678 kfree(cd->hash_table);
1679 kfree(cd);
1664} 1680}
1665EXPORT_SYMBOL_GPL(cache_unregister); 1681EXPORT_SYMBOL_GPL(cache_destroy_net);
1666 1682
1667static ssize_t cache_read_pipefs(struct file *filp, char __user *buf, 1683static ssize_t cache_read_pipefs(struct file *filp, char __user *buf,
1668 size_t count, loff_t *ppos) 1684 size_t count, loff_t *ppos)
@@ -1789,17 +1805,14 @@ int sunrpc_cache_register_pipefs(struct dentry *parent,
1789 struct dentry *dir; 1805 struct dentry *dir;
1790 int ret = 0; 1806 int ret = 0;
1791 1807
1792 sunrpc_init_cache_detail(cd);
1793 q.name = name; 1808 q.name = name;
1794 q.len = strlen(name); 1809 q.len = strlen(name);
1795 q.hash = full_name_hash(q.name, q.len); 1810 q.hash = full_name_hash(q.name, q.len);
1796 dir = rpc_create_cache_dir(parent, &q, umode, cd); 1811 dir = rpc_create_cache_dir(parent, &q, umode, cd);
1797 if (!IS_ERR(dir)) 1812 if (!IS_ERR(dir))
1798 cd->u.pipefs.dir = dir; 1813 cd->u.pipefs.dir = dir;
1799 else { 1814 else
1800 sunrpc_destroy_cache_detail(cd);
1801 ret = PTR_ERR(dir); 1815 ret = PTR_ERR(dir);
1802 }
1803 return ret; 1816 return ret;
1804} 1817}
1805EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs); 1818EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs);
@@ -1808,7 +1821,6 @@ void sunrpc_cache_unregister_pipefs(struct cache_detail *cd)
1808{ 1821{
1809 rpc_remove_cache_dir(cd->u.pipefs.dir); 1822 rpc_remove_cache_dir(cd->u.pipefs.dir);
1810 cd->u.pipefs.dir = NULL; 1823 cd->u.pipefs.dir = NULL;
1811 sunrpc_destroy_cache_detail(cd);
1812} 1824}
1813EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs); 1825EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs);
1814 1826