163
163
test_sync (int writes_per_op )
164
164
{
165
165
int tmpfile , ops , writes ;
166
-
166
+ bool fs_warning = false;
167
+
167
168
if (writes_per_op == 1 )
168
169
printf ("\nCompare file sync methods using one write:\n" );
169
170
else
@@ -176,9 +177,17 @@ test_sync(int writes_per_op)
176
177
*/
177
178
#ifdef OPEN_DATASYNC_FLAG
178
179
if (writes_per_op == 1 )
179
- printf (LABEL_FORMAT , "open_datasync 8k write" );
180
+ printf (LABEL_FORMAT , "open_datasync 8k write"
181
+ #if PG_O_DIRECT != 0
182
+ "**"
183
+ #endif
184
+ );
180
185
else
181
- printf (LABEL_FORMAT , "2 open_datasync 8k writes" );
186
+ printf (LABEL_FORMAT , "2 open_datasync 8k writes"
187
+ #if PG_O_DIRECT != 0
188
+ "**"
189
+ #endif
190
+ );
182
191
fflush (stdout );
183
192
184
193
if ((tmpfile = open (filename , O_RDWR | O_DSYNC , 0 )) == -1 )
@@ -201,7 +210,10 @@ test_sync(int writes_per_op)
201
210
*/
202
211
#if PG_O_DIRECT != 0
203
212
if ((tmpfile = open (filename , O_RDWR | O_DSYNC | PG_O_DIRECT , 0 )) == -1 )
204
- printf (NA_FORMAT , "o_direct" , "n/a on this filesystem\n" );
213
+ {
214
+ printf (NA_FORMAT , "o_direct" , "n/a*\n" );
215
+ fs_warning = true;
216
+ }
205
217
else
206
218
{
207
219
if (writes_per_op == 1 )
@@ -321,9 +333,17 @@ test_sync(int writes_per_op)
321
333
*/
322
334
#ifdef OPEN_SYNC_FLAG
323
335
if (writes_per_op == 1 )
324
- printf (LABEL_FORMAT , "open_sync 8k write" );
336
+ printf (LABEL_FORMAT , "open_sync 8k write"
337
+ #if PG_O_DIRECT != 0
338
+ "**"
339
+ #endif
340
+ );
325
341
else
326
- printf (LABEL_FORMAT , "2 open_sync 8k writes" );
342
+ printf (LABEL_FORMAT , "2 open_sync 8k writes"
343
+ #if PG_O_DIRECT != 0
344
+ "**"
345
+ #endif
346
+ );
327
347
fflush (stdout );
328
348
329
349
if ((tmpfile = open (filename , O_RDWR | OPEN_SYNC_FLAG , 0 )) == -1 )
@@ -352,7 +372,10 @@ test_sync(int writes_per_op)
352
372
fflush (stdout );
353
373
354
374
if ((tmpfile = open (filename , O_RDWR | OPEN_SYNC_FLAG | PG_O_DIRECT , 0 )) == -1 )
355
- printf (NA_FORMAT , "o_direct" , "n/a on this filesystem\n" );
375
+ {
376
+ printf (NA_FORMAT , "o_direct" , "n/a*\n" );
377
+ fs_warning = true;
378
+ }
356
379
else
357
380
{
358
381
gettimeofday (& start_t , NULL );
@@ -375,6 +398,17 @@ test_sync(int writes_per_op)
375
398
#else
376
399
printf (NA_FORMAT , "open_sync" , "n/a\n" );
377
400
#endif
401
+
402
+ if (fs_warning )
403
+ {
404
+ printf ("* This file system and its mount options do not support direct\n" );
405
+ printf ("I/O, e.g. ext4 in journaled mode.\n" );
406
+ }
407
+
408
+ #if defined(OPEN_DATASYNC_FLAG ) || defined(OPEN_SYNC_FLAG )
409
+ if (PG_O_DIRECT != 0 )
410
+ printf ("** This non-direct I/O option is not used by Postgres.\n" );
411
+ #endif
378
412
}
379
413
380
414
void
@@ -389,6 +423,8 @@ test_open_syncs(void)
389
423
printf ("(This is designed to compare the cost of one large\n" );
390
424
printf ("sync'ed write and two smaller sync'ed writes.)\n" );
391
425
426
+ /* XXX no PG_O_DIRECT */
427
+
392
428
/*
393
429
* Test open_sync with different size files
394
430
*/
0 commit comments