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

Commit 431605f

Browse files
committed
In test_fsync, warn about options without o_direct that are not used by
Postgres, and cases where o_direct does not work with certain file systems.
1 parent 6ca452b commit 431605f

File tree

1 file changed

+43
-7
lines changed

1 file changed

+43
-7
lines changed

src/tools/fsync/test_fsync.c

+43-7
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ void
163163
test_sync(int writes_per_op)
164164
{
165165
int tmpfile, ops, writes;
166-
166+
bool fs_warning = false;
167+
167168
if (writes_per_op == 1)
168169
printf("\nCompare file sync methods using one write:\n");
169170
else
@@ -176,9 +177,17 @@ test_sync(int writes_per_op)
176177
*/
177178
#ifdef OPEN_DATASYNC_FLAG
178179
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+
);
180185
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+
);
182191
fflush(stdout);
183192

184193
if ((tmpfile = open(filename, O_RDWR | O_DSYNC, 0)) == -1)
@@ -201,7 +210,10 @@ test_sync(int writes_per_op)
201210
*/
202211
#if PG_O_DIRECT != 0
203212
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+
}
205217
else
206218
{
207219
if (writes_per_op == 1)
@@ -321,9 +333,17 @@ test_sync(int writes_per_op)
321333
*/
322334
#ifdef OPEN_SYNC_FLAG
323335
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+
);
325341
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+
);
327347
fflush(stdout);
328348

329349
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG, 0)) == -1)
@@ -352,7 +372,10 @@ test_sync(int writes_per_op)
352372
fflush(stdout);
353373

354374
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+
}
356379
else
357380
{
358381
gettimeofday(&start_t, NULL);
@@ -375,6 +398,17 @@ test_sync(int writes_per_op)
375398
#else
376399
printf(NA_FORMAT, "open_sync", "n/a\n");
377400
#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
378412
}
379413

380414
void
@@ -389,6 +423,8 @@ test_open_syncs(void)
389423
printf("(This is designed to compare the cost of one large\n");
390424
printf("sync'ed write and two smaller sync'ed writes.)\n");
391425

426+
/* XXX no PG_O_DIRECT */
427+
392428
/*
393429
* Test open_sync with different size files
394430
*/

0 commit comments

Comments
 (0)