Commit 431605f6 authored by Bruce Momjian's avatar Bruce Momjian

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.
parent 6ca452ba
...@@ -163,6 +163,7 @@ void ...@@ -163,6 +163,7 @@ void
test_sync(int writes_per_op) test_sync(int writes_per_op)
{ {
int tmpfile, ops, writes; int tmpfile, ops, writes;
bool fs_warning = false;
if (writes_per_op == 1) if (writes_per_op == 1)
printf("\nCompare file sync methods using one write:\n"); printf("\nCompare file sync methods using one write:\n");
...@@ -176,9 +177,17 @@ test_sync(int writes_per_op) ...@@ -176,9 +177,17 @@ test_sync(int writes_per_op)
*/ */
#ifdef OPEN_DATASYNC_FLAG #ifdef OPEN_DATASYNC_FLAG
if (writes_per_op == 1) if (writes_per_op == 1)
printf(LABEL_FORMAT, "open_datasync 8k write"); printf(LABEL_FORMAT, "open_datasync 8k write"
#if PG_O_DIRECT != 0
"**"
#endif
);
else else
printf(LABEL_FORMAT, "2 open_datasync 8k writes"); printf(LABEL_FORMAT, "2 open_datasync 8k writes"
#if PG_O_DIRECT != 0
"**"
#endif
);
fflush(stdout); fflush(stdout);
if ((tmpfile = open(filename, O_RDWR | O_DSYNC, 0)) == -1) if ((tmpfile = open(filename, O_RDWR | O_DSYNC, 0)) == -1)
...@@ -201,7 +210,10 @@ test_sync(int writes_per_op) ...@@ -201,7 +210,10 @@ test_sync(int writes_per_op)
*/ */
#if PG_O_DIRECT != 0 #if PG_O_DIRECT != 0
if ((tmpfile = open(filename, O_RDWR | O_DSYNC | PG_O_DIRECT, 0)) == -1) if ((tmpfile = open(filename, O_RDWR | O_DSYNC | PG_O_DIRECT, 0)) == -1)
printf(NA_FORMAT, "o_direct", "n/a on this filesystem\n"); {
printf(NA_FORMAT, "o_direct", "n/a*\n");
fs_warning = true;
}
else else
{ {
if (writes_per_op == 1) if (writes_per_op == 1)
...@@ -321,9 +333,17 @@ test_sync(int writes_per_op) ...@@ -321,9 +333,17 @@ test_sync(int writes_per_op)
*/ */
#ifdef OPEN_SYNC_FLAG #ifdef OPEN_SYNC_FLAG
if (writes_per_op == 1) if (writes_per_op == 1)
printf(LABEL_FORMAT, "open_sync 8k write"); printf(LABEL_FORMAT, "open_sync 8k write"
#if PG_O_DIRECT != 0
"**"
#endif
);
else else
printf(LABEL_FORMAT, "2 open_sync 8k writes"); printf(LABEL_FORMAT, "2 open_sync 8k writes"
#if PG_O_DIRECT != 0
"**"
#endif
);
fflush(stdout); fflush(stdout);
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG, 0)) == -1) if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG, 0)) == -1)
...@@ -352,7 +372,10 @@ test_sync(int writes_per_op) ...@@ -352,7 +372,10 @@ test_sync(int writes_per_op)
fflush(stdout); fflush(stdout);
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG | PG_O_DIRECT, 0)) == -1) if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG | PG_O_DIRECT, 0)) == -1)
printf(NA_FORMAT, "o_direct", "n/a on this filesystem\n"); {
printf(NA_FORMAT, "o_direct", "n/a*\n");
fs_warning = true;
}
else else
{ {
gettimeofday(&start_t, NULL); gettimeofday(&start_t, NULL);
...@@ -375,6 +398,17 @@ test_sync(int writes_per_op) ...@@ -375,6 +398,17 @@ test_sync(int writes_per_op)
#else #else
printf(NA_FORMAT, "open_sync", "n/a\n"); printf(NA_FORMAT, "open_sync", "n/a\n");
#endif #endif
if (fs_warning)
{
printf("* This file system and its mount options do not support direct\n");
printf("I/O, e.g. ext4 in journaled mode.\n");
}
#if defined(OPEN_DATASYNC_FLAG) || defined(OPEN_SYNC_FLAG)
if (PG_O_DIRECT != 0)
printf("** This non-direct I/O option is not used by Postgres.\n");
#endif
} }
void void
...@@ -389,6 +423,8 @@ test_open_syncs(void) ...@@ -389,6 +423,8 @@ test_open_syncs(void)
printf("(This is designed to compare the cost of one large\n"); printf("(This is designed to compare the cost of one large\n");
printf("sync'ed write and two smaller sync'ed writes.)\n"); printf("sync'ed write and two smaller sync'ed writes.)\n");
/* XXX no PG_O_DIRECT */
/* /*
* Test open_sync with different size files * Test open_sync with different size files
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment