Commit c6bc0feb authored by Bruce Momjian's avatar Bruce Momjian

fsync test files

Prevent creation of 16GB files during fsync testing; only create 16MB
files;  backpatch to 8.4.X.
parent 923413ac
/* /*
* $PostgreSQL: pgsql/src/tools/fsync/test_fsync.c,v 1.24 2009/08/10 18:19:06 momjian Exp $ * $PostgreSQL: pgsql/src/tools/fsync/test_fsync.c,v 1.25 2009/09/21 20:20:56 momjian Exp $
* *
* *
* test_fsync.c * test_fsync.c
...@@ -149,8 +149,12 @@ main(int argc, char *argv[]) ...@@ -149,8 +149,12 @@ main(int argc, char *argv[])
die("Cannot open output file."); die("Cannot open output file.");
gettimeofday(&start_t, NULL); gettimeofday(&start_t, NULL);
for (i = 0; i < loops; i++) for (i = 0; i < loops; i++)
{
if (write(tmpfile, buf, WRITE_SIZE) != WRITE_SIZE) if (write(tmpfile, buf, WRITE_SIZE) != WRITE_SIZE)
die("write failed"); die("write failed");
if (lseek(tmpfile, 0, SEEK_SET) == -1)
die("seek failed");
}
gettimeofday(&elapse_t, NULL); gettimeofday(&elapse_t, NULL);
close(tmpfile); close(tmpfile);
printf("\tone 16k o_sync write "); printf("\tone 16k o_sync write ");
...@@ -167,6 +171,8 @@ main(int argc, char *argv[]) ...@@ -167,6 +171,8 @@ main(int argc, char *argv[])
die("write failed"); die("write failed");
if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2) if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
die("write failed"); die("write failed");
if (lseek(tmpfile, 0, SEEK_SET) == -1)
die("seek failed");
} }
gettimeofday(&elapse_t, NULL); gettimeofday(&elapse_t, NULL);
close(tmpfile); close(tmpfile);
...@@ -188,8 +194,12 @@ main(int argc, char *argv[]) ...@@ -188,8 +194,12 @@ main(int argc, char *argv[])
die("Cannot open output file."); die("Cannot open output file.");
gettimeofday(&start_t, NULL); gettimeofday(&start_t, NULL);
for (i = 0; i < loops; i++) for (i = 0; i < loops; i++)
{
if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2) if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
die("write failed"); die("write failed");
if (lseek(tmpfile, 0, SEEK_SET) == -1)
die("seek failed");
}
gettimeofday(&elapse_t, NULL); gettimeofday(&elapse_t, NULL);
close(tmpfile); close(tmpfile);
printf("\topen o_dsync, write "); printf("\topen o_dsync, write ");
...@@ -205,8 +215,12 @@ main(int argc, char *argv[]) ...@@ -205,8 +215,12 @@ main(int argc, char *argv[])
die("Cannot open output file."); die("Cannot open output file.");
gettimeofday(&start_t, NULL); gettimeofday(&start_t, NULL);
for (i = 0; i < loops; i++) for (i = 0; i < loops; i++)
{
if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2) if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
die("write failed"); die("write failed");
if (lseek(tmpfile, 0, SEEK_SET) == -1)
die("seek failed");
}
gettimeofday(&elapse_t, NULL); gettimeofday(&elapse_t, NULL);
close(tmpfile); close(tmpfile);
printf("\topen o_sync, write "); printf("\topen o_sync, write ");
...@@ -226,6 +240,8 @@ main(int argc, char *argv[]) ...@@ -226,6 +240,8 @@ main(int argc, char *argv[])
if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2) if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
die("write failed"); die("write failed");
fdatasync(tmpfile); fdatasync(tmpfile);
if (lseek(tmpfile, 0, SEEK_SET) == -1)
die("seek failed");
} }
gettimeofday(&elapse_t, NULL); gettimeofday(&elapse_t, NULL);
close(tmpfile); close(tmpfile);
...@@ -246,6 +262,8 @@ main(int argc, char *argv[]) ...@@ -246,6 +262,8 @@ main(int argc, char *argv[])
die("write failed"); die("write failed");
if (fsync(tmpfile) != 0) if (fsync(tmpfile) != 0)
die("fsync failed"); die("fsync failed");
if (lseek(tmpfile, 0, SEEK_SET) == -1)
die("seek failed");
} }
gettimeofday(&elapse_t, NULL); gettimeofday(&elapse_t, NULL);
close(tmpfile); close(tmpfile);
...@@ -269,6 +287,8 @@ main(int argc, char *argv[]) ...@@ -269,6 +287,8 @@ main(int argc, char *argv[])
die("write failed"); die("write failed");
if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2) if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
die("write failed"); die("write failed");
if (lseek(tmpfile, 0, SEEK_SET) == -1)
die("seek failed");
} }
gettimeofday(&elapse_t, NULL); gettimeofday(&elapse_t, NULL);
close(tmpfile); close(tmpfile);
...@@ -290,6 +310,8 @@ main(int argc, char *argv[]) ...@@ -290,6 +310,8 @@ main(int argc, char *argv[])
die("write failed"); die("write failed");
if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2) if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
die("write failed"); die("write failed");
if (lseek(tmpfile, 0, SEEK_SET) == -1)
die("seek failed");
} }
gettimeofday(&elapse_t, NULL); gettimeofday(&elapse_t, NULL);
close(tmpfile); close(tmpfile);
...@@ -310,6 +332,8 @@ main(int argc, char *argv[]) ...@@ -310,6 +332,8 @@ main(int argc, char *argv[])
if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2) if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
die("write failed"); die("write failed");
fdatasync(tmpfile); fdatasync(tmpfile);
if (lseek(tmpfile, 0, SEEK_SET) == -1)
die("seek failed");
} }
gettimeofday(&elapse_t, NULL); gettimeofday(&elapse_t, NULL);
close(tmpfile); close(tmpfile);
...@@ -332,6 +356,8 @@ main(int argc, char *argv[]) ...@@ -332,6 +356,8 @@ main(int argc, char *argv[])
die("write failed"); die("write failed");
if (fsync(tmpfile) != 0) if (fsync(tmpfile) != 0)
die("fsync failed"); die("fsync failed");
if (lseek(tmpfile, 0, SEEK_SET) == -1)
die("seek failed");
} }
gettimeofday(&elapse_t, NULL); gettimeofday(&elapse_t, NULL);
close(tmpfile); close(tmpfile);
......
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