]> granicus.if.org Git - postgresql/commitdiff
fsync test files
authorBruce Momjian <bruce@momjian.us>
Mon, 21 Sep 2009 20:20:56 +0000 (20:20 +0000)
committerBruce Momjian <bruce@momjian.us>
Mon, 21 Sep 2009 20:20:56 +0000 (20:20 +0000)
Prevent creation of 16GB files during fsync testing; only create 16MB
files;  backpatch to 8.4.X.

src/tools/fsync/test_fsync.c

index 6b3e939cd4ea6a926a0683bddee7ba0c826bb2b0..52351b7dfdd301adabd82a27e1dc8d8b5aae1fcb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $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
@@ -149,8 +149,12 @@ main(int argc, char *argv[])
                die("Cannot open output file.");
        gettimeofday(&start_t, NULL);
        for (i = 0; i < loops; i++)
+       {
                if (write(tmpfile, buf, WRITE_SIZE) != WRITE_SIZE)
                        die("write failed");
+               if (lseek(tmpfile, 0, SEEK_SET) == -1)
+                       die("seek failed");
+       }
        gettimeofday(&elapse_t, NULL);
        close(tmpfile);
        printf("\tone 16k o_sync write   ");
@@ -167,6 +171,8 @@ main(int argc, char *argv[])
                        die("write failed");
                if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
                        die("write failed");
+               if (lseek(tmpfile, 0, SEEK_SET) == -1)
+                       die("seek failed");
        }
        gettimeofday(&elapse_t, NULL);
        close(tmpfile);
@@ -188,8 +194,12 @@ main(int argc, char *argv[])
                die("Cannot open output file.");
        gettimeofday(&start_t, NULL);
        for (i = 0; i < loops; i++)
+       {
                if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
                        die("write failed");
+               if (lseek(tmpfile, 0, SEEK_SET) == -1)
+                       die("seek failed");
+       }
        gettimeofday(&elapse_t, NULL);
        close(tmpfile);
        printf("\topen o_dsync, write    ");
@@ -205,8 +215,12 @@ main(int argc, char *argv[])
                die("Cannot open output file.");
        gettimeofday(&start_t, NULL);
        for (i = 0; i < loops; i++)
+       {
                if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
                        die("write failed");
+               if (lseek(tmpfile, 0, SEEK_SET) == -1)
+                       die("seek failed");
+       }
        gettimeofday(&elapse_t, NULL);
        close(tmpfile);
        printf("\topen o_sync, write     ");
@@ -226,6 +240,8 @@ main(int argc, char *argv[])
                if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
                        die("write failed");
                fdatasync(tmpfile);
+               if (lseek(tmpfile, 0, SEEK_SET) == -1)
+                       die("seek failed");
        }
        gettimeofday(&elapse_t, NULL);
        close(tmpfile);
@@ -246,6 +262,8 @@ main(int argc, char *argv[])
                        die("write failed");
                if (fsync(tmpfile) != 0)
                        die("fsync failed");
+               if (lseek(tmpfile, 0, SEEK_SET) == -1)
+                       die("seek failed");
        }
        gettimeofday(&elapse_t, NULL);
        close(tmpfile);
@@ -269,6 +287,8 @@ main(int argc, char *argv[])
                        die("write failed");
                if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
                        die("write failed");
+               if (lseek(tmpfile, 0, SEEK_SET) == -1)
+                       die("seek failed");
        }
        gettimeofday(&elapse_t, NULL);
        close(tmpfile);
@@ -290,6 +310,8 @@ main(int argc, char *argv[])
                        die("write failed");
                if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
                        die("write failed");
+               if (lseek(tmpfile, 0, SEEK_SET) == -1)
+                       die("seek failed");
        }
        gettimeofday(&elapse_t, NULL);
        close(tmpfile);
@@ -310,6 +332,8 @@ main(int argc, char *argv[])
                if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
                        die("write failed");
                fdatasync(tmpfile);
+               if (lseek(tmpfile, 0, SEEK_SET) == -1)
+                       die("seek failed");
        }
        gettimeofday(&elapse_t, NULL);
        close(tmpfile);
@@ -332,6 +356,8 @@ main(int argc, char *argv[])
                        die("write failed");
                if (fsync(tmpfile) != 0)
                        die("fsync failed");
+               if (lseek(tmpfile, 0, SEEK_SET) == -1)
+                       die("seek failed");
        }
        gettimeofday(&elapse_t, NULL);
        close(tmpfile);