Use O_DIRECT in O_SYNC test of different size. Restructure O_DIRECT
error reporting to be more consistent.
This commit is contained in:
parent
3eebb33ddd
commit
6dc15e3bef
|
@ -31,8 +31,8 @@
|
||||||
|
|
||||||
#define WRITE_SIZE (8 * 1024) /* 8k */
|
#define WRITE_SIZE (8 * 1024) /* 8k */
|
||||||
|
|
||||||
#define LABEL_FORMAT " %-32s"
|
#define LABEL_FORMAT " %-32s"
|
||||||
#define NA_FORMAT LABEL_FORMAT "%18s"
|
#define NA_FORMAT LABEL_FORMAT "%18s"
|
||||||
|
|
||||||
|
|
||||||
int ops_per_test = 2000;
|
int ops_per_test = 2000;
|
||||||
|
@ -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,47 +423,51 @@ 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
|
||||||
printf(LABEL_FORMAT, "open_sync 16k write");
|
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG | PG_O_DIRECT, 0)) == -1)
|
||||||
fflush(stdout);
|
printf(NA_FORMAT, "o_direct", "n/a**\n");
|
||||||
|
else
|
||||||
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG, 0)) == -1)
|
|
||||||
die("Cannot open output file.");
|
|
||||||
gettimeofday(&start_t, NULL);
|
|
||||||
for (ops = 0; ops < ops_per_test; ops++)
|
|
||||||
{
|
{
|
||||||
if (write(tmpfile, buf, WRITE_SIZE * 2) != WRITE_SIZE * 2)
|
printf(LABEL_FORMAT, "open_sync 16k write");
|
||||||
die("write failed");
|
fflush(stdout);
|
||||||
if (lseek(tmpfile, 0, SEEK_SET) == -1)
|
|
||||||
die("seek failed");
|
gettimeofday(&start_t, NULL);
|
||||||
|
for (ops = 0; ops < ops_per_test; ops++)
|
||||||
|
{
|
||||||
|
if (write(tmpfile, buf, WRITE_SIZE * 2) != WRITE_SIZE * 2)
|
||||||
|
die("write failed");
|
||||||
|
if (lseek(tmpfile, 0, SEEK_SET) == -1)
|
||||||
|
die("seek failed");
|
||||||
|
}
|
||||||
|
gettimeofday(&stop_t, NULL);
|
||||||
|
close(tmpfile);
|
||||||
|
print_elapse(start_t, stop_t);
|
||||||
}
|
}
|
||||||
gettimeofday(&stop_t, NULL);
|
|
||||||
close(tmpfile);
|
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG | PG_O_DIRECT, 0)) == -1)
|
||||||
print_elapse(start_t, stop_t);
|
printf(NA_FORMAT, "n/a**\n");
|
||||||
|
else
|
||||||
printf(LABEL_FORMAT, "2 open_sync 8k writes");
|
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG, 0)) == -1)
|
|
||||||
die("Cannot open output file.");
|
|
||||||
gettimeofday(&start_t, NULL);
|
|
||||||
for (ops = 0; ops < ops_per_test; ops++)
|
|
||||||
{
|
{
|
||||||
if (write(tmpfile, buf, WRITE_SIZE) != WRITE_SIZE)
|
printf(LABEL_FORMAT, "2 open_sync 8k writes");
|
||||||
die("write failed");
|
fflush(stdout);
|
||||||
if (write(tmpfile, buf, WRITE_SIZE) != WRITE_SIZE)
|
|
||||||
die("write failed");
|
gettimeofday(&start_t, NULL);
|
||||||
if (lseek(tmpfile, 0, SEEK_SET) == -1)
|
for (ops = 0; ops < ops_per_test; ops++)
|
||||||
die("seek failed");
|
{
|
||||||
|
if (write(tmpfile, buf, WRITE_SIZE) != WRITE_SIZE)
|
||||||
|
die("write failed");
|
||||||
|
if (write(tmpfile, buf, WRITE_SIZE) != WRITE_SIZE)
|
||||||
|
die("write failed");
|
||||||
|
if (lseek(tmpfile, 0, SEEK_SET) == -1)
|
||||||
|
die("seek failed");
|
||||||
|
}
|
||||||
|
gettimeofday(&stop_t, NULL);
|
||||||
|
close(tmpfile);
|
||||||
|
print_elapse(start_t, stop_t);
|
||||||
}
|
}
|
||||||
gettimeofday(&stop_t, NULL);
|
|
||||||
close(tmpfile);
|
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue