Windows: define AFS_IHANDLE_PIO_ENV for ihandle pio 48/13148/2
authorMichael Meffie <mmeffie@sinenomine.net>
Mon, 25 Apr 2016 15:19:10 +0000 (11:19 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 8 Jun 2018 12:39:51 +0000 (08:39 -0400)
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 <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 759f29cfdfabed4dc5c1b96a0b2b79a3f83c08e3)

Change-Id: Ic64f9e65b10fbe6f7650eff852d5a7e20762ef10
Reviewed-on: https://gerrit.openafs.org/13148
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/config/afsconfig-windows.h
src/vol/ihandle.c
src/vol/ihandle.h

index 6e6a6c2..ca53a18 100644 (file)
 #undef HAVE_VFS_DQRWLOCK
 
 /* define if you have pread() and pwrite() */
-#define HAVE_PIO 1
+#undef HAVE_PIO
 
 #undef PACKAGE
 #undef VERSION
index 3144b70..c32ae75 100644 (file)
@@ -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
index a37898e..0bc0203 100644 (file)
@@ -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))