Use O_DIRECT in O_SYNC test of different size. Restructure O_DIRECT

error reporting to be more consistent.
This commit is contained in:
Bruce Momjian 2011-01-15 19:40:49 -05:00
parent 3eebb33ddd
commit 6dc15e3bef
1 changed files with 45 additions and 41 deletions

View File

@ -365,12 +365,6 @@ test_sync(int writes_per_op)
* If O_DIRECT is enabled, test that with open_sync * If O_DIRECT is enabled, test that with open_sync
*/ */
#if PG_O_DIRECT != 0 #if PG_O_DIRECT != 0
if (writes_per_op == 1)
printf(LABEL_FORMAT, "open_sync 8k direct I/O write");
else
printf(LABEL_FORMAT, "2 open_sync 8k direct I/O writes");
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**\n"); printf(NA_FORMAT, "o_direct", "n/a**\n");
@ -378,6 +372,12 @@ test_sync(int writes_per_op)
} }
else else
{ {
if (writes_per_op == 1)
printf(LABEL_FORMAT, "open_sync 8k direct I/O write");
else
printf(LABEL_FORMAT, "2 open_sync 8k direct I/O writes");
fflush(stdout);
gettimeofday(&start_t, NULL); gettimeofday(&start_t, NULL);
for (ops = 0; ops < ops_per_test; ops++) for (ops = 0; ops < ops_per_test; ops++)
{ {
@ -423,17 +423,17 @@ 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
*/ */
#ifdef OPEN_SYNC_FLAG #ifdef OPEN_SYNC_FLAG
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG | PG_O_DIRECT, 0)) == -1)
printf(NA_FORMAT, "o_direct", "n/a**\n");
else
{
printf(LABEL_FORMAT, "open_sync 16k write"); printf(LABEL_FORMAT, "open_sync 16k write");
fflush(stdout); fflush(stdout);
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG, 0)) == -1)
die("Cannot open output file.");
gettimeofday(&start_t, NULL); gettimeofday(&start_t, NULL);
for (ops = 0; ops < ops_per_test; ops++) for (ops = 0; ops < ops_per_test; ops++)
{ {
@ -445,12 +445,15 @@ test_open_syncs(void)
gettimeofday(&stop_t, NULL); gettimeofday(&stop_t, NULL);
close(tmpfile); close(tmpfile);
print_elapse(start_t, stop_t); print_elapse(start_t, stop_t);
}
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG | PG_O_DIRECT, 0)) == -1)
printf(NA_FORMAT, "n/a**\n");
else
{
printf(LABEL_FORMAT, "2 open_sync 8k writes"); printf(LABEL_FORMAT, "2 open_sync 8k writes");
fflush(stdout); fflush(stdout);
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG, 0)) == -1)
die("Cannot open output file.");
gettimeofday(&start_t, NULL); gettimeofday(&start_t, NULL);
for (ops = 0; ops < ops_per_test; ops++) for (ops = 0; ops < ops_per_test; ops++)
{ {
@ -464,6 +467,7 @@ test_open_syncs(void)
gettimeofday(&stop_t, NULL); gettimeofday(&stop_t, NULL);
close(tmpfile); close(tmpfile);
print_elapse(start_t, stop_t); print_elapse(start_t, stop_t);
}
#else #else
printf(NA_FORMAT, "open_sync", "n/a\n"); printf(NA_FORMAT, "open_sync", "n/a\n");
#endif #endif