Author: jra Date: 2005-06-09 00:13:10 +0000 (Thu, 09 Jun 2005) New Revision: 7417
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7417 Log: Added autoconf option to turn on aio calls. --with-aio-support. Works on Linux - other systems please look at the configure.in tests and adjust accordingly. Jeremy Modified: trunk/source/configure.in trunk/source/include/includes.h trunk/source/lib/system.c trunk/source/smbd/aio.c Changeset: Modified: trunk/source/configure.in =================================================================== --- trunk/source/configure.in 2005-06-08 23:01:38 UTC (rev 7416) +++ trunk/source/configure.in 2005-06-09 00:13:10 UTC (rev 7417) @@ -1034,8 +1034,6 @@ AC_CHECK_FUNCS(syslog vsyslog timegm) AC_CHECK_FUNCS(setlocale nl_langinfo) AC_CHECK_FUNCS(nanosleep) -AC_CHECK_FUNCS(aio_cancel aio_cancel64 aio_error aio_error64 aio_fsync aio_fsync64 aio_read aio_read64) -AC_CHECK_FUNCS(aio_return aio_return64 aio_suspend aio_suspend64 aio_write aio_write64) # setbuffer, shmget, shm_open are needed for smbtorture AC_CHECK_FUNCS(setbuffer shmget shm_open backtrace_symbols) AC_CHECK_HEADERS(libexc.h) @@ -4048,6 +4046,57 @@ ) ################################################# +# check for AIO support + +AC_MSG_CHECKING(whether to support asynchronous io) +AC_ARG_WITH(aio-support, +[ --with-aio-support Include asynchronous io support (default=no)], +[ case "$withval" in + yes) + + case "$host_os" in + *) + AC_CHECK_LIB(rt,aio_read,[AIO_LIBS="$ACL_LIBS -lrt"]) + AC_CACHE_CHECK([for asynchronous io support],samba_cv_HAVE_AIO,[ + aio_LIBS=$LIBS + LIBS="$LIBS -lrt" + AC_TRY_LINK([#include <sys/types.h> +#include <aio.h>], +[ struct aiocb a; return aio_read(&a);], +samba_cv_HAVE_AIO=yes,samba_cv_HAVE_AIO=no) + LIBS=$aio_LIBS]) + AC_CACHE_CHECK([for 64-bit asynchronous io support],samba_cv_HAVE_AIO64,[ + aio_LIBS=$LIBS + LIBS="$LIBS -lrt" + AC_TRY_LINK([#include <sys/types.h> +#include <aio.h>], +[ struct aiocb64 a; return aio_read64(&a);], +samba_cv_HAVE_AIO64=yes,samba_cv_HAVE_AIO64=no) + LIBS=$aio_LIBS]) + if test x"$samba_cv_HAVE_AIO64" = x"yes"; then + AC_DEFINE(HAVE_AIOCB64,1,[Whether 64 bit aio is available]) + AC_DEFINE(WITH_AIO, 1, [Using asynchronous io]) + LIBS="$LIBS -lrt" + elif test x"$samba_cv_HAVE_AIO" = x"yes"; then + AC_DEFINE(WITH_AIO, 1, [Using asynchronous io]) + LIBS="$LIBS -lrt" + fi + ;; + esac + ;; + *) + AC_MSG_RESULT(no) + AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support is available]) + ;; + esac ], + AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support should be built in]) + AC_MSG_RESULT(no) +) + +AC_CHECK_FUNCS(aio_cancel aio_cancel64 aio_error aio_error64 aio_fsync aio_fsync64 aio_read aio_read64) +AC_CHECK_FUNCS(aio_return aio_return64 aio_suspend aio_suspend64 aio_write aio_write64) + +################################################# # check for sendfile support with_sendfile_support=yes Modified: trunk/source/include/includes.h =================================================================== --- trunk/source/include/includes.h 2005-06-08 23:01:38 UTC (rev 7416) +++ trunk/source/include/includes.h 2005-06-09 00:13:10 UTC (rev 7417) @@ -770,10 +770,14 @@ */ #ifndef SMB_STRUCT_AIOCB -# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_AIOCB64) -# define SMB_STRUCT_AIOCB struct aiocb64 +# if defined(WITH_AIO) +# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_AIOCB64) +# define SMB_STRUCT_AIOCB struct aiocb64 +# else +# define SMB_STRUCT_AIOCB struct aiocb +# endif # else -# define SMB_STRUCT_AIOCB struct aiocb +# define SMB_STRUCT_AIOCB int /* AIO not being used but we still need the define.... */ # endif #endif Modified: trunk/source/lib/system.c =================================================================== --- trunk/source/lib/system.c 2005-06-08 23:01:38 UTC (rev 7416) +++ trunk/source/lib/system.c 2005-06-09 00:13:10 UTC (rev 7417) @@ -1847,6 +1847,8 @@ #endif } +#if defined(WITH_AIO) + /******************************************************************* An aio_read wrapper that will deal with 64-bit sizes. ********************************************************************/ @@ -1902,11 +1904,37 @@ 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); + return aio_cancel64(fd, aiocb); #elif defined(HAVE_AIO_CANCEL) - return aio_cancel(aiocb); + return aio_cancel(fd, aiocb); #else errno = ENOSYS; return -1; #endif } + +#else /* !WITH_AIO */ +int sys_aio_read(SMB_STRUCT_AIOCB *aiocb) +{ + errno = ENOSYS; + return -1; +} + +int sys_aio_write(SMB_STRUCT_AIOCB *aiocb) +{ + errno = ENOSYS; + return -1; +} + +ssize_t sys_aio_return(SMB_STRUCT_AIOCB *aiocb) +{ + errno = ENOSYS; + return -1; +} + +int sys_aio_cancel(int fd, SMB_STRUCT_AIOCB *aiocb) +{ + errno = ENOSYS; + return -1; +} +#endif /* WITH_AIO */ Modified: trunk/source/smbd/aio.c =================================================================== --- trunk/source/smbd/aio.c 2005-06-08 23:01:38 UTC (rev 7416) +++ trunk/source/smbd/aio.c 2005-06-09 00:13:10 UTC (rev 7417) @@ -21,8 +21,7 @@ #include "includes.h" -/* #define HAVE_POSIX_ASYNC_IO 1 */ -#if HAVE_POSIX_ASYNC_IO +#if defined(WITH_AIO) /* The signal we'll use to signify aio done. */ #ifndef RT_SIGNAL_AIO @@ -241,7 +240,7 @@ a->aio_sigevent.sigev_signo = RT_SIGNAL_AIO; a->aio_sigevent.sigev_value.sival_ptr = (void *)&aio_ex->mid; - if (aio_read(a) == -1) { + if (sys_aio_read(a) == -1) { DEBUG(0,("schedule_aio_read_and_X: aio_read failed. Error %s\n", strerror(errno) )); delete_aio_ex(aio_ex); @@ -317,7 +316,7 @@ a->aio_sigevent.sigev_signo = RT_SIGNAL_AIO; a->aio_sigevent.sigev_value.sival_ptr = (void *)&aio_ex->mid; - if (aio_write(a) == -1) { + if (sys_aio_write(a) == -1) { DEBUG(0,("schedule_aio_read_and_X: aio_write failed. Error %s\n", strerror(errno) )); /* Replace global InBuf as we're going to do a normal write. */ @@ -345,7 +344,7 @@ int outsize; char *outbuf = aio_ex->outbuf; char *data = smb_buf(outbuf); - ssize_t nread = aio_return(&aio_ex->acb); + ssize_t nread = sys_aio_return(&aio_ex->acb); if (aio_ex->fsp == NULL) { /* file was closed whilst I/O was outstanding. Just ignore. */ @@ -400,7 +399,7 @@ static void handle_aio_write_complete(struct aio_extra *aio_ex) { char *outbuf = aio_ex->outbuf; - ssize_t nwritten = aio_return(&aio_ex->acb); + ssize_t nwritten = sys_aio_return(&aio_ex->acb); ssize_t numtowrite = aio_ex->acb.aio_nbytes; if (aio_ex->fsp == NULL) { @@ -503,7 +502,7 @@ if (aio_ex->fsp == fsp) { /* Don't delete the aio_extra record as we may have completed and don't yet know it. Just do the aio_cancel call and return. */ - aio_cancel(fsp->fd, &aio_ex->acb); + sys_aio_cancel(fsp->fd, &aio_ex->acb); aio_ex->fsp = NULL; /* fsp will be closed when we return. */ } }
