diff mbox

cnic: Give a chance for the uio device to be opened before failing the path request

Message ID 1270762468-21128-1-git-send-email-benli@broadcom.com
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Benjamin Li April 8, 2010, 9:34 p.m. UTC
There is a timing condition; where the time between the CNIC's
/dev/uio* device registration and then the issuing of path requests
messages is faster the brcm_iscsiuio daemon initializing.

This can be seen if one sets the machine to automatically login into
iSCSI targets.  Then reset the network and iscsi daemons in quick
succession.  The login will fail because iscsid will only try
a couple of times in quick succession.  This patch will allow some
additional needed time for the brcm_iscsiuio daemon to initialize
before failing the path request call.

Signed-off-by: Benjamin Li <benli@broadcom.com>
Signed-off-by: Eddie Wai <waie@broadcom.com>
---
 drivers/net/cnic.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

Comments

David Miller April 9, 2010, 10:49 p.m. UTC | #1
From: "Benjamin Li" <benli@broadcom.com>
Date: Thu, 8 Apr 2010 14:34:28 -0700

> There is a timing condition; where the time between the CNIC's
> /dev/uio* device registration and then the issuing of path requests
> messages is faster the brcm_iscsiuio daemon initializing.
> 
> This can be seen if one sets the machine to automatically login into
> iSCSI targets.  Then reset the network and iscsi daemons in quick
> succession.  The login will fail because iscsid will only try
> a couple of times in quick succession.  This patch will allow some
> additional needed time for the brcm_iscsiuio daemon to initialize
> before failing the path request call.
> 
> Signed-off-by: Benjamin Li <benli@broadcom.com>
> Signed-off-by: Eddie Wai <waie@broadcom.com>

You need to create a proper serialization scheme to fix this.

Any delay value you choose is arbitrary, and could be easily exceeded
if swapping or other expensive operations are in propgress at the time
of the regristration.

Therefore all delay based schemes have a failure mode and therefore
isn't the way to fix this properly.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 9781942..897f171 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -274,9 +274,17 @@  static int cnic_send_nlmsg(struct cnic_local *cp, u32 type,
 	u16 len = 0;
 	u32 msg_type = ISCSI_KEVENT_IF_DOWN;
 	struct cnic_ulp_ops *ulp_ops;
+	int count = 0;
 
-	if (cp->uio_dev == -1)
+	while (count < 40 && cp->uio_dev == -1) {
+		msleep(50);
+		count++;
+	}
+
+	if (cp->uio_dev == -1) {
+		netdev_warn(cp->dev->netdev, "no uio dev to send nl request\n");
 		return -ENODEV;
+	}
 
 	if (csk) {
 		len = sizeof(path_req);