2020 */
2121#define FSYNC_FILENAME "./pg_test_fsync.out"
2222
23- #define WRITE_SIZE (8 * 1024) /* 8k */
23+ #if XLOG_BLCKSZ != 8 * 1024 /* 8k */
24+ #error Unknown block size for test.
25+ #endif
2426
2527#define LABEL_FORMAT " %-32s"
2628#define NA_FORMAT LABEL_FORMAT "%18s"
@@ -198,7 +200,7 @@ test_sync(int writes_per_op)
198200 for (ops = 0 ; ops < ops_per_test ; ops ++ )
199201 {
200202 for (writes = 0 ; writes < writes_per_op ; writes ++ )
201- if (write (tmpfile , buf , WRITE_SIZE ) != WRITE_SIZE )
203+ if (write (tmpfile , buf , XLOG_BLCKSZ ) != XLOG_BLCKSZ )
202204 die ("write failed" );
203205 if (lseek (tmpfile , 0 , SEEK_SET ) == -1 )
204206 die ("seek failed" );
@@ -225,7 +227,7 @@ test_sync(int writes_per_op)
225227 for (ops = 0 ; ops < ops_per_test ; ops ++ )
226228 {
227229 for (writes = 0 ; writes < writes_per_op ; writes ++ )
228- if (write (tmpfile , buf , WRITE_SIZE ) != WRITE_SIZE )
230+ if (write (tmpfile , buf , XLOG_BLCKSZ ) != XLOG_BLCKSZ )
229231 die ("write failed" );
230232 if (lseek (tmpfile , 0 , SEEK_SET ) == -1 )
231233 die ("seek failed" );
@@ -253,7 +255,7 @@ test_sync(int writes_per_op)
253255 for (ops = 0 ; ops < ops_per_test ; ops ++ )
254256 {
255257 for (writes = 0 ; writes < writes_per_op ; writes ++ )
256- if (write (tmpfile , buf , WRITE_SIZE ) != WRITE_SIZE )
258+ if (write (tmpfile , buf , XLOG_BLCKSZ ) != XLOG_BLCKSZ )
257259 die ("write failed" );
258260 fdatasync (tmpfile );
259261 if (lseek (tmpfile , 0 , SEEK_SET ) == -1 )
@@ -278,7 +280,7 @@ test_sync(int writes_per_op)
278280 for (ops = 0 ; ops < ops_per_test ; ops ++ )
279281 {
280282 for (writes = 0 ; writes < writes_per_op ; writes ++ )
281- if (write (tmpfile , buf , WRITE_SIZE ) != WRITE_SIZE )
283+ if (write (tmpfile , buf , XLOG_BLCKSZ ) != XLOG_BLCKSZ )
282284 die ("write failed" );
283285 if (fsync (tmpfile ) != 0 )
284286 die ("fsync failed" );
@@ -302,7 +304,7 @@ test_sync(int writes_per_op)
302304 for (ops = 0 ; ops < ops_per_test ; ops ++ )
303305 {
304306 for (writes = 0 ; writes < writes_per_op ; writes ++ )
305- if (write (tmpfile , buf , WRITE_SIZE ) != WRITE_SIZE )
307+ if (write (tmpfile , buf , XLOG_BLCKSZ ) != XLOG_BLCKSZ )
306308 die ("write failed" );
307309 if (pg_fsync_writethrough (tmpfile ) != 0 )
308310 die ("fsync failed" );
@@ -333,7 +335,7 @@ test_sync(int writes_per_op)
333335 for (ops = 0 ; ops < ops_per_test ; ops ++ )
334336 {
335337 for (writes = 0 ; writes < writes_per_op ; writes ++ )
336- if (write (tmpfile , buf , WRITE_SIZE ) != WRITE_SIZE )
338+ if (write (tmpfile , buf , XLOG_BLCKSZ ) != XLOG_BLCKSZ )
337339 die ("write failed" );
338340 if (lseek (tmpfile , 0 , SEEK_SET ) == -1 )
339341 die ("seek failed" );
@@ -360,7 +362,7 @@ test_sync(int writes_per_op)
360362 for (ops = 0 ; ops < ops_per_test ; ops ++ )
361363 {
362364 for (writes = 0 ; writes < writes_per_op ; writes ++ )
363- if (write (tmpfile , buf , WRITE_SIZE ) != WRITE_SIZE )
365+ if (write (tmpfile , buf , XLOG_BLCKSZ ) != XLOG_BLCKSZ )
364366 die ("write failed" );
365367 if (lseek (tmpfile , 0 , SEEK_SET ) == -1 )
366368 die ("seek failed" );
@@ -465,7 +467,7 @@ test_file_descriptor_sync(void)
465467 {
466468 if ((tmpfile = open (filename , O_RDWR , 0 )) == -1 )
467469 die ("could not open output file" );
468- if (write (tmpfile , buf , WRITE_SIZE ) != WRITE_SIZE )
470+ if (write (tmpfile , buf , XLOG_BLCKSZ ) != XLOG_BLCKSZ )
469471 die ("write failed" );
470472 if (fsync (tmpfile ) != 0 )
471473 die ("fsync failed" );
@@ -494,7 +496,7 @@ test_file_descriptor_sync(void)
494496 {
495497 if ((tmpfile = open (filename , O_RDWR , 0 )) == -1 )
496498 die ("could not open output file" );
497- if (write (tmpfile , buf , WRITE_SIZE ) != WRITE_SIZE )
499+ if (write (tmpfile , buf , XLOG_BLCKSZ ) != XLOG_BLCKSZ )
498500 die ("write failed" );
499501 close (tmpfile );
500502 /* reopen file */
@@ -526,7 +528,7 @@ test_non_sync(void)
526528 {
527529 if ((tmpfile = open (filename , O_RDWR , 0 )) == -1 )
528530 die ("could not open output file" );
529- if (write (tmpfile , buf , WRITE_SIZE ) != WRITE_SIZE )
531+ if (write (tmpfile , buf , XLOG_BLCKSZ ) != XLOG_BLCKSZ )
530532 die ("write failed" );
531533 close (tmpfile );
532534 }
0 commit comments