diff mbox series

[08/24] lnet: o2iblnd: treat cmid->device == NULL as an error

Message ID 1642124283-10148-9-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: update to OpenSFS Jan 13, 2022 | expand

Commit Message

James Simmons Jan. 14, 2022, 1:37 a.m. UTC
From: Serguei Smirnov <ssmirnov@whamcloud.com>

Even if rdma_bind_addr is successful, kiblnd_dev_failover should
treat cmid->device == NULL as an error in order to later avoid
calling kiblnd_set_ni_fatal_on with possibly dev->ibd_hdev == NULL.

Fixes: 5e07562bc3 ("lnet: o2iblnd: clear fatal error on successful failover")
WC-bug-id: https://jira.whamcloud.com/browse/LU-15018
Lustre-commit: abd0ce62e96523193 ("LU-15018 o2iblnd: treat cmid->device == NULL as an error")
Signed-off-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/44981
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Cyril Bordage <cbordage@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/klnds/o2iblnd/o2iblnd.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/net/lnet/klnds/o2iblnd/o2iblnd.c b/net/lnet/klnds/o2iblnd/o2iblnd.c
index 7d28acd..76f5e7f 100644
--- a/net/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/net/lnet/klnds/o2iblnd/o2iblnd.c
@@ -2365,6 +2365,7 @@  int kiblnd_dev_failover(struct kib_dev *dev, struct net *ns)
 	struct kib_net *net;
 	struct sockaddr_in addr;
 	struct net_device *netdev;
+	bool set_fatal = true;
 	unsigned long flags;
 	int rc = 0;
 	int i;
@@ -2416,6 +2417,8 @@  int kiblnd_dev_failover(struct kib_dev *dev, struct net *ns)
 		CERROR("Failed to bind %s:%pI4h to device(%p): %d\n",
 		       dev->ibd_ifname, &dev->ibd_ifip,
 		       cmid->device, rc);
+		if (!rc && !cmid->device)
+			set_fatal = false;
 		rdma_destroy_id(cmid);
 		goto out;
 	}
@@ -2490,11 +2493,13 @@  int kiblnd_dev_failover(struct kib_dev *dev, struct net *ns)
 	} else {
 		dev->ibd_failed_failover = 0;
 
-		rcu_read_lock();
-		netdev = dev_get_by_name_rcu(ns, dev->ibd_ifname);
-		if (netdev && (kiblnd_get_link_status(netdev) == 1))
-			kiblnd_set_ni_fatal_on(dev->ibd_hdev, 0);
-		rcu_read_unlock();
+		if (set_fatal) {
+			rcu_read_lock();
+			netdev = dev_get_by_name_rcu(ns, dev->ibd_ifname);
+			if (netdev && (kiblnd_get_link_status(netdev) == 1))
+				kiblnd_set_ni_fatal_on(dev->ibd_hdev, 0);
+			rcu_read_unlock();
+		}
 	}
 
 	return rc;