for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (write(tmpfile, buf, XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pg_pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
- if (lseek(tmpfile, 0, SEEK_SET) == -1)
- die("seek failed");
}
STOP_TIMER;
close(tmpfile);
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (write(tmpfile, buf, XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pg_pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
fdatasync(tmpfile);
- if (lseek(tmpfile, 0, SEEK_SET) == -1)
- die("seek failed");
}
STOP_TIMER;
close(tmpfile);
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (write(tmpfile, buf, XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pg_pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
if (fsync(tmpfile) != 0)
die("fsync failed");
- if (lseek(tmpfile, 0, SEEK_SET) == -1)
- die("seek failed");
}
STOP_TIMER;
close(tmpfile);
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (write(tmpfile, buf, XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pg_pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
if (pg_fsync_writethrough(tmpfile) != 0)
die("fsync failed");
- if (lseek(tmpfile, 0, SEEK_SET) == -1)
- die("seek failed");
}
STOP_TIMER;
close(tmpfile);
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (write(tmpfile, buf, XLOG_BLCKSZ) != XLOG_BLCKSZ)
-
+ if (pg_pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
/*
* This can generate write failures if the filesystem has
* a large block size, e.g. 4k, and there is no support
* size, e.g. XFS.
*/
die("write failed");
- if (lseek(tmpfile, 0, SEEK_SET) == -1)
- die("seek failed");
}
STOP_TIMER;
close(tmpfile);
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < 16 / writes_size; writes++)
- if (write(tmpfile, buf, writes_size * 1024) !=
+ if (pg_pwrite(tmpfile,
+ buf,
+ writes_size * 1024,
+ writes * writes_size * 1024) !=
writes_size * 1024)
die("write failed");
- if (lseek(tmpfile, 0, SEEK_SET) == -1)
- die("seek failed");
}
STOP_TIMER;
close(tmpfile);
printf(LABEL_FORMAT, "write");
fflush(stdout);
+ if ((tmpfile = open(filename, O_RDWR | PG_BINARY, 0)) == -1)
+ die("could not open output file");
START_TIMER;
for (ops = 0; alarm_triggered == false; ops++)
{
- if ((tmpfile = open(filename, O_RDWR | PG_BINARY, 0)) == -1)
- die("could not open output file");
- if (write(tmpfile, buf, XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pg_pwrite(tmpfile, buf, XLOG_BLCKSZ, 0) != XLOG_BLCKSZ)
die("write failed");
- close(tmpfile);
}
STOP_TIMER;
+ close(tmpfile);
}
static void