Skip to content

Commit 1360f43

Browse files
srabinovgregkh
authored andcommitted
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: 1732b0e ([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>
1 parent 1549c88 commit 1360f43

3 files changed

Lines changed: 42 additions & 8 deletions

File tree

drivers/infiniband/ulp/ipoib/ipoib_fs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,11 @@ void ipoib_delete_debug_files(struct net_device *dev)
281281
{
282282
struct ipoib_dev_priv *priv = netdev_priv(dev);
283283

284+
WARN_ONCE(!priv->mcg_dentry, "null mcg debug file\n");
285+
WARN_ONCE(!priv->path_dentry, "null path debug file\n");
284286
debugfs_remove(priv->mcg_dentry);
285287
debugfs_remove(priv->path_dentry);
288+
priv->mcg_dentry = priv->path_dentry = NULL;
286289
}
287290

288291
int ipoib_register_debugfs(void)

drivers/infiniband/ulp/ipoib/ipoib_main.c

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,33 @@ static struct ib_client ipoib_client = {
106106
.get_net_dev_by_params = ipoib_get_net_dev_by_params,
107107
};
108108

109+
#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
110+
static int ipoib_netdev_event(struct notifier_block *this,
111+
unsigned long event, void *ptr)
112+
{
113+
struct netdev_notifier_info *ni = ptr;
114+
struct net_device *dev = ni->dev;
115+
116+
if (dev->netdev_ops->ndo_open != ipoib_open)
117+
return NOTIFY_DONE;
118+
119+
switch (event) {
120+
case NETDEV_REGISTER:
121+
ipoib_create_debug_files(dev);
122+
break;
123+
case NETDEV_CHANGENAME:
124+
ipoib_delete_debug_files(dev);
125+
ipoib_create_debug_files(dev);
126+
break;
127+
case NETDEV_UNREGISTER:
128+
ipoib_delete_debug_files(dev);
129+
break;
130+
}
131+
132+
return NOTIFY_DONE;
133+
}
134+
#endif
135+
109136
int ipoib_open(struct net_device *dev)
110137
{
111138
struct ipoib_dev_priv *priv = netdev_priv(dev);
@@ -1595,8 +1622,6 @@ void ipoib_dev_cleanup(struct net_device *dev)
15951622

15961623
ASSERT_RTNL();
15971624

1598-
ipoib_delete_debug_files(dev);
1599-
16001625
/* Delete any child interfaces first */
16011626
list_for_each_entry_safe(cpriv, tcpriv, &priv->child_intfs, list) {
16021627
/* Stop GC on child */
@@ -1908,8 +1933,6 @@ static struct net_device *ipoib_add_port(const char *format,
19081933
goto register_failed;
19091934
}
19101935

1911-
ipoib_create_debug_files(priv->dev);
1912-
19131936
if (ipoib_cm_add_mode_attr(priv->dev))
19141937
goto sysfs_failed;
19151938
if (ipoib_add_pkey_attr(priv->dev))
@@ -1924,7 +1947,6 @@ static struct net_device *ipoib_add_port(const char *format,
19241947
return priv->dev;
19251948

19261949
sysfs_failed:
1927-
ipoib_delete_debug_files(priv->dev);
19281950
unregister_netdev(priv->dev);
19291951

19301952
register_failed:
@@ -2006,6 +2028,12 @@ static void ipoib_remove_one(struct ib_device *device, void *client_data)
20062028
kfree(dev_list);
20072029
}
20082030

2031+
#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
2032+
static struct notifier_block ipoib_netdev_notifier = {
2033+
.notifier_call = ipoib_netdev_event,
2034+
};
2035+
#endif
2036+
20092037
static int __init ipoib_init_module(void)
20102038
{
20112039
int ret;
@@ -2057,6 +2085,9 @@ static int __init ipoib_init_module(void)
20572085
if (ret)
20582086
goto err_client;
20592087

2088+
#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
2089+
register_netdevice_notifier(&ipoib_netdev_notifier);
2090+
#endif
20602091
return 0;
20612092

20622093
err_client:
@@ -2074,6 +2105,9 @@ static int __init ipoib_init_module(void)
20742105

20752106
static void __exit ipoib_cleanup_module(void)
20762107
{
2108+
#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
2109+
unregister_netdevice_notifier(&ipoib_netdev_notifier);
2110+
#endif
20772111
ipoib_netlink_fini();
20782112
ib_unregister_client(&ipoib_client);
20792113
ib_sa_unregister_client(&ipoib_sa_client);

drivers/infiniband/ulp/ipoib/ipoib_vlan.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv,
8585
goto register_failed;
8686
}
8787

88-
ipoib_create_debug_files(priv->dev);
89-
9088
/* RTNL childs don't need proprietary sysfs entries */
9189
if (type == IPOIB_LEGACY_CHILD) {
9290
if (ipoib_cm_add_mode_attr(priv->dev))
@@ -107,7 +105,6 @@ int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv,
107105

108106
sysfs_failed:
109107
result = -ENOMEM;
110-
ipoib_delete_debug_files(priv->dev);
111108
unregister_netdevice(priv->dev);
112109

113110
register_failed:

0 commit comments

Comments
 (0)