aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@parallels.com>2010-09-27 06:00:15 -0400
committerJ. Bruce Fields <bfields@redhat.com>2010-09-27 10:16:11 -0400
commit593ce16b943ea37d4ec62c377b32d7f3f4085e84 (patch)
treed8e161541e89f69e0de4416d76655cf11d9ecaa8 /net
parent352114f395bd79353faf0bc1506ead94de393f55 (diff)
sunrpc: Add routines that allow registering per-net caches
Existing calls do the same, but for the init_net. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/cache.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index ff733dfef3b8..e84e7ddeecd4 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -34,6 +34,7 @@
34#include <linux/sunrpc/cache.h> 34#include <linux/sunrpc/cache.h>
35#include <linux/sunrpc/stats.h> 35#include <linux/sunrpc/stats.h>
36#include <linux/sunrpc/rpc_pipe_fs.h> 36#include <linux/sunrpc/rpc_pipe_fs.h>
37#include <net/net_namespace.h>
37 38
38#define RPCDBG_FACILITY RPCDBG_CACHE 39#define RPCDBG_FACILITY RPCDBG_CACHE
39 40
@@ -1537,7 +1538,7 @@ static const struct file_operations cache_flush_operations_procfs = {
1537 .release = release_flush_procfs, 1538 .release = release_flush_procfs,
1538}; 1539};
1539 1540
1540static void remove_cache_proc_entries(struct cache_detail *cd) 1541static void remove_cache_proc_entries(struct cache_detail *cd, struct net *net)
1541{ 1542{
1542 if (cd->u.procfs.proc_ent == NULL) 1543 if (cd->u.procfs.proc_ent == NULL)
1543 return; 1544 return;
@@ -1552,7 +1553,7 @@ static void remove_cache_proc_entries(struct cache_detail *cd)
1552} 1553}
1553 1554
1554#ifdef CONFIG_PROC_FS 1555#ifdef CONFIG_PROC_FS
1555static int create_cache_proc_entries(struct cache_detail *cd) 1556static int create_cache_proc_entries(struct cache_detail *cd, struct net *net)
1556{ 1557{
1557 struct proc_dir_entry *p; 1558 struct proc_dir_entry *p;
1558 1559
@@ -1587,11 +1588,11 @@ static int create_cache_proc_entries(struct cache_detail *cd)
1587 } 1588 }
1588 return 0; 1589 return 0;
1589out_nomem: 1590out_nomem:
1590 remove_cache_proc_entries(cd); 1591 remove_cache_proc_entries(cd, net);
1591 return -ENOMEM; 1592 return -ENOMEM;
1592} 1593}
1593#else /* CONFIG_PROC_FS */ 1594#else /* CONFIG_PROC_FS */
1594static int create_cache_proc_entries(struct cache_detail *cd) 1595static int create_cache_proc_entries(struct cache_detail *cd, struct net *net)
1595{ 1596{
1596 return 0; 1597 return 0;
1597} 1598}
@@ -1602,23 +1603,33 @@ void __init cache_initialize(void)
1602 INIT_DELAYED_WORK_DEFERRABLE(&cache_cleaner, do_cache_clean); 1603 INIT_DELAYED_WORK_DEFERRABLE(&cache_cleaner, do_cache_clean);
1603} 1604}
1604 1605
1605int cache_register(struct cache_detail *cd) 1606int cache_register_net(struct cache_detail *cd, struct net *net)
1606{ 1607{
1607 int ret; 1608 int ret;
1608 1609
1609 sunrpc_init_cache_detail(cd); 1610 sunrpc_init_cache_detail(cd);
1610 ret = create_cache_proc_entries(cd); 1611 ret = create_cache_proc_entries(cd, net);
1611 if (ret) 1612 if (ret)
1612 sunrpc_destroy_cache_detail(cd); 1613 sunrpc_destroy_cache_detail(cd);
1613 return ret; 1614 return ret;
1614} 1615}
1616
1617int cache_register(struct cache_detail *cd)
1618{
1619 return cache_register_net(cd, &init_net);
1620}
1615EXPORT_SYMBOL_GPL(cache_register); 1621EXPORT_SYMBOL_GPL(cache_register);
1616 1622
1617void cache_unregister(struct cache_detail *cd) 1623void cache_unregister_net(struct cache_detail *cd, struct net *net)
1618{ 1624{
1619 remove_cache_proc_entries(cd); 1625 remove_cache_proc_entries(cd, net);
1620 sunrpc_destroy_cache_detail(cd); 1626 sunrpc_destroy_cache_detail(cd);
1621} 1627}
1628
1629void cache_unregister(struct cache_detail *cd)
1630{
1631 cache_unregister_net(cd, &init_net);
1632}
1622EXPORT_SYMBOL_GPL(cache_unregister); 1633EXPORT_SYMBOL_GPL(cache_unregister);
1623 1634
1624static ssize_t cache_read_pipefs(struct file *filp, char __user *buf, 1635static ssize_t cache_read_pipefs(struct file *filp, char __user *buf,