diff options
author | Kinglong Mee <kinglongmee@gmail.com> | 2017-02-07 08:47:16 -0500 |
---|---|---|
committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2017-02-08 17:02:45 -0500 |
commit | 863d7d9c2e0cbbde6cd15f87c4431dd806f2d917 (patch) | |
tree | c99169539a6a1c92201ebd0bec23c9d6cee2e270 | |
parent | 2864486bd0fdd14431058650c91fcb9fba605d43 (diff) |
sunrpc/nfs: cleanup procfs/pipefs entry in cache_detail
Record flush/channel/content entries is useless, remove them.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
-rw-r--r-- | fs/nfs/cache_lib.c | 3 | ||||
-rw-r--r-- | include/linux/sunrpc/cache.h | 15 | ||||
-rw-r--r-- | net/sunrpc/cache.c | 49 |
3 files changed, 21 insertions, 46 deletions
diff --git a/fs/nfs/cache_lib.c b/fs/nfs/cache_lib.c index 6de15709d024..2ae676f93e6b 100644 --- a/fs/nfs/cache_lib.c +++ b/fs/nfs/cache_lib.c | |||
@@ -141,8 +141,7 @@ int nfs_cache_register_net(struct net *net, struct cache_detail *cd) | |||
141 | 141 | ||
142 | void nfs_cache_unregister_sb(struct super_block *sb, struct cache_detail *cd) | 142 | void nfs_cache_unregister_sb(struct super_block *sb, struct cache_detail *cd) |
143 | { | 143 | { |
144 | if (cd->u.pipefs.dir) | 144 | sunrpc_cache_unregister_pipefs(cd); |
145 | sunrpc_cache_unregister_pipefs(cd); | ||
146 | } | 145 | } |
147 | 146 | ||
148 | void nfs_cache_unregister_net(struct net *net, struct cache_detail *cd) | 147 | void nfs_cache_unregister_net(struct net *net, struct cache_detail *cd) |
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 62a60eeacb0a..bb5c9c80f12e 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h | |||
@@ -63,15 +63,6 @@ struct cache_head { | |||
63 | 63 | ||
64 | #define CACHE_NEW_EXPIRY 120 /* keep new things pending confirmation for 120 seconds */ | 64 | #define CACHE_NEW_EXPIRY 120 /* keep new things pending confirmation for 120 seconds */ |
65 | 65 | ||
66 | struct cache_detail_procfs { | ||
67 | struct proc_dir_entry *proc_ent; | ||
68 | struct proc_dir_entry *flush_ent, *channel_ent, *content_ent; | ||
69 | }; | ||
70 | |||
71 | struct cache_detail_pipefs { | ||
72 | struct dentry *dir; | ||
73 | }; | ||
74 | |||
75 | struct cache_detail { | 66 | struct cache_detail { |
76 | struct module * owner; | 67 | struct module * owner; |
77 | int hash_size; | 68 | int hash_size; |
@@ -123,9 +114,9 @@ struct cache_detail { | |||
123 | time_t last_warn; /* when we last warned about no readers */ | 114 | time_t last_warn; /* when we last warned about no readers */ |
124 | 115 | ||
125 | union { | 116 | union { |
126 | struct cache_detail_procfs procfs; | 117 | struct proc_dir_entry *procfs; |
127 | struct cache_detail_pipefs pipefs; | 118 | struct dentry *pipefs; |
128 | } u; | 119 | }; |
129 | struct net *net; | 120 | struct net *net; |
130 | }; | 121 | }; |
131 | 122 | ||
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 8147e8d56eb2..688ef8cbac62 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c | |||
@@ -1600,21 +1600,12 @@ static const struct file_operations cache_flush_operations_procfs = { | |||
1600 | .llseek = no_llseek, | 1600 | .llseek = no_llseek, |
1601 | }; | 1601 | }; |
1602 | 1602 | ||
1603 | static void remove_cache_proc_entries(struct cache_detail *cd, struct net *net) | 1603 | static void remove_cache_proc_entries(struct cache_detail *cd) |
1604 | { | 1604 | { |
1605 | struct sunrpc_net *sn; | 1605 | if (cd->procfs) { |
1606 | 1606 | proc_remove(cd->procfs); | |
1607 | if (cd->u.procfs.proc_ent == NULL) | 1607 | cd->procfs = NULL; |
1608 | return; | 1608 | } |
1609 | if (cd->u.procfs.flush_ent) | ||
1610 | remove_proc_entry("flush", cd->u.procfs.proc_ent); | ||
1611 | if (cd->u.procfs.channel_ent) | ||
1612 | remove_proc_entry("channel", cd->u.procfs.proc_ent); | ||
1613 | if (cd->u.procfs.content_ent) | ||
1614 | remove_proc_entry("content", cd->u.procfs.proc_ent); | ||
1615 | cd->u.procfs.proc_ent = NULL; | ||
1616 | sn = net_generic(net, sunrpc_net_id); | ||
1617 | remove_proc_entry(cd->name, sn->proc_net_rpc); | ||
1618 | } | 1609 | } |
1619 | 1610 | ||
1620 | #ifdef CONFIG_PROC_FS | 1611 | #ifdef CONFIG_PROC_FS |
@@ -1624,38 +1615,30 @@ static int create_cache_proc_entries(struct cache_detail *cd, struct net *net) | |||
1624 | struct sunrpc_net *sn; | 1615 | struct sunrpc_net *sn; |
1625 | 1616 | ||
1626 | sn = net_generic(net, sunrpc_net_id); | 1617 | sn = net_generic(net, sunrpc_net_id); |
1627 | cd->u.procfs.proc_ent = proc_mkdir(cd->name, sn->proc_net_rpc); | 1618 | cd->procfs = proc_mkdir(cd->name, sn->proc_net_rpc); |
1628 | if (cd->u.procfs.proc_ent == NULL) | 1619 | if (cd->procfs == NULL) |
1629 | goto out_nomem; | 1620 | goto out_nomem; |
1630 | cd->u.procfs.channel_ent = NULL; | ||
1631 | cd->u.procfs.content_ent = NULL; | ||
1632 | 1621 | ||
1633 | p = proc_create_data("flush", S_IFREG|S_IRUSR|S_IWUSR, | 1622 | p = proc_create_data("flush", S_IFREG|S_IRUSR|S_IWUSR, |
1634 | cd->u.procfs.proc_ent, | 1623 | cd->procfs, &cache_flush_operations_procfs, cd); |
1635 | &cache_flush_operations_procfs, cd); | ||
1636 | cd->u.procfs.flush_ent = p; | ||
1637 | if (p == NULL) | 1624 | if (p == NULL) |
1638 | goto out_nomem; | 1625 | goto out_nomem; |
1639 | 1626 | ||
1640 | if (cd->cache_request || cd->cache_parse) { | 1627 | if (cd->cache_request || cd->cache_parse) { |
1641 | p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR, | 1628 | p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR, |
1642 | cd->u.procfs.proc_ent, | 1629 | cd->procfs, &cache_file_operations_procfs, cd); |
1643 | &cache_file_operations_procfs, cd); | ||
1644 | cd->u.procfs.channel_ent = p; | ||
1645 | if (p == NULL) | 1630 | if (p == NULL) |
1646 | goto out_nomem; | 1631 | goto out_nomem; |
1647 | } | 1632 | } |
1648 | if (cd->cache_show) { | 1633 | if (cd->cache_show) { |
1649 | p = proc_create_data("content", S_IFREG|S_IRUSR, | 1634 | p = proc_create_data("content", S_IFREG|S_IRUSR, |
1650 | cd->u.procfs.proc_ent, | 1635 | cd->procfs, &content_file_operations_procfs, cd); |
1651 | &content_file_operations_procfs, cd); | ||
1652 | cd->u.procfs.content_ent = p; | ||
1653 | if (p == NULL) | 1636 | if (p == NULL) |
1654 | goto out_nomem; | 1637 | goto out_nomem; |
1655 | } | 1638 | } |
1656 | return 0; | 1639 | return 0; |
1657 | out_nomem: | 1640 | out_nomem: |
1658 | remove_cache_proc_entries(cd, net); | 1641 | remove_cache_proc_entries(cd); |
1659 | return -ENOMEM; | 1642 | return -ENOMEM; |
1660 | } | 1643 | } |
1661 | #else /* CONFIG_PROC_FS */ | 1644 | #else /* CONFIG_PROC_FS */ |
@@ -1684,7 +1667,7 @@ EXPORT_SYMBOL_GPL(cache_register_net); | |||
1684 | 1667 | ||
1685 | void cache_unregister_net(struct cache_detail *cd, struct net *net) | 1668 | void cache_unregister_net(struct cache_detail *cd, struct net *net) |
1686 | { | 1669 | { |
1687 | remove_cache_proc_entries(cd, net); | 1670 | remove_cache_proc_entries(cd); |
1688 | sunrpc_destroy_cache_detail(cd); | 1671 | sunrpc_destroy_cache_detail(cd); |
1689 | } | 1672 | } |
1690 | EXPORT_SYMBOL_GPL(cache_unregister_net); | 1673 | EXPORT_SYMBOL_GPL(cache_unregister_net); |
@@ -1843,15 +1826,17 @@ int sunrpc_cache_register_pipefs(struct dentry *parent, | |||
1843 | struct dentry *dir = rpc_create_cache_dir(parent, name, umode, cd); | 1826 | struct dentry *dir = rpc_create_cache_dir(parent, name, umode, cd); |
1844 | if (IS_ERR(dir)) | 1827 | if (IS_ERR(dir)) |
1845 | return PTR_ERR(dir); | 1828 | return PTR_ERR(dir); |
1846 | cd->u.pipefs.dir = dir; | 1829 | cd->pipefs = dir; |
1847 | return 0; | 1830 | return 0; |
1848 | } | 1831 | } |
1849 | EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs); | 1832 | EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs); |
1850 | 1833 | ||
1851 | void sunrpc_cache_unregister_pipefs(struct cache_detail *cd) | 1834 | void sunrpc_cache_unregister_pipefs(struct cache_detail *cd) |
1852 | { | 1835 | { |
1853 | rpc_remove_cache_dir(cd->u.pipefs.dir); | 1836 | if (cd->pipefs) { |
1854 | cd->u.pipefs.dir = NULL; | 1837 | rpc_remove_cache_dir(cd->pipefs); |
1838 | cd->pipefs = NULL; | ||
1839 | } | ||
1855 | } | 1840 | } |
1856 | EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs); | 1841 | EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs); |
1857 | 1842 | ||