Windows: define AFS_IHANDLE_PIO_ENV for ihandle pio
[openafs.git] / src / vol / ihandle.h
index 6682af7..0bc0203 100644 (file)
  * cached by IO_CLOSE. To make sure a file descriptor is really closed call
  * IH_REALLYCLOSE.
  *
+ * Note that IH_REALLYCLOSE does not guarantee that all file descriptors are
+ * closed (or are marked as needing close) by the time it returns, in the case
+ * of an IH_OPEN being executed in parallel. If a separate thread is running
+ * an IH_OPEN on the same IHandle_t at around the same time, it is possible for
+ * it to open the file, then IH_REALLYCLOSE runs, and then IH_OPEN associates
+ * the file handle with the IHandle_t. For this reason, it is probably an
+ * error if it is ever possible to have an IH_OPEN call run at the same time as
+ * an IH_REALLYCLOSE call on the same IHandle_t. If such functionality is
+ * required, ihandle must be changed to accomodate this.
+ *
  * The IHandle_t also provides a place to do other optimizations. In the
  * NT user space file system, we keep a separate special file for the
  * link counts and using the IHandle_t allows keeping the details of
@@ -337,6 +347,7 @@ extern int stream_close(StreamHandle_t * streamP, int reallyClose);
 extern int ih_reallyclose(IHandle_t * ihP);
 extern int ih_release(IHandle_t * ihP);
 extern int ih_condsync(IHandle_t * ihP);
+extern FdHandle_t *ih_attachfd(IHandle_t * ihP, FD_t fd);
 
 /* Macros common to user space and inode API's. */
 #define IH_INIT(H, D, V, I) ((H) = ih_init((D), (V), (I)))
@@ -347,9 +358,9 @@ extern int ih_condsync(IHandle_t * ihP);
 
 #define IH_OPEN(H) ih_open(H)
 
-#define FDH_CLOSE(H) (fd_close(H), (H)=NULL, 0)
+#define FDH_CLOSE(H) (fd_close(H), (H)=NULL)
 
-#define FDH_REALLYCLOSE(H) (fd_reallyclose(H), (H)=NULL, 0)
+#define FDH_REALLYCLOSE(H) (fd_reallyclose(H), (H)=NULL)
 
 #define FDH_FDOPEN(H, A) stream_fdopen((H)->fd_fd)
 
@@ -373,31 +384,31 @@ extern int ih_condsync(IHandle_t * ihP);
 
 #define STREAM_REALLYCLOSE(H) stream_close(H, 1)
 
-#define IH_RELEASE(H) (ih_release(H), (H)=NULL, 0)
+#define IH_RELEASE(H) (ih_release(H), (H)=NULL)
 
 #define IH_REALLYCLOSE(H) ih_reallyclose(H)
 
 #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))
@@ -419,6 +430,11 @@ extern int ih_isunlinked(FD_t fd);
 # define OS_DIRSEPC '/'
 #endif
 
+#if defined(AFS_NT40_ENV) || !defined(AFS_NAMEI_ENV)
+# define  IH_CREATE_INIT(H, D, P, N, P1, P2, P3, P4) \
+         ih_icreate_init(H, D, P, N, P1, P2, P3, P4)
+#endif
+
 #ifdef AFS_NAMEI_ENV
 
 # ifdef AFS_NT40_ENV
@@ -484,6 +500,8 @@ extern int OS_TRUNC(FD_t FD, OFFT L);
 #  endif /* !O_LARGEFILE */
 
 #  define OS_SYNC(FD) fsync(FD)
+#  define IH_CREATE_INIT(H, D, P, N, P1, P2, P3, P4) \
+          namei_icreate_init(H, D, P, P1, P2, P3, P4)
 
 /*@=fcnmacros =macrofcndecl@*/
 # endif /* AFS_NT40_ENV */