diff options
Diffstat (limited to 'net/sunrpc/cache.c')
-rw-r--r-- | net/sunrpc/cache.c | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 465df9ae1046..f21ece088764 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c | |||
@@ -344,7 +344,7 @@ static int current_index; | |||
344 | static void do_cache_clean(struct work_struct *work); | 344 | static void do_cache_clean(struct work_struct *work); |
345 | static struct delayed_work cache_cleaner; | 345 | static struct delayed_work cache_cleaner; |
346 | 346 | ||
347 | static void sunrpc_init_cache_detail(struct cache_detail *cd) | 347 | void 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 | } |
363 | EXPORT_SYMBOL_GPL(sunrpc_init_cache_detail); | ||
363 | 364 | ||
364 | static void sunrpc_destroy_cache_detail(struct cache_detail *cd) | 365 | void 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) | |||
384 | out: | 385 | out: |
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 | } |
388 | EXPORT_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. |
@@ -1643,12 +1645,6 @@ int cache_register_net(struct cache_detail *cd, struct net *net) | |||
1643 | } | 1645 | } |
1644 | EXPORT_SYMBOL_GPL(cache_register_net); | 1646 | EXPORT_SYMBOL_GPL(cache_register_net); |
1645 | 1647 | ||
1646 | int cache_register(struct cache_detail *cd) | ||
1647 | { | ||
1648 | return cache_register_net(cd, &init_net); | ||
1649 | } | ||
1650 | EXPORT_SYMBOL_GPL(cache_register); | ||
1651 | |||
1652 | void cache_unregister_net(struct cache_detail *cd, struct net *net) | 1648 | void cache_unregister_net(struct cache_detail *cd, struct net *net) |
1653 | { | 1649 | { |
1654 | remove_cache_proc_entries(cd, net); | 1650 | remove_cache_proc_entries(cd, net); |
@@ -1656,11 +1652,31 @@ void cache_unregister_net(struct cache_detail *cd, struct net *net) | |||
1656 | } | 1652 | } |
1657 | EXPORT_SYMBOL_GPL(cache_unregister_net); | 1653 | EXPORT_SYMBOL_GPL(cache_unregister_net); |
1658 | 1654 | ||
1659 | void cache_unregister(struct cache_detail *cd) | 1655 | struct cache_detail *cache_create_net(struct cache_detail *tmpl, struct net *net) |
1656 | { | ||
1657 | struct cache_detail *cd; | ||
1658 | |||
1659 | cd = kmemdup(tmpl, sizeof(struct cache_detail), GFP_KERNEL); | ||
1660 | if (cd == NULL) | ||
1661 | return ERR_PTR(-ENOMEM); | ||
1662 | |||
1663 | cd->hash_table = kzalloc(cd->hash_size * sizeof(struct cache_head *), | ||
1664 | GFP_KERNEL); | ||
1665 | if (cd->hash_table == NULL) { | ||
1666 | kfree(cd); | ||
1667 | return ERR_PTR(-ENOMEM); | ||
1668 | } | ||
1669 | cd->net = net; | ||
1670 | return cd; | ||
1671 | } | ||
1672 | EXPORT_SYMBOL_GPL(cache_create_net); | ||
1673 | |||
1674 | void cache_destroy_net(struct cache_detail *cd, struct net *net) | ||
1660 | { | 1675 | { |
1661 | cache_unregister_net(cd, &init_net); | 1676 | kfree(cd->hash_table); |
1677 | kfree(cd); | ||
1662 | } | 1678 | } |
1663 | EXPORT_SYMBOL_GPL(cache_unregister); | 1679 | EXPORT_SYMBOL_GPL(cache_destroy_net); |
1664 | 1680 | ||
1665 | static ssize_t cache_read_pipefs(struct file *filp, char __user *buf, | 1681 | static ssize_t cache_read_pipefs(struct file *filp, char __user *buf, |
1666 | size_t count, loff_t *ppos) | 1682 | size_t count, loff_t *ppos) |
@@ -1787,17 +1803,14 @@ int sunrpc_cache_register_pipefs(struct dentry *parent, | |||
1787 | struct dentry *dir; | 1803 | struct dentry *dir; |
1788 | int ret = 0; | 1804 | int ret = 0; |
1789 | 1805 | ||
1790 | sunrpc_init_cache_detail(cd); | ||
1791 | q.name = name; | 1806 | q.name = name; |
1792 | q.len = strlen(name); | 1807 | q.len = strlen(name); |
1793 | q.hash = full_name_hash(q.name, q.len); | 1808 | q.hash = full_name_hash(q.name, q.len); |
1794 | dir = rpc_create_cache_dir(parent, &q, umode, cd); | 1809 | dir = rpc_create_cache_dir(parent, &q, umode, cd); |
1795 | if (!IS_ERR(dir)) | 1810 | if (!IS_ERR(dir)) |
1796 | cd->u.pipefs.dir = dir; | 1811 | cd->u.pipefs.dir = dir; |
1797 | else { | 1812 | else |
1798 | sunrpc_destroy_cache_detail(cd); | ||
1799 | ret = PTR_ERR(dir); | 1813 | ret = PTR_ERR(dir); |
1800 | } | ||
1801 | return ret; | 1814 | return ret; |
1802 | } | 1815 | } |
1803 | EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs); | 1816 | EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs); |
@@ -1806,7 +1819,6 @@ void sunrpc_cache_unregister_pipefs(struct cache_detail *cd) | |||
1806 | { | 1819 | { |
1807 | rpc_remove_cache_dir(cd->u.pipefs.dir); | 1820 | rpc_remove_cache_dir(cd->u.pipefs.dir); |
1808 | cd->u.pipefs.dir = NULL; | 1821 | cd->u.pipefs.dir = NULL; |
1809 | sunrpc_destroy_cache_detail(cd); | ||
1810 | } | 1822 | } |
1811 | EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs); | 1823 | EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs); |
1812 | 1824 | ||