Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 92875e6

Browse files
committed
pg_fsync is fsync in WAL version.
1 parent ddeab22 commit 92875e6

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

src/backend/storage/buffer/xlog_bufmgr.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/Attic/xlog_bufmgr.c,v 1.2 2000/11/08 22:09:59 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/Attic/xlog_bufmgr.c,v 1.3 2000/11/10 03:53:44 vadim Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1065,6 +1065,9 @@ void
10651065
BufmgrCommit(void)
10661066
{
10671067
LocalBufferSync();
1068+
/*
1069+
* All files created in current transaction will be fsync-ed
1070+
*/
10681071
smgrcommit();
10691072
}
10701073

src/backend/storage/file/fd.c

+12-1
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.65 2000/10/28 16:20:56 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.66 2000/11/10 03:53:44 vadim Exp $
1111
*
1212
* NOTES:
1313
*
@@ -192,6 +192,7 @@ static File fileNameOpenFile(FileName fileName, int fileFlags, int fileMode);
192192
static char *filepath(char *filename);
193193
static long pg_nofile(void);
194194

195+
#ifndef XLOG
195196
/*
196197
* pg_fsync --- same as fsync except does nothing if -F switch was given
197198
*/
@@ -203,6 +204,7 @@ pg_fsync(int fd)
203204
else
204205
return 0;
205206
}
207+
#endif
206208

207209
/*
208210
* BasicOpenFile --- same as open(2) except can free other FDs if needed
@@ -663,7 +665,16 @@ fileNameOpenFile(FileName fileName,
663665
vfdP->fileFlags = fileFlags & ~(O_TRUNC | O_EXCL);
664666
vfdP->fileMode = fileMode;
665667
vfdP->seekPos = 0;
668+
#ifdef XLOG
669+
/*
670+
* Have to fsync file on commit. Alternative way - log
671+
* file creation and fsync log before actual file creation.
672+
*/
673+
if (fileFlags & O_CREAT)
674+
vfdP->fdstate = FD_DIRTY;
675+
#else
666676
vfdP->fdstate = 0x0;
677+
#endif
667678

668679
return file;
669680
}

src/backend/storage/smgr/md.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.78 2000/11/08 22:10:00 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.79 2000/11/10 03:53:45 vadim Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -569,12 +569,14 @@ mdblindwrt(RelFileNode rnode,
569569
elog(DEBUG, "mdblindwrt: write() failed: %m");
570570
status = SM_FAIL;
571571
}
572+
#ifndef XLOG
572573
else if (dofsync &&
573574
pg_fsync(fd) < 0)
574575
{
575576
elog(DEBUG, "mdblindwrt: fsync() failed: %m");
576577
status = SM_FAIL;
577578
}
579+
#endif
578580

579581
if (close(fd) < 0)
580582
{

src/include/storage/fd.h

+6-1
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.22 2000/06/02 03:58:31 tgl Exp $
10+
* $Id: fd.h,v 1.23 2000/11/10 03:53:45 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -70,6 +70,11 @@ 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+
#ifdef XLOG
75+
#define pg_fsync(fd) fsync(fd)
76+
#else
7377
extern int pg_fsync(int fd);
78+
#endif
7479

7580
#endif /* FD_H */

0 commit comments

Comments
 (0)