From: Michael Meffie Date: Mon, 25 Apr 2016 15:19:10 +0000 (-0400) Subject: Windows: define AFS_IHANDLE_PIO_ENV for ihandle pio X-Git-Tag: upstream/1.8.1_pre2^2~28 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=37daf101007e92038560913b56ac0330fce3d230;p=packages%2Fo%2Fopenafs.git Windows: define AFS_IHANDLE_PIO_ENV for ihandle pio Support for positional i/o in the ihandle package was added to the windows platform in commit 50b6a116a1c412d0e6d7442d13d6e92c9dbb35ee using native windows functions. That commit also defined HAVE_PIO in the windows version of the afsconfig.h file. Unfortunately, that definition of HAVE_PIO is not limited to the ihandle package. Remove the project-wide HAVE_PIO definition from the windows afsconfig.h file and define the new AFS_IHANDLE_PIO_ENV symbol when position i/o support is available in the ihandle package. Build the fallback ih_pread and ih_pwrite functions (which use lseek) only when positional i/o is not available in the ihandle package for the current platform. Use AFS_IHANDLE_PIO_ENV instead of HAVE_PIO in ih_open() to determine when it is is safe to share ihandles among threads. Reviewed-on: https://gerrit.openafs.org/12270 Reviewed-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Michael Meffie Reviewed-by: Mark Vitale Reviewed-by: Benjamin Kaduk (cherry picked from commit 759f29cfdfabed4dc5c1b96a0b2b79a3f83c08e3) Change-Id: Ic64f9e65b10fbe6f7650eff852d5a7e20762ef10 Reviewed-on: https://gerrit.openafs.org/13148 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- diff --git a/src/config/afsconfig-windows.h b/src/config/afsconfig-windows.h index 6e6a6c2ea..ca53a1832 100644 --- a/src/config/afsconfig-windows.h +++ b/src/config/afsconfig-windows.h @@ -163,7 +163,7 @@ #undef HAVE_VFS_DQRWLOCK /* define if you have pread() and pwrite() */ -#define HAVE_PIO 1 +#undef HAVE_PIO #undef PACKAGE #undef VERSION diff --git a/src/vol/ihandle.c b/src/vol/ihandle.c index 3144b702f..c32ae758c 100644 --- a/src/vol/ihandle.c +++ b/src/vol/ihandle.c @@ -433,7 +433,7 @@ ih_open(IHandle_t * ihP) * cannot reuse it; it will be closed soon. */ continue; } -#ifndef HAVE_PIO +#ifndef AFS_IHANDLE_PIO_ENV /* * If we don't have positional i/o, don't try to share fds, since * we can't do so in a threadsafe way. @@ -442,9 +442,9 @@ ih_open(IHandle_t * ihP) continue; } opr_Assert(fdP->fd_status == FD_HANDLE_OPEN); -#else /* HAVE_PIO */ +#else /* AFS_IHANDLE_PIO_ENV */ opr_Assert(fdP->fd_status != FD_HANDLE_AVAIL); -#endif /* HAVE_PIO */ +#endif /* AFS_IHANDLE_PIO_ENV */ fdP->fd_refcnt++; if (fdP->fd_status == FD_HANDLE_OPEN) { @@ -1092,7 +1092,7 @@ ih_size(FD_t fd) #endif } -#ifndef HAVE_PIO +#ifndef AFS_IHANDLE_PIO_ENV ssize_t ih_pread(int fd, void * buf, size_t count, afs_foff_t offset) { @@ -1112,7 +1112,7 @@ ih_pwrite(int fd, const void * buf, size_t count, afs_foff_t offset) return code; return OS_WRITE(fd, buf, count); } -#endif /* !HAVE_PIO */ +#endif /* !AFS_IHANDLE_PIO_ENV */ #ifndef AFS_NT40_ENV int diff --git a/src/vol/ihandle.h b/src/vol/ihandle.h index a37898e4e..0bc0203d5 100644 --- a/src/vol/ihandle.h +++ b/src/vol/ihandle.h @@ -391,24 +391,24 @@ extern FdHandle_t *ih_attachfd(IHandle_t * ihP, FD_t fd); #define IH_CONDSYNC(H) ih_condsync(H) #ifdef HAVE_PIO -# ifdef AFS_NT40_ENV -# define OS_PREAD(FD, B, S, O) nt_pread(FD, B, S, O) -# define OS_PWRITE(FD, B, S, O) nt_pwrite(FD, B, S, O) -# else -# ifdef O_LARGEFILE -# define OS_PREAD(FD, B, S, O) pread64(FD, B, S, O) -# define OS_PWRITE(FD, B, S, O) pwrite64(FD, B, S, O) -# else /* !O_LARGEFILE */ -# define OS_PREAD(FD, B, S, O) pread(FD, B, S, O) -# define OS_PWRITE(FD, B, S, O) pwrite(FD, B, S, O) -# endif /* !O_LARGEFILE */ -# endif /* AFS_NT40_ENV */ -#else /* !HAVE_PIO */ +# define AFS_IHANDLE_PIO_ENV 1 +# ifdef O_LARGEFILE +# define OS_PREAD(FD, B, S, O) pread64(FD, B, S, O) +# define OS_PWRITE(FD, B, S, O) pwrite64(FD, B, S, O) +# else /* !O_LARGEFILE */ +# define OS_PREAD(FD, B, S, O) pread(FD, B, S, O) +# define OS_PWRITE(FD, B, S, O) pwrite(FD, B, S, O) +# endif /* !O_LARGEFILE */ +#elif defined(AFS_NT40_ENV) +# define AFS_IHANDLE_PIO_ENV 1 +# define OS_PREAD(FD, B, S, O) nt_pread(FD, B, S, O) +# define OS_PWRITE(FD, B, S, O) nt_pwrite(FD, B, S, O) +#else extern ssize_t ih_pread(FD_t fd, void * buf, size_t count, afs_foff_t offset); extern ssize_t ih_pwrite(FD_t fd, const void * buf, size_t count, afs_foff_t offset); # define OS_PREAD(FD, B, S, O) ih_pread(FD, B, S, O) # define OS_PWRITE(FD, B, S, O) ih_pwrite(FD, B, S, O) -#endif /* !HAVE_PIO */ +#endif #ifdef AFS_NT40_ENV # define OS_LOCKFILE(FD, O) (!LockFile(FD, (DWORD)((O) & 0xFFFFFFFF), (DWORD)((O) >> 32), 2, 0))