mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hal Rosenstock <halr@voltaire.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, openib-general@openib.org
Subject: PATCH [7/27] Fix timeout/cancelled MAD handling
Date: 11 Jul 2005 10:01:17 -0400	[thread overview]
Message-ID: <1121089096.4389.4519.camel@hal.voltaire.com> (raw)

Fixes an issue processing a sent MAD after it has timed out or 
been canceled.  The race occurs when a response MAD matches with
the send request.  The request could time out or be canceled after
the response MAD matches with the request, but before the request
completion can be processed.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Hal Rosenstock <halr@voltaire.com>

This patch depends on patch 6/27.

-- 
 mad.c      |   14 ++++++++++++--
 mad_priv.h |    1 +
 2 files changed, 13 insertions(+), 2 deletions(-)
diff -uprN linux-2.6.13-rc2-mm1/drivers/infiniband6/core/mad.c linux-2.6.13-rc2-mm1/drivers/infiniband7/core/mad.c
-- linux-2.6.13-rc2-mm1/drivers/infiniband6/core/mad.c	2005-07-09 15:12:32.000000000 -0400
+++ linux-2.6.13-rc2-mm1/drivers/infiniband7/core/mad.c	2005-07-09 16:48:45.000000000 -0400
@@ -341,6 +341,7 @@ struct ib_mad_agent *ib_register_mad_age
 	spin_lock_init(&mad_agent_priv->lock);
 	INIT_LIST_HEAD(&mad_agent_priv->send_list);
 	INIT_LIST_HEAD(&mad_agent_priv->wait_list);
+	INIT_LIST_HEAD(&mad_agent_priv->done_list);
 	INIT_WORK(&mad_agent_priv->timed_work, timeout_sends, mad_agent_priv);
 	INIT_LIST_HEAD(&mad_agent_priv->local_list);
 	INIT_WORK(&mad_agent_priv->local_work, local_completions,
@@ -1559,6 +1560,16 @@ find_send_req(struct ib_mad_agent_privat
 	return NULL;
 }
 
+static void ib_mark_req_done(struct ib_mad_send_wr_private *mad_send_wr)
+{
+	mad_send_wr->timeout = 0;
+	if (mad_send_wr->refcount == 1) {
+		list_del(&mad_send_wr->agent_list);
+		list_add_tail(&mad_send_wr->agent_list,
+			      &mad_send_wr->mad_agent_priv->done_list);
+	}
+}
+
 static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,
 				 struct ib_mad_recv_wc *mad_recv_wc)
 {
@@ -1580,8 +1591,7 @@ static void ib_mad_complete_recv(struct 
 				wake_up(&mad_agent_priv->wait);
 			return;
 		}
-		/* Timeout = 0 means that we won't wait for a response */
-		mad_send_wr->timeout = 0;
+		ib_mark_req_done(mad_send_wr);
 		spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
 
 		/* Defined behavior is to complete response before request */
diff -uprN linux-2.6.13-rc2-mm1/drivers/infiniband6/core/mad_priv.h linux-2.6.13-rc2-mm1/drivers/infiniband7/core/mad_priv.h
-- linux-2.6.13-rc2-mm1/drivers/infiniband6/core/mad_priv.h	2005-07-09 15:09:53.000000000 -0400
+++ linux-2.6.13-rc2-mm1/drivers/infiniband7/core/mad_priv.h	2005-07-09 16:48:05.000000000 -0400
@@ -92,6 +92,7 @@ struct ib_mad_agent_private {
 	spinlock_t lock;
 	struct list_head send_list;
 	struct list_head wait_list;
+	struct list_head done_list;
 	struct work_struct timed_work;
 	unsigned long timeout;
 	struct list_head local_list;



                 reply	other threads:[~2005-07-11 14:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1121089096.4389.4519.camel@hal.voltaire.com \
    --to=halr@voltaire.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openib-general@openib.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome