Author: jra
Date: 2005-06-08 23:01:38 +0000 (Wed, 08 Jun 2005)
New Revision: 7416

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

Log:
Only do aio reads/writes on non-chained non-write cached calls.
Add abstract types for aiocb struct and wrapper functions for 64-bit aio.
Jeremy.

Modified:
   trunk/source/include/includes.h
   trunk/source/lib/system.c
   trunk/source/smbd/aio.c


Changeset:
Modified: trunk/source/include/includes.h
===================================================================
--- trunk/source/include/includes.h     2005-06-08 22:10:34 UTC (rev 7415)
+++ trunk/source/include/includes.h     2005-06-08 23:01:38 UTC (rev 7416)
@@ -765,6 +765,18 @@
 #  endif
 #endif
 
+/*
+ * Type for aiocb structure.
+ */
+
+#ifndef SMB_STRUCT_AIOCB
+#  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_AIOCB64)
+#    define SMB_STRUCT_AIOCB struct aiocb64
+#  else
+#    define SMB_STRUCT_AIOCB struct aiocb
+#  endif
+#endif
+
 #ifndef MIN
 #define MIN(a,b) ((a)<(b)?(a):(b))
 #endif

Modified: trunk/source/lib/system.c
===================================================================
--- trunk/source/lib/system.c   2005-06-08 22:10:34 UTC (rev 7415)
+++ trunk/source/lib/system.c   2005-06-08 23:01:38 UTC (rev 7416)
@@ -1846,3 +1846,67 @@
         return (uint32)(dev & 0xff);
 #endif
 }
+
+/*******************************************************************
+ An aio_read wrapper that will deal with 64-bit sizes.
+********************************************************************/
+                                                                               
                                                            
+int sys_aio_read(SMB_STRUCT_AIOCB *aiocb)
+{
+#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_AIOCB64) && 
defined(HAVE_AIO_READ64)
+        return aio_read64(aiocb);
+#elif defined(HAVE_AIO_READ)
+        return aio_read(aiocb);
+#else
+       errno = ENOSYS;
+       return -1;
+#endif
+}
+
+/*******************************************************************
+ An aio_write wrapper that will deal with 64-bit sizes.
+********************************************************************/
+                                                                               
                                                            
+int sys_aio_write(SMB_STRUCT_AIOCB *aiocb)
+{
+#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_AIOCB64) && 
defined(HAVE_AIO_WRITE64)
+        return aio_write64(aiocb);
+#elif defined(HAVE_AIO_WRITE)
+        return aio_write(aiocb);
+#else
+       errno = ENOSYS;
+       return -1;
+#endif
+}
+
+/*******************************************************************
+ An aio_return wrapper that will deal with 64-bit sizes.
+********************************************************************/
+                                                                               
                                                            
+ssize_t sys_aio_return(SMB_STRUCT_AIOCB *aiocb)
+{
+#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_AIOCB64) && 
defined(HAVE_AIO_RETURN64)
+        return aio_return64(aiocb);
+#elif defined(HAVE_AIO_RETURN)
+        return aio_return(aiocb);
+#else
+       errno = ENOSYS;
+       return -1;
+#endif
+}
+
+/*******************************************************************
+ An aio_cancel wrapper that will deal with 64-bit sizes.
+********************************************************************/
+                                                                               
                                                            
+int sys_aio_cancel(int fd, SMB_STRUCT_AIOCB *aiocb)
+{
+#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_AIOCB64) && 
defined(HAVE_AIO_CANCEL64)
+        return aio_cancel64(aiocb);
+#elif defined(HAVE_AIO_CANCEL)
+        return aio_cancel(aiocb);
+#else
+       errno = ENOSYS;
+       return -1;
+#endif
+}

Modified: trunk/source/smbd/aio.c
===================================================================
--- trunk/source/smbd/aio.c     2005-06-08 22:10:34 UTC (rev 7415)
+++ trunk/source/smbd/aio.c     2005-06-08 23:01:38 UTC (rev 7416)
@@ -29,9 +29,6 @@
 #define RT_SIGNAL_AIO (SIGRTMIN+3)
 #endif
 
-/* Until we have detection of 64-bit aio structs... */
-#define SMB_STRUCT_AIOCB struct aiocb
-
 /****************************************************************************
  The buffer we keep around whilst an aio request is in process.
 *****************************************************************************/
@@ -208,6 +205,11 @@
                return False;
        }
 
+       /* Only do this on non-chained and non-chaining reads not using the 
write cache. */
+        if (chain_size !=0 || (CVAL(inbuf,smb_vwv0) != 0xFF) || 
(lp_write_cache_size(SNUM(conn)) != 0) ) {
+               return False;
+       }
+
        if (outstanding_aio_calls >= AIO_PENDING_SIZE) {
                DEBUG(10,("schedule_aio_read_and_X: Already have %d aio 
activities outstanding.\n",
                          outstanding_aio_calls ));
@@ -279,6 +281,11 @@
                return False;
        }
 
+       /* Only do this on non-chained and non-chaining reads not using the 
write cache. */
+        if (chain_size !=0 || (CVAL(inbuf,smb_vwv0) != 0xFF) || 
(lp_write_cache_size(SNUM(conn)) != 0) ) {
+               return False;
+       }
+
        if (outstanding_aio_calls >= AIO_PENDING_SIZE) {
                DEBUG(10,("schedule_aio_write_and_X: Already have %d aio 
activities outstanding.\n",
                          outstanding_aio_calls ));

Reply via email to