[openib-general] sdp_kvec.c

Libor Michalek libor at topspin.com
Thu Feb 24 11:11:10 PST 2005


On Wed, Feb 23, 2005 at 01:02:43PM +0200, Michael S. Tsirkin wrote:
> Libor, shall not the code in sdp_kvec.c go into
> sdp_iocb.c? I dont see kvec mentionned even once in there ...

  Yes. Here's a patch to simplify the code in sdp_kvec.c and move it
to sdp_conn.c. The reason I moved it there instead of sdp_iocb.c is
that the cancel functions are for a specific connection, and cancel
all outstanding AIO requests for a given connection. 

 3 files changed, 43 insertions(+), 156 deletions(-)

-Libor

Signed-off-by: Libor Michalek <libor at topspin.com>

Index: Makefile
===================================================================
--- Makefile	(revision 1905)
+++ Makefile	(working copy)
@@ -10,7 +10,6 @@
 	sdp_buff.o \
 	sdp_rcvd.o \
 	sdp_sent.o \
-	sdp_kvec.o \
 	sdp_read.o \
 	sdp_write.o \
 	sdp_wall.o \
Index: sdp_conn.c
===================================================================
--- sdp_conn.c	(revision 1905)
+++ sdp_conn.c	(working copy)
@@ -596,7 +596,50 @@
 	spin_unlock_irqrestore(&_dev_root_s.sock_lock, flags);
 	return conn;
 } /* sdp_conn_table_lookup */
+/* 
+ * Functions to cancel IOCB requests in a conenctions queues.
+ */
+static int _sdp_desc_q_cancel_lookup_func(struct sdpc_desc *element, void *arg)
+{
+	return ((SDP_DESC_TYPE_IOCB == element->type) ? 0 : -ERANGE);
+} /* _sdp_iocb_q_cancel_lookup_func */
 
+static void _sdp_desc_q_cancel_iocb(struct sdpc_desc_q *table, ssize_t error)
+{
+	struct sdpc_iocb *iocb;
+
+	while (NULL != (iocb = (struct sdpc_iocb *)sdp_desc_q_lookup
+			(table,
+			 _sdp_desc_q_cancel_lookup_func,
+			 NULL))) {
+
+		sdp_iocb_q_remove(iocb);
+		(void)sdp_iocb_complete(iocb, error);
+	}
+} /* _sdp_desc_q_cancel_iocb */
+
+void sdp_iocb_q_cancel_all_read(struct sdp_opt *conn, ssize_t error)
+{
+	sdp_iocb_q_cancel(&conn->r_pend, SDP_IOCB_F_ALL, error);
+	sdp_iocb_q_cancel(&conn->r_snk, SDP_IOCB_F_ALL, error);
+
+	_sdp_desc_q_cancel_iocb(&conn->r_src, error);
+} /* sdp_iocb_q_cancel_all_read */
+
+void sdp_iocb_q_cancel_all_write(struct sdp_opt *conn, ssize_t error)
+{
+	sdp_iocb_q_cancel(&conn->w_src, SDP_IOCB_F_ALL, error);
+
+	_sdp_desc_q_cancel_iocb(&conn->send_queue, error);
+	_sdp_desc_q_cancel_iocb(&conn->w_snk, error);
+} /* sdp_iocb_q_cancel_all_write */
+
+void sdp_iocb_q_cancel_all(struct sdp_opt *conn, ssize_t error)
+{
+	sdp_iocb_q_cancel_all_read(conn, error);
+	sdp_iocb_q_cancel_all_write(conn, error);
+} /* sdp_iocb_q_cancel_all */
+
 /*
  * connection allocation/deallocation
  */
Index: sdp_kvec.c
===================================================================
--- sdp_kvec.c	(revision 1905)
+++ sdp_kvec.c	(working copy)
@@ -1,155 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications.  All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- *
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- *
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * $Id$
- */
-
-#include "sdp_main.h"
-
-/*
- * _sdp_iocb_q_cancel_lookup_func - lookup function for cancelation
- */
-static int _sdp_iocb_q_cancel_lookup_func(struct sdpc_desc *element, void *arg)
-{
-	return ((SDP_DESC_TYPE_IOCB == element->type) ? 0 : -ERANGE);
-} /* _sdp_iocb_q_cancel_lookup_func */
-
-/*
- * _sdp_iocb_q_cancel_read_pending - cancel all pending read AIOs
- */
-static void _sdp_iocb_q_cancel_read_pending(struct sdp_opt *conn,
-					    ssize_t error)
-{
-	sdp_iocb_q_cancel(&conn->r_pend, SDP_IOCB_F_ALL, error);
-} /* _sdp_iocb_q_cancel_read_pending */
-
-/*
- * _sdp_iocb_q_cancel_read_source - cancel all pending read AIOs
- */
-static void _sdp_iocb_q_cancel_read_source(struct sdp_opt *conn, ssize_t error)
-{
-	struct sdpc_iocb *iocb;
-	int result;
-
-	while (NULL != (iocb = (struct sdpc_iocb *) sdp_desc_q_lookup(&conn->r_src,
-								   _sdp_iocb_q_cancel_lookup_func,
-								   NULL))) {
-		sdp_iocb_q_remove(iocb);
-
-		result = sdp_iocb_complete(iocb, error);
-		SDP_EXPECT(!(0 > result));
-	}
-} /* _sdp_iocb_q_cancel_read_source */
-
-/*
- * _sdp_iocb_q_cancel_read_snk - cancel all pending read AIOs
- */
-static void _sdp_iocb_q_cancel_read_snk(struct sdp_opt *conn, ssize_t error)
-{
-	sdp_iocb_q_cancel(&conn->r_snk, SDP_IOCB_F_ALL, error);
-} /* _sdp_iocb_q_cancel_read_snk */
-
-/*
- * _sdp_iocb_q_cancel_write_pending - cancel all pending read AIOs
- */
-static void _sdp_iocb_q_cancel_write_pending(struct sdp_opt *conn,
-					     ssize_t error)
-{
-	struct sdpc_iocb *iocb;
-	int result;
-
-	while (NULL !=
-	       (iocb =
-		(struct sdpc_iocb *) sdp_desc_q_lookup(&conn->send_queue,
-						    _sdp_iocb_q_cancel_lookup_func,
-						    NULL))) {
-		sdp_iocb_q_remove(iocb);
-
-		result = sdp_iocb_complete(iocb, error);
-		SDP_EXPECT(!(0 > result));
-	}
-} /* _sdp_iocb_q_cancel_write_pending */
-
-/*
- * _sdp_iocb_q_cancel_write_source - cancel all pending source AIOs
- */
-static void _sdp_iocb_q_cancel_write_source(struct sdp_opt *conn,
-					    ssize_t error)
-{
-	sdp_iocb_q_cancel(&conn->w_src, SDP_IOCB_F_ALL, error);
-} /* _sdp_iocb_q_cancel_write_source */
-
-/*
- * _sdp_iocb_q_cancel_write_snk - cancel all pending sink AIOs
- */
-static void _sdp_iocb_q_cancel_write_snk(struct sdp_opt *conn, ssize_t error)
-{
-	struct sdpc_iocb *iocb;
-	int result;
-
-	while (NULL != (iocb = (struct sdpc_iocb *) sdp_desc_q_lookup(&conn->w_snk,
-								   _sdp_iocb_q_cancel_lookup_func,
-								   NULL))) {
-		sdp_iocb_q_remove(iocb);
-
-		result = sdp_iocb_complete(iocb, error);
-		SDP_EXPECT(!(0 > result));
-	}
-} /* _sdp_iocb_q_cancel_write_snk */
-
-/* 
- * sdp_iocb_q_cancel_all_read - cancel all outstanding read AIOs
- */
-void sdp_iocb_q_cancel_all_read(struct sdp_opt *conn, ssize_t error)
-{
-	_sdp_iocb_q_cancel_read_pending(conn, error);
-	_sdp_iocb_q_cancel_read_snk(conn, error);
-	_sdp_iocb_q_cancel_read_source(conn, error);
-} /* sdp_iocb_q_cancel_all_read */
-
-/*
- * sdp_iocb_q_cancel_all_write - cancel all outstanding write AIOs
- */
-void sdp_iocb_q_cancel_all_write(struct sdp_opt *conn, ssize_t error)
-{
-	_sdp_iocb_q_cancel_write_pending(conn, error);
-	_sdp_iocb_q_cancel_write_source(conn, error);
-	_sdp_iocb_q_cancel_write_snk(conn, error);
-} /* sdp_iocb_q_cancel_all_write */
-
-/*
- * sdp_iocb_q_cancel_all - cancel all outstanding AIOs
- */
-void sdp_iocb_q_cancel_all(struct sdp_opt *conn, ssize_t error)
-{
-	sdp_iocb_q_cancel_all_read(conn, error);
-	sdp_iocb_q_cancel_all_write(conn, error);
-} /* sdp_iocb_q_cancel_all */



More information about the general mailing list