pg_fsync is fsync in WAL version.
authorVadim B. Mikheev <vadim4o@yahoo.com>
Fri, 10 Nov 2000 03:53:45 +0000 (03:53 +0000)
committerVadim B. Mikheev <vadim4o@yahoo.com>
Fri, 10 Nov 2000 03:53:45 +0000 (03:53 +0000)
src/backend/storage/buffer/xlog_bufmgr.c
src/backend/storage/file/fd.c
src/backend/storage/smgr/md.c
src/include/storage/fd.h

index f7b2922b151eb6a194ca2f2315ba59fe59ff64bd..ca0707d56046ac6c456728b296c8fd96744a96ea 100644 (file)
@@ -1065,6 +1065,9 @@ void
 BufmgrCommit(void)
 {
        LocalBufferSync();
+       /*
+        * All files created in current transaction will be fsync-ed
+        */
        smgrcommit();
 }
 
index 7fa0c6c92bff44b5068f96f9a66d837b37ddb6ed..842f64880e6a235751434baa3a7cc902d94e83a0 100644 (file)
@@ -192,6 +192,7 @@ static File fileNameOpenFile(FileName fileName, int fileFlags, int fileMode);
 static char *filepath(char *filename);
 static long pg_nofile(void);
 
+#ifndef XLOG
 /*
  * pg_fsync --- same as fsync except does nothing if -F switch was given
  */
@@ -203,6 +204,7 @@ pg_fsync(int fd)
        else
                return 0;
 }
+#endif
 
 /*
  * BasicOpenFile --- same as open(2) except can free other FDs if needed
@@ -663,7 +665,16 @@ fileNameOpenFile(FileName fileName,
        vfdP->fileFlags = fileFlags & ~(O_TRUNC | O_EXCL);
        vfdP->fileMode = fileMode;
        vfdP->seekPos = 0;
+#ifdef XLOG
+       /*
+        * Have to fsync file on commit. Alternative way - log
+        * file creation and fsync log before actual file creation.
+        */
+       if (fileFlags & O_CREAT)
+               vfdP->fdstate = FD_DIRTY;
+#else
        vfdP->fdstate = 0x0;
+#endif
 
        return file;
 }
index 961e5f058dcdeb121c285e66f012ec050fa8dc22..da6f6d16fee912f5739d29d752a8eb29ab60d4e0 100644 (file)
@@ -569,12 +569,14 @@ mdblindwrt(RelFileNode rnode,
                elog(DEBUG, "mdblindwrt: write() failed: %m");
                status = SM_FAIL;
        }
+#ifndef XLOG
        else if (dofsync &&
                         pg_fsync(fd) < 0)
        {
                elog(DEBUG, "mdblindwrt: fsync() failed: %m");
                status = SM_FAIL;
        }
+#endif
 
        if (close(fd) < 0)
        {
index fe14af5fe93e7490238d7b66d4a60ec99c797f4c..656052e3afcd88154ee1d173b2a8d66b317c1dcb 100644 (file)
@@ -70,6 +70,11 @@ extern int   BasicOpenFile(FileName fileName, int fileFlags, int fileMode);
 /* Miscellaneous support routines */
 extern void closeAllVfds(void);
 extern void AtEOXact_Files(void);
+
+#ifdef XLOG
+#define pg_fsync(fd)   fsync(fd)
+#else
 extern int     pg_fsync(int fd);
+#endif
 
 #endif  /* FD_H */