]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
IB/IPoIB: ibX: failed to create mcg debug file
authorShamir Rabinovitch <shamir.rabinovitch@oracle.com>
Wed, 29 Mar 2017 10:21:59 +0000 (06:21 -0400)
committerAllen Pais <allen.pais@oracle.com>
Sat, 24 Jun 2017 01:27:47 +0000 (06:57 +0530)
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)
Cc: stable@vger.kernel.org # 2.6.15+
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>
(cherry picked from git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma
 commit 771a52584096c45e4565e8aabb596eece9d73d61)

Orabug: 24711873

Reviewed-by: Allen Pais <allen.pais@oracle.com>
Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
Signed-off-by: Allen Pais <allen.pais@oracle.com>
drivers/infiniband/ulp/ipoib/ipoib_fs.c
drivers/infiniband/ulp/ipoib/ipoib_main.c
drivers/infiniband/ulp/ipoib/ipoib_vlan.c

index 6bd5740e26913df2662bad05a754ad6e88b3bb50..09396bd7b02d282321fa0b015b0ec33cef350ed9 100644 (file)
@@ -281,8 +281,11 @@ void ipoib_delete_debug_files(struct net_device *dev)
 {
        struct ipoib_dev_priv *priv = netdev_priv(dev);
 
+       WARN_ONCE(!priv->mcg_dentry, "null mcg debug file\n");
+       WARN_ONCE(!priv->path_dentry, "null path debug file\n");
        debugfs_remove(priv->mcg_dentry);
        debugfs_remove(priv->path_dentry);
+       priv->mcg_dentry = priv->path_dentry = NULL;
 }
 
 int ipoib_register_debugfs(void)
index 9d2f5b2f5fa9c28aaa59c7893dcd4ebb86a24acb..72466da91effbf2385ced3731cda53ff56af17e5 100644 (file)
@@ -128,6 +128,33 @@ static struct ib_client ipoib_client = {
  */
 #define PKEY_HEXSTRING_MAXWIDTH 4
 
+#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
+static int ipoib_netdev_event(struct notifier_block *this,
+                             unsigned long event, void *ptr)
+{
+       struct netdev_notifier_info *ni = ptr;
+       struct net_device *dev = ni->dev;
+
+       if (dev->netdev_ops->ndo_open != ipoib_open)
+               return NOTIFY_DONE;
+
+       switch (event) {
+       case NETDEV_REGISTER:
+               ipoib_create_debug_files(dev);
+               break;
+       case NETDEV_CHANGENAME:
+               ipoib_delete_debug_files(dev);
+               ipoib_create_debug_files(dev);
+               break;
+       case NETDEV_UNREGISTER:
+               ipoib_delete_debug_files(dev);
+               break;
+       }
+
+       return NOTIFY_DONE;
+}
+#endif
+
 int ipoib_open(struct net_device *dev)
 {
        struct ipoib_dev_priv *priv = netdev_priv(dev);
@@ -1406,8 +1433,6 @@ void ipoib_dev_cleanup(struct net_device *dev)
 
        ASSERT_RTNL();
 
-       ipoib_delete_debug_files(dev);
-
        /* Delete any child interfaces first */
        list_for_each_entry_safe(cpriv, tcpriv, &priv->child_intfs, list) {
                ipoib_clean_acl(cpriv->dev);
@@ -1886,8 +1911,6 @@ static struct net_device *ipoib_add_port(const char *format,
                goto register_failed;
        }
 
-       ipoib_create_debug_files(priv->dev);
-
        result = -ENOMEM;
 
        if (ipoib_cm_add_mode_attr(priv->dev))
@@ -1910,7 +1933,6 @@ static struct net_device *ipoib_add_port(const char *format,
        return priv->dev;
 
 sysfs_failed:
-       ipoib_delete_debug_files(priv->dev);
        unregister_netdev(priv->dev);
 
 register_failed:
@@ -2029,6 +2051,12 @@ EXPORT_SYMBOL(ipoib_get_netdev_pkey);
 
 #define MODULE_NAME "ib_ipoib"
 
+#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
+static struct notifier_block ipoib_netdev_notifier = {
+       .notifier_call = ipoib_netdev_event,
+};
+#endif
+
 static int __init ipoib_init_module(void)
 {
        int ret;
@@ -2111,6 +2139,9 @@ static int __init ipoib_init_module(void)
                __module_get(THIS_MODULE);
        }
 
+#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
+       register_netdevice_notifier(&ipoib_netdev_notifier);
+#endif
        return 0;
 
 err_client:
@@ -2128,6 +2159,9 @@ err_fs:
 
 static void __exit ipoib_cleanup_module(void)
 {
+#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
+       unregister_netdevice_notifier(&ipoib_netdev_notifier);
+#endif
        ipoib_netlink_fini();
        ib_unregister_client(&ipoib_client);
        ib_sa_unregister_client(&ipoib_sa_client);
index 6017bff91676c5677cb28b93bbb9f51f8df6de7a..904f9a98307b5448cf77bfac00a3501da4107480 100644 (file)
@@ -87,8 +87,6 @@ int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv,
                goto register_failed;
        }
 
-       ipoib_create_debug_files(priv->dev);
-
        /* RTNL childs don't need proprietary sysfs entries */
        if (type == IPOIB_LEGACY_CHILD) {
                if (ipoib_cm_add_mode_attr(priv->dev))
@@ -112,7 +110,6 @@ int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv,
 
 sysfs_failed:
        result = -ENOMEM;
-       ipoib_delete_debug_files(priv->dev);
        unregister_netdevice(priv->dev);
 
 register_failed: