aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShamir Rabinovitch <shamir.rabinovitch@oracle.com>2017-03-29 06:21:59 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-05-20 08:28:38 -0400
commitd20bfe223d3e63bb42aa581d779a1f8074b0c287 (patch)
tree5703136845119c249847aa027ecee7067d39aaa9
parent7a227630ab893f1aac6da6a540ebc2c6a7dce115 (diff)
IB/IPoIB: ibX: failed to create mcg debug file
commit 771a52584096c45e4565e8aabb596eece9d73d61 upstream. When udev renames the netdev devices, ipoib debugfs entries does not get renamed. As a result, if subsequent probe of ipoib device reuse the name then creating a debugfs entry for the new device would fail. Also, moved ipoib_create_debug_files and ipoib_delete_debug_files as part of ipoib event handling in order to avoid any race condition between these. Fixes: 1732b0ef3b3a ([IPoIB] add path record information in debugfs) Signed-off-by: Vijay Kumar <vijay.ac.kumar@oracle.com> Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com> Reviewed-by: Mark Bloch <markb@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_fs.c3
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c44
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_vlan.c3
3 files changed, 42 insertions, 8 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_fs.c b/drivers/infiniband/ulp/ipoib/ipoib_fs.c
index 6bd5740e2691..09396bd7b02d 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_fs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_fs.c
@@ -281,8 +281,11 @@ void ipoib_delete_debug_files(struct net_device *dev)
281{ 281{
282 struct ipoib_dev_priv *priv = netdev_priv(dev); 282 struct ipoib_dev_priv *priv = netdev_priv(dev);
283 283
284 WARN_ONCE(!priv->mcg_dentry, "null mcg debug file\n");
285 WARN_ONCE(!priv->path_dentry, "null path debug file\n");
284 debugfs_remove(priv->mcg_dentry); 286 debugfs_remove(priv->mcg_dentry);
285 debugfs_remove(priv->path_dentry); 287 debugfs_remove(priv->path_dentry);
288 priv->mcg_dentry = priv->path_dentry = NULL;
286} 289}
287 290
288int ipoib_register_debugfs(void) 291int ipoib_register_debugfs(void)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 3ef7b8f049c4..08c4b0287304 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -108,6 +108,33 @@ static struct ib_client ipoib_client = {
108 .get_net_dev_by_params = ipoib_get_net_dev_by_params, 108 .get_net_dev_by_params = ipoib_get_net_dev_by_params,
109}; 109};
110 110
111#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
112static int ipoib_netdev_event(struct notifier_block *this,
113 unsigned long event, void *ptr)
114{
115 struct netdev_notifier_info *ni = ptr;
116 struct net_device *dev = ni->dev;
117
118 if (dev->netdev_ops->ndo_open != ipoib_open)
119 return NOTIFY_DONE;
120
121 switch (event) {
122 case NETDEV_REGISTER:
123 ipoib_create_debug_files(dev);
124 break;
125 case NETDEV_CHANGENAME:
126 ipoib_delete_debug_files(dev);
127 ipoib_create_debug_files(dev);
128 break;
129 case NETDEV_UNREGISTER:
130 ipoib_delete_debug_files(dev);
131 break;
132 }
133
134 return NOTIFY_DONE;
135}
136#endif
137
111int ipoib_open(struct net_device *dev) 138int ipoib_open(struct net_device *dev)
112{ 139{
113 struct ipoib_dev_priv *priv = netdev_priv(dev); 140 struct ipoib_dev_priv *priv = netdev_priv(dev);
@@ -1655,8 +1682,6 @@ void ipoib_dev_cleanup(struct net_device *dev)
1655 1682
1656 ASSERT_RTNL(); 1683 ASSERT_RTNL();
1657 1684
1658 ipoib_delete_debug_files(dev);
1659
1660 /* Delete any child interfaces first */ 1685 /* Delete any child interfaces first */
1661 list_for_each_entry_safe(cpriv, tcpriv, &priv->child_intfs, list) { 1686 list_for_each_entry_safe(cpriv, tcpriv, &priv->child_intfs, list) {
1662 /* Stop GC on child */ 1687 /* Stop GC on child */
@@ -2074,8 +2099,6 @@ static struct net_device *ipoib_add_port(const char *format,
2074 goto register_failed; 2099 goto register_failed;
2075 } 2100 }
2076 2101
2077 ipoib_create_debug_files(priv->dev);
2078
2079 if (ipoib_cm_add_mode_attr(priv->dev)) 2102 if (ipoib_cm_add_mode_attr(priv->dev))
2080 goto sysfs_failed; 2103 goto sysfs_failed;
2081 if (ipoib_add_pkey_attr(priv->dev)) 2104 if (ipoib_add_pkey_attr(priv->dev))
@@ -2090,7 +2113,6 @@ static struct net_device *ipoib_add_port(const char *format,
2090 return priv->dev; 2113 return priv->dev;
2091 2114
2092sysfs_failed: 2115sysfs_failed:
2093 ipoib_delete_debug_files(priv->dev);
2094 unregister_netdev(priv->dev); 2116 unregister_netdev(priv->dev);
2095 2117
2096register_failed: 2118register_failed:
@@ -2175,6 +2197,12 @@ static void ipoib_remove_one(struct ib_device *device, void *client_data)
2175 kfree(dev_list); 2197 kfree(dev_list);
2176} 2198}
2177 2199
2200#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
2201static struct notifier_block ipoib_netdev_notifier = {
2202 .notifier_call = ipoib_netdev_event,
2203};
2204#endif
2205
2178static int __init ipoib_init_module(void) 2206static int __init ipoib_init_module(void)
2179{ 2207{
2180 int ret; 2208 int ret;
@@ -2227,6 +2255,9 @@ static int __init ipoib_init_module(void)
2227 if (ret) 2255 if (ret)
2228 goto err_client; 2256 goto err_client;
2229 2257
2258#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
2259 register_netdevice_notifier(&ipoib_netdev_notifier);
2260#endif
2230 return 0; 2261 return 0;
2231 2262
2232err_client: 2263err_client:
@@ -2244,6 +2275,9 @@ err_fs:
2244 2275
2245static void __exit ipoib_cleanup_module(void) 2276static void __exit ipoib_cleanup_module(void)
2246{ 2277{
2278#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
2279 unregister_netdevice_notifier(&ipoib_netdev_notifier);
2280#endif
2247 ipoib_netlink_fini(); 2281 ipoib_netlink_fini();
2248 ib_unregister_client(&ipoib_client); 2282 ib_unregister_client(&ipoib_client);
2249 ib_sa_unregister_client(&ipoib_sa_client); 2283 ib_sa_unregister_client(&ipoib_sa_client);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
index a2f9f29c6ab5..57eadd2b7a71 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
@@ -87,8 +87,6 @@ int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv,
87 goto register_failed; 87 goto register_failed;
88 } 88 }
89 89
90 ipoib_create_debug_files(priv->dev);
91
92 /* RTNL childs don't need proprietary sysfs entries */ 90 /* RTNL childs don't need proprietary sysfs entries */
93 if (type == IPOIB_LEGACY_CHILD) { 91 if (type == IPOIB_LEGACY_CHILD) {
94 if (ipoib_cm_add_mode_attr(priv->dev)) 92 if (ipoib_cm_add_mode_attr(priv->dev))
@@ -109,7 +107,6 @@ int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv,
109 107
110sysfs_failed: 108sysfs_failed:
111 result = -ENOMEM; 109 result = -ENOMEM;
112 ipoib_delete_debug_files(priv->dev);
113 unregister_netdevice(priv->dev); 110 unregister_netdevice(priv->dev);
114 111
115register_failed: 112register_failed: