svn commit: samba r7353 - in trunk/source/smbd: .

jra at samba.org jra at samba.org
Tue Jun 7 07:24:57 GMT 2005


Author: jra
Date: 2005-06-07 07:24:57 +0000 (Tue, 07 Jun 2005)
New Revision: 7353

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7353

Log:
More tweaks to aio code - doesn't compile yet but the structure is becoming
clear. Need to add aio_XXX calls to VFS layer soon.
Jeremy.

Modified:
   trunk/source/smbd/aio.c


Changeset:
Modified: trunk/source/smbd/aio.c
===================================================================
--- trunk/source/smbd/aio.c	2005-06-07 07:22:25 UTC (rev 7352)
+++ trunk/source/smbd/aio.c	2005-06-07 07:24:57 UTC (rev 7353)
@@ -23,11 +23,13 @@
 
 #if HAVE_POSIX_ASYNC_IO
 
+/* The signal we'll use to signify aio done. */
 #define RT_SIGNAL_AIO (SIGRTMIN+3)
-#define AIO_PENDING_SIZE 10
-static sig_atomic_t signals_received;
-static int outstanding_aio_reads;
 
+/****************************************************************************
+ The buffer we keep around whilst an aio request is in process.
+*****************************************************************************/
+
 struct aio_extra {
 	struct aio_extra *next, *prev;
 	struct aiocb acb;
@@ -37,17 +39,45 @@
 
 struct aio_extra aio_list_head;
 
-static struct aio_extra *create_aio_ex(void)
+/****************************************************************************
+ Create the extended aio struct we must keep around for the lifetime
+ of the aio call.
+*****************************************************************************/
+
+static struct aio_extra *create_aio_ex(size_t buflen)
 {
-	struct aio_extra *aio_ex = MALLOC_P();
+	struct aio_extra *aio_ex = SMB_MALLOC_P(struct aio_extra);
+
+	if (!aio_ex) {
+		return NULL;
+	}
+	ZERO_STRUCTP(aio_ex);
+	/* The buf stored in the aio_ex is the start of
+	   the smb return buffer. The buffer used in the acb
+	   is the start of the reply data portion of that buffer. */
+	aio_ex->buf = SMB_MALLOC_ARRAY(char *, buflen);
+	if (!aio_ex->buf) {
+		SAFE_FREE(aio_ex);
+		return NULL;
+	}
+	DLIST_ADD(aio_list_head, aio_ex);
+	return aio_ex;
 }
 
+/****************************************************************************
+ Delete the extended aio struct.
+*****************************************************************************/
+
 static void delete_aio_ex(struct aio_extra *aio_ex)
 {
 	DLIST_REMOVE(aio_list_head, aio_ex);
 	SAFE_FREE(aio_ex->buf);
 }
 
+/****************************************************************************
+ Given the aiocb struct find the extended aio struct containing it.
+*****************************************************************************/
+
 static struct aio_extra *find_aio_ex(struct aiocb *pacb)
 {
 	struct aio_extra *p;
@@ -60,8 +90,20 @@
 	return NULL;
 }
 
+/****************************************************************************
+ We can have these many aio buffers in flight.
+*****************************************************************************/
+
+#define AIO_PENDING_SIZE 10
+static sig_atomic_t signals_received;
+static int outstanding_aio_reads;
+
 static struct aiocb aio_pending_array[AIO_PENDING_SIZE];
 
+/****************************************************************************
+ Signal handler when an aio request completes.
+*****************************************************************************/
+
 static void signal_handler(int sig, siginfo_t *info, void *unused)
 {
 	if (signals_received < AIO_PENDING_SIZE - 1) {
@@ -71,16 +113,32 @@
 	sys_select_signal();
 }
 
+/****************************************************************************
+ Set up an aio request from a SMBreadX call.
+*****************************************************************************/
+
 BOOL schedule_aio_read_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length, int len_outbuf,
 				files_struct *fsp, SMB_OFF_T startpos, size_t smb_maxcnt)
 {
+	size_t min_aio_read_size = lp_aio_read_size(SNUM(conn));
+
+	if (min_aio_read_size && (smb_maxcnt < min_aio_read_size)) {
+		/* Too small a read for aio request. */
+		DEBUG(10,("schedule_aio_read_and_X: read size (%u) too small for minimum aio_read of %u\n",
+			(unsigned int)smb_maxcnt, (unsigned int)min_aio_read_size ));
+		return False;
+	}
+
 	if (outstanding_aio_reads >= AIO_PENDING_SIZE) {
 		DEBUG(10,("schedule_aio_read_and_X: Already have %d aio activities outstanding.\n",
 			outstanding_aio_reads ));
 		return False;
 	}
+
+	/* Allocate and set up the aio record here... */
+
 	srv_defer_sign_response(mid);
-	return False;
+	return True;
 }
 
 void process_aio_queue(void)



More information about the samba-cvs mailing list