Skip to content

Commit fb47385

Browse files
committed
Resurrect -F switch: it controls fsyncs again, though the fsyncs are
mostly just on the WAL logfile nowadays. But if people want to disable fsync for performance, why should we say no?
1 parent 57c499a commit fb47385

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

src/backend/access/transam/xlog.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.39 2000/12/03 10:27:26 vadim Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.40 2000/12/08 22:21:33 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -621,7 +621,7 @@ XLogFlush(XLogRecPtr record)
621621
logFile = XLogFileOpen(logId, logSeg, false);
622622
}
623623

624-
if (fsync(logFile) != 0)
624+
if (pg_fsync(logFile) != 0)
625625
elog(STOP, "fsync(logfile %u seg %u) failed: %m",
626626
logId, logSeg);
627627
LgwrResult.Flush = LgwrResult.Write;
@@ -717,7 +717,7 @@ XLogWrite(char *buffer)
717717
{
718718
if (wcnt > 0)
719719
{
720-
if (fsync(logFile) != 0)
720+
if (pg_fsync(logFile) != 0)
721721
elog(STOP, "fsync(logfile %u seg %u) failed: %m",
722722
logId, logSeg);
723723
if (LgwrResult.Write.xlogid != logId)
@@ -799,7 +799,7 @@ XLogWrite(char *buffer)
799799
if (XLByteLT(LgwrResult.Flush, LgwrRqst.Flush) &&
800800
XLByteLE(LgwrRqst.Flush, LgwrResult.Write))
801801
{
802-
if (fsync(logFile) != 0)
802+
if (pg_fsync(logFile) != 0)
803803
elog(STOP, "fsync(logfile %u seg %u) failed: %m",
804804
logId, logSeg);
805805
LgwrResult.Flush = LgwrResult.Write;
@@ -864,7 +864,7 @@ XLogFileInit(uint32 log, uint32 seg, bool *usexistent)
864864
elog(STOP, "write(logfile %u seg %u) failed: %m",
865865
logId, logSeg);
866866

867-
if (fsync(fd) != 0)
867+
if (pg_fsync(fd) != 0)
868868
elog(STOP, "fsync(logfile %u seg %u) failed: %m",
869869
logId, logSeg);
870870

@@ -1213,7 +1213,7 @@ next_record_is_invalid:;
12131213
}
12141214
if (readFile >= 0)
12151215
{
1216-
if (fsync(readFile) < 0)
1216+
if (pg_fsync(readFile) < 0)
12171217
elog(STOP, "ReadRecord: fsync(logfile %u seg %u) failed: %m",
12181218
readId, readSeg);
12191219
close(readFile);
@@ -1330,7 +1330,7 @@ WriteControlFile(void)
13301330
if (write(fd, buffer, BLCKSZ) != BLCKSZ)
13311331
elog(STOP, "WriteControlFile failed to write control file: %m");
13321332

1333-
if (fsync(fd) != 0)
1333+
if (pg_fsync(fd) != 0)
13341334
elog(STOP, "WriteControlFile failed to fsync control file: %m");
13351335

13361336
close(fd);
@@ -1400,7 +1400,7 @@ UpdateControlFile(void)
14001400
if (write(fd, ControlFile, sizeof(ControlFileData)) != sizeof(ControlFileData))
14011401
elog(STOP, "write(cntlfile) failed: %m");
14021402

1403-
if (fsync(fd) != 0)
1403+
if (pg_fsync(fd) != 0)
14041404
elog(STOP, "fsync(cntlfile) failed: %m");
14051405

14061406
close(fd);
@@ -1489,7 +1489,7 @@ BootStrapXLOG()
14891489
if (write(logFile, buffer, BLCKSZ) != BLCKSZ)
14901490
elog(STOP, "BootStrapXLOG failed to write logfile: %m");
14911491

1492-
if (fsync(logFile) != 0)
1492+
if (pg_fsync(logFile) != 0)
14931493
elog(STOP, "BootStrapXLOG failed to fsync logfile: %m");
14941494

14951495
close(logFile);

src/backend/storage/file/fd.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.68 2000/11/30 08:46:23 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.69 2000/12/08 22:21:32 tgl Exp $
1111
*
1212
* NOTES:
1313
*
@@ -192,6 +192,18 @@ static File fileNameOpenFile(FileName fileName, int fileFlags, int fileMode);
192192
static char *filepath(char *filename);
193193
static long pg_nofile(void);
194194

195+
/*
196+
* pg_fsync --- same as fsync except does nothing if -F switch was given
197+
*/
198+
int
199+
pg_fsync(int fd)
200+
{
201+
if (enableFsync)
202+
return fsync(fd);
203+
else
204+
return 0;
205+
}
206+
195207
/*
196208
* BasicOpenFile --- same as open(2) except can free other FDs if needed
197209
*

src/include/storage/fd.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: fd.h,v 1.24 2000/11/30 08:46:26 vadim Exp $
10+
* $Id: fd.h,v 1.25 2000/12/08 22:21:32 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -70,7 +70,6 @@ extern int BasicOpenFile(FileName fileName, int fileFlags, int fileMode);
7070
/* Miscellaneous support routines */
7171
extern void closeAllVfds(void);
7272
extern void AtEOXact_Files(void);
73-
74-
#define pg_fsync(fd) fsync(fd)
73+
extern int pg_fsync(int fd);
7574

7675
#endif /* FD_H */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy