aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/sunrpc/cache.h2
-rw-r--r--net/sunrpc/cache.c27
2 files changed, 21 insertions, 8 deletions
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
index 03496357f455..6950c981882d 100644
--- a/include/linux/sunrpc/cache.h
+++ b/include/linux/sunrpc/cache.h
@@ -197,7 +197,9 @@ extern void cache_purge(struct cache_detail *detail);
197#define NEVER (0x7FFFFFFF) 197#define NEVER (0x7FFFFFFF)
198extern void __init cache_initialize(void); 198extern void __init cache_initialize(void);
199extern int cache_register(struct cache_detail *cd); 199extern int cache_register(struct cache_detail *cd);
200extern int cache_register_net(struct cache_detail *cd, struct net *net);
200extern void cache_unregister(struct cache_detail *cd); 201extern void cache_unregister(struct cache_detail *cd);
202extern void cache_unregister_net(struct cache_detail *cd, struct net *net);
201 203
202extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *, 204extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *,
203 mode_t, struct cache_detail *); 205 mode_t, struct cache_detail *);
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,