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)
198200for (ops = 0 ;ops < ops_per_test ;ops ++ )
199201{
200202for (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 )
202204die ("write failed" );
203205if (lseek (tmpfile ,0 ,SEEK_SET )== -1 )
204206die ("seek failed" );
@@ -225,7 +227,7 @@ test_sync(int writes_per_op)
225227for (ops = 0 ;ops < ops_per_test ;ops ++ )
226228{
227229for (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 )
229231die ("write failed" );
230232if (lseek (tmpfile ,0 ,SEEK_SET )== -1 )
231233die ("seek failed" );
@@ -253,7 +255,7 @@ test_sync(int writes_per_op)
253255for (ops = 0 ;ops < ops_per_test ;ops ++ )
254256{
255257for (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 )
257259die ("write failed" );
258260fdatasync (tmpfile );
259261if (lseek (tmpfile ,0 ,SEEK_SET )== -1 )
@@ -278,7 +280,7 @@ test_sync(int writes_per_op)
278280for (ops = 0 ;ops < ops_per_test ;ops ++ )
279281{
280282for (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 )
282284die ("write failed" );
283285if (fsync (tmpfile )!= 0 )
284286die ("fsync failed" );
@@ -302,7 +304,7 @@ test_sync(int writes_per_op)
302304for (ops = 0 ;ops < ops_per_test ;ops ++ )
303305{
304306for (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 )
306308die ("write failed" );
307309if (pg_fsync_writethrough (tmpfile )!= 0 )
308310die ("fsync failed" );
@@ -333,7 +335,7 @@ test_sync(int writes_per_op)
333335for (ops = 0 ;ops < ops_per_test ;ops ++ )
334336{
335337for (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 )
337339die ("write failed" );
338340if (lseek (tmpfile ,0 ,SEEK_SET )== -1 )
339341die ("seek failed" );
@@ -360,7 +362,7 @@ test_sync(int writes_per_op)
360362for (ops = 0 ;ops < ops_per_test ;ops ++ )
361363{
362364for (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 )
364366die ("write failed" );
365367if (lseek (tmpfile ,0 ,SEEK_SET )== -1 )
366368die ("seek failed" );
@@ -465,7 +467,7 @@ test_file_descriptor_sync(void)
465467{
466468if ((tmpfile = open (filename ,O_RDWR ,0 ))== -1 )
467469die ("could not open output file" );
468- if (write (tmpfile ,buf ,WRITE_SIZE )!= WRITE_SIZE )
470+ if (write (tmpfile ,buf ,XLOG_BLCKSZ )!= XLOG_BLCKSZ )
469471die ("write failed" );
470472if (fsync (tmpfile )!= 0 )
471473die ("fsync failed" );
@@ -494,7 +496,7 @@ test_file_descriptor_sync(void)
494496{
495497if ((tmpfile = open (filename ,O_RDWR ,0 ))== -1 )
496498die ("could not open output file" );
497- if (write (tmpfile ,buf ,WRITE_SIZE )!= WRITE_SIZE )
499+ if (write (tmpfile ,buf ,XLOG_BLCKSZ )!= XLOG_BLCKSZ )
498500die ("write failed" );
499501close (tmpfile );
500502/* reopen file */
@@ -526,7 +528,7 @@ test_non_sync(void)
526528{
527529if ((tmpfile = open (filename ,O_RDWR ,0 ))== -1 )
528530die ("could not open output file" );
529- if (write (tmpfile ,buf ,WRITE_SIZE )!= WRITE_SIZE )
531+ if (write (tmpfile ,buf ,XLOG_BLCKSZ )!= XLOG_BLCKSZ )
530532die ("write failed" );
531533close (tmpfile );
532534}