aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/access/transam/xlog.c18
-rw-r--r--src/backend/storage/file/fd.c14
-rw-r--r--src/include/storage/fd.h5
3 files changed, 24 insertions, 13 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index e1a8ef97d17..cf65dc0d46e 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.39 2000/12/03 10:27:26 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.40 2000/12/08 22:21:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -621,7 +621,7 @@ XLogFlush(XLogRecPtr record)
logFile = XLogFileOpen(logId, logSeg, false);
}
- if (fsync(logFile) != 0)
+ if (pg_fsync(logFile) != 0)
elog(STOP, "fsync(logfile %u seg %u) failed: %m",
logId, logSeg);
LgwrResult.Flush = LgwrResult.Write;
@@ -717,7 +717,7 @@ XLogWrite(char *buffer)
{
if (wcnt > 0)
{
- if (fsync(logFile) != 0)
+ if (pg_fsync(logFile) != 0)
elog(STOP, "fsync(logfile %u seg %u) failed: %m",
logId, logSeg);
if (LgwrResult.Write.xlogid != logId)
@@ -799,7 +799,7 @@ XLogWrite(char *buffer)
if (XLByteLT(LgwrResult.Flush, LgwrRqst.Flush) &&
XLByteLE(LgwrRqst.Flush, LgwrResult.Write))
{
- if (fsync(logFile) != 0)
+ if (pg_fsync(logFile) != 0)
elog(STOP, "fsync(logfile %u seg %u) failed: %m",
logId, logSeg);
LgwrResult.Flush = LgwrResult.Write;
@@ -864,7 +864,7 @@ XLogFileInit(uint32 log, uint32 seg, bool *usexistent)
elog(STOP, "write(logfile %u seg %u) failed: %m",
logId, logSeg);
- if (fsync(fd) != 0)
+ if (pg_fsync(fd) != 0)
elog(STOP, "fsync(logfile %u seg %u) failed: %m",
logId, logSeg);
@@ -1213,7 +1213,7 @@ next_record_is_invalid:;
}
if (readFile >= 0)
{
- if (fsync(readFile) < 0)
+ if (pg_fsync(readFile) < 0)
elog(STOP, "ReadRecord: fsync(logfile %u seg %u) failed: %m",
readId, readSeg);
close(readFile);
@@ -1330,7 +1330,7 @@ WriteControlFile(void)
if (write(fd, buffer, BLCKSZ) != BLCKSZ)
elog(STOP, "WriteControlFile failed to write control file: %m");
- if (fsync(fd) != 0)
+ if (pg_fsync(fd) != 0)
elog(STOP, "WriteControlFile failed to fsync control file: %m");
close(fd);
@@ -1400,7 +1400,7 @@ UpdateControlFile(void)
if (write(fd, ControlFile, sizeof(ControlFileData)) != sizeof(ControlFileData))
elog(STOP, "write(cntlfile) failed: %m");
- if (fsync(fd) != 0)
+ if (pg_fsync(fd) != 0)
elog(STOP, "fsync(cntlfile) failed: %m");
close(fd);
@@ -1489,7 +1489,7 @@ BootStrapXLOG()
if (write(logFile, buffer, BLCKSZ) != BLCKSZ)
elog(STOP, "BootStrapXLOG failed to write logfile: %m");
- if (fsync(logFile) != 0)
+ if (pg_fsync(logFile) != 0)
elog(STOP, "BootStrapXLOG failed to fsync logfile: %m");
close(logFile);
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index f46c04c4b6f..3cff7932129 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.68 2000/11/30 08:46:23 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.69 2000/12/08 22:21:32 tgl Exp $
*
* NOTES:
*
@@ -193,6 +193,18 @@ static char *filepath(char *filename);
static long pg_nofile(void);
/*
+ * pg_fsync --- same as fsync except does nothing if -F switch was given
+ */
+int
+pg_fsync(int fd)
+{
+ if (enableFsync)
+ return fsync(fd);
+ else
+ return 0;
+}
+
+/*
* BasicOpenFile --- same as open(2) except can free other FDs if needed
*
* This is exported for use by places that really want a plain kernel FD,
diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h
index c4b1a85c354..d3905df41ed 100644
--- a/src/include/storage/fd.h
+++ b/src/include/storage/fd.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: fd.h,v 1.24 2000/11/30 08:46:26 vadim Exp $
+ * $Id: fd.h,v 1.25 2000/12/08 22:21:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -70,7 +70,6 @@ extern int BasicOpenFile(FileName fileName, int fileFlags, int fileMode);
/* Miscellaneous support routines */
extern void closeAllVfds(void);
extern void AtEOXact_Files(void);
-
-#define pg_fsync(fd) fsync(fd)
+extern int pg_fsync(int fd);
#endif /* FD_H */