Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Dec 2007 07:23:11 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 131420 for review
Message-ID:  <200712220723.lBM7NBhn065549@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=131420

Change 131420 by kmacy@kmacy:entropy:iwarp on 2007/12/22 07:23:05

	Add aesthetically displeasing but backport-able mechanism for hooking 
	aio calls in a generic fashion.

Affected files ...

.. //depot/projects/iwarp/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#5 edit
.. //depot/projects/iwarp/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c#4 edit
.. //depot/projects/iwarp/sys/dev/cxgb/ulp/tom/cxgb_defs.h#4 edit
.. //depot/projects/iwarp/sys/kern/vfs_aio.c#3 edit
.. //depot/projects/iwarp/sys/netinet/tcp.h#4 edit
.. //depot/projects/iwarp/sys/sys/aio.h#2 edit

Differences ...

==== //depot/projects/iwarp/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#5 (text+ko) ====

@@ -44,6 +44,7 @@
 #include <sys/socketvar.h>
 #include <sys/protosw.h>
 #include <sys/priv.h>
+#include <sys/aio.h>
 
 #include <net/if.h>
 #include <net/route.h>
@@ -1427,6 +1428,14 @@
 #endif			
 		} else
 			return (err);
+	} else if (sopt->sopt_name == TCP_AIO) {
+		aio_op_t **op;
+		
+		if (sopt->sopt_td != NULL)
+			return (EINVAL);
+		op = sopt->sopt_val;
+		*op = t3_aio;
+		return (0);
 	} else {
 		int optval, oldval;
 		struct inpcb *inp;

==== //depot/projects/iwarp/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c#4 (text+ko) ====

@@ -44,6 +44,8 @@
 #include <sys/syslog.h>
 #include <sys/socketvar.h>
 #include <sys/uio.h>
+#include <sys/aio.h>
+#include <sys/file.h>
 
 #include <machine/bus.h>
 
@@ -440,6 +442,42 @@
 	return pru_soreceive(so, psa, uio, mp0, controlp, flagsp);
 }
 
+static int
+t3_aio_read(struct socket *so, struct aiocb *cb, struct aiocb *ucb, struct thread *td)
+{
+
+	return (ECANCELED);
+}
+
+static int
+t3_aio_write(struct socket *so, struct aiocb *cb, struct aiocb *ucb, struct thread *td)
+{
+
+	return (ECANCELED);
+}
+
+int
+t3_aio(struct file *fp, struct aiocb *cb, struct aiocb *ucb, struct thread *td)
+{
+	int opcode, error;
+	struct socket *so;
+	
+	opcode = cb->aio_lio_opcode;
+
+	if (fp->f_type != DTYPE_SOCKET)
+		return (EINVAL);
+
+	so = fp->f_data;
+	if ((opcode != LIO_READ) && (opcode != LIO_WRITE))
+		return (ECANCELED);
+	
+	if (opcode == LIO_READ)
+		error = (t3_aio_read(so, cb, ucb, td));
+	else
+		error = (t3_aio_write(so, cb, ucb, td));
+
+	return (error);
+}
 
 void
 t3_install_socket_ops(struct socket *so)

==== //depot/projects/iwarp/sys/dev/cxgb/ulp/tom/cxgb_defs.h#4 (text+ko) ====

@@ -76,4 +76,8 @@
 		    unsigned int len);
 int t3_get_tcb(struct socket *so);
 
+struct aiocb;
+struct file;
+int t3_aio(struct file *, struct aiocb *cb, struct aiocb *ucb, struct thread *td);
+
 #endif

==== //depot/projects/iwarp/sys/kern/vfs_aio.c#3 (text+ko) ====

@@ -494,6 +494,31 @@
 	return (0);
 }
 
+static aio_op_t
+aio_op_get(struct file *fp)
+{
+	struct socket *so;
+	aio_op_t op;
+	struct sockopt sopt;
+	socklen_t valsize;
+	int error;
+	
+	if (fp->f_type != DTYPE_SOCKET)
+		return (NULL);
+
+	sopt.sopt_dir = SOPT_GET;
+	sopt.sopt_level = 0;
+	sopt.sopt_name = TCP_AIO;
+	sopt.sopt_val = &op;
+	sopt.sopt_valsize = sizeof(aio_op_t);
+	sopt.sopt_tp = NULL;
+	so = fp->f_data;g
+	if ((error = sogetopt(so, &sopt)) != 0)
+		return (NULL);
+	
+	return (op);
+}
+
 /*
  * Init the per-process aioinfo structure.  The aioinfo limits are set
  * per-process for user limit (resource) management.
@@ -1335,6 +1360,7 @@
 	struct kaioinfo *ki;
 	struct kevent kev;
 	struct sockbuf *sb;
+	aio_op_t op;
 	int opcode;
 	int error;
 	int fd, kqfd;
@@ -1472,11 +1498,26 @@
 
 	suword(&job->_aiocb_private.error, EINPROGRESS);
 	aiocbe->uaiocb._aiocb_private.error = EINPROGRESS;
+
+	op = aio_op_get(fp);
+	if (op != NULL) {
+		error = op(fp, &aiocbe->uaiocb, job, td);
+		if (error && error != ECANCELED)
+			fdrop(fp, td);
+
+		if (error == ECANCELED)
+			error = 0;
+		else {
+			uma_zfree(aiocb_zone, aiocbe);
+			goto done;		
+		}
+	}
 	aiocbe->userproc = p;
 	aiocbe->cred = crhold(td->td_ucred);
 	aiocbe->jobflags = 0;
 	aiocbe->lio = lj;
 
+	
 	if (opcode == LIO_SYNC)
 		goto queueit;
 
@@ -1494,6 +1535,7 @@
 		 * Note if opcode is neither LIO_WRITE nor LIO_READ we lock
 		 * and unlock the snd sockbuf for no reason.
 		 */
+
 		so = fp->f_data;
 		sb = (opcode == LIO_READ) ? &so->so_rcv : &so->so_snd;
 		SOCKBUF_LOCK(sb);

==== //depot/projects/iwarp/sys/netinet/tcp.h#4 (text+ko) ====

@@ -148,6 +148,7 @@
 #define TCP_MD5SIG	0x10	/* use MD5 digests (RFC2385) */
 #define	TCP_INFO	0x20	/* retrieve tcp_info structure */
 #define	TCP_CONGESTION	0x40	/* get/set congestion control algorithm */
+#define	TCP_AIO		0x80	/* fetch AIO operation */
 
 #define	TCP_CA_NAME_MAX	16	/* max congestion control name length */
 

==== //depot/projects/iwarp/sys/sys/aio.h#2 (text+ko) ====

@@ -132,8 +132,11 @@
 /* Forward declarations for prototypes below. */
 struct socket;
 struct sockbuf;
+struct file;
+struct thread;
 
 extern void (*aio_swake)(struct socket *, struct sockbuf *);
+typedef int	aio_op_t (struct file *, struct aiocb *, struct aiocb *, struct thread *);
 
 #endif
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200712220723.lBM7NBhn065549>