|
|
|
@ -44,7 +44,7 @@ do { \ |
|
|
|
|
if (CreateThread(NULL, 0, process_alarm, NULL, 0, NULL) == \
|
|
|
|
|
INVALID_HANDLE_VALUE) \
|
|
|
|
|
{ \
|
|
|
|
|
fprintf(stderr, "Cannot create thread for alarm\n"); \
|
|
|
|
|
fprintf(stderr, _("Cannot create thread for alarm\n")); \
|
|
|
|
|
exit(1); \
|
|
|
|
|
} \
|
|
|
|
|
gettimeofday(&start_t, NULL); \
|
|
|
|
@ -96,6 +96,7 @@ static void die(const char *str); |
|
|
|
|
int |
|
|
|
|
main(int argc, char *argv[]) |
|
|
|
|
{ |
|
|
|
|
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_test_fsync")); |
|
|
|
|
progname = get_progname(argv[0]); |
|
|
|
|
|
|
|
|
|
handle_args(argc, argv); |
|
|
|
@ -148,7 +149,7 @@ handle_args(int argc, char *argv[]) |
|
|
|
|
{ |
|
|
|
|
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0) |
|
|
|
|
{ |
|
|
|
|
printf("Usage: %s [-f FILENAME] [-s SECS-PER-TEST]\n", progname); |
|
|
|
|
printf(_("Usage: %s [-f FILENAME] [-s SECS-PER-TEST]\n"), progname); |
|
|
|
|
exit(0); |
|
|
|
|
} |
|
|
|
|
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0) |
|
|
|
@ -172,7 +173,7 @@ handle_args(int argc, char *argv[]) |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
fprintf(stderr, "Try \"%s --help\" for more information.\n", |
|
|
|
|
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), |
|
|
|
|
progname); |
|
|
|
|
exit(1); |
|
|
|
|
break; |
|
|
|
@ -182,18 +183,18 @@ handle_args(int argc, char *argv[]) |
|
|
|
|
if (argc > optind) |
|
|
|
|
{ |
|
|
|
|
fprintf(stderr, |
|
|
|
|
"%s: too many command-line arguments (first is \"%s\")\n", |
|
|
|
|
_("%s: too many command-line arguments (first is \"%s\")\n"), |
|
|
|
|
progname, argv[optind]); |
|
|
|
|
fprintf(stderr, "Try \"%s --help\" for more information.\n", |
|
|
|
|
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), |
|
|
|
|
progname); |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
printf("%d seconds per test\n", secs_per_test); |
|
|
|
|
printf(_("%d seconds per test\n"), secs_per_test); |
|
|
|
|
#if PG_O_DIRECT != 0 |
|
|
|
|
printf("O_DIRECT supported on this platform for open_datasync and open_sync.\n"); |
|
|
|
|
printf(_("O_DIRECT supported on this platform for open_datasync and open_sync.\n")); |
|
|
|
|
#else |
|
|
|
|
printf("Direct I/O is not supported on this platform.\n"); |
|
|
|
|
printf(_("Direct I/O is not supported on this platform.\n")); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -239,10 +240,10 @@ test_sync(int writes_per_op) |
|
|
|
|
bool fs_warning = false; |
|
|
|
|
|
|
|
|
|
if (writes_per_op == 1) |
|
|
|
|
printf("\nCompare file sync methods using one %dkB write:\n", XLOG_BLCKSZ_K); |
|
|
|
|
printf(_("\nCompare file sync methods using one %dkB write:\n"), XLOG_BLCKSZ_K); |
|
|
|
|
else |
|
|
|
|
printf("\nCompare file sync methods using two %dkB writes:\n", XLOG_BLCKSZ_K); |
|
|
|
|
printf("(in wal_sync_method preference order, except fdatasync is Linux's default)\n"); |
|
|
|
|
printf(_("\nCompare file sync methods using two %dkB writes:\n"), XLOG_BLCKSZ_K); |
|
|
|
|
printf(_("(in wal_sync_method preference order, except fdatasync is Linux's default)\n")); |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Test open_datasync if available |
|
|
|
@ -253,7 +254,7 @@ test_sync(int writes_per_op) |
|
|
|
|
#ifdef OPEN_DATASYNC_FLAG |
|
|
|
|
if ((tmpfile = open(filename, O_RDWR | O_DSYNC | PG_O_DIRECT, 0)) == -1) |
|
|
|
|
{ |
|
|
|
|
printf(NA_FORMAT, "n/a*\n"); |
|
|
|
|
printf(NA_FORMAT, _("n/a*\n")); |
|
|
|
|
fs_warning = true; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
@ -271,7 +272,7 @@ test_sync(int writes_per_op) |
|
|
|
|
close(tmpfile); |
|
|
|
|
} |
|
|
|
|
#else |
|
|
|
|
printf(NA_FORMAT, "n/a\n"); |
|
|
|
|
printf(NA_FORMAT, _("n/a\n")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -296,7 +297,7 @@ test_sync(int writes_per_op) |
|
|
|
|
STOP_TIMER; |
|
|
|
|
close(tmpfile); |
|
|
|
|
#else |
|
|
|
|
printf(NA_FORMAT, "n/a\n"); |
|
|
|
|
printf(NA_FORMAT, _("n/a\n")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -344,7 +345,7 @@ test_sync(int writes_per_op) |
|
|
|
|
STOP_TIMER; |
|
|
|
|
close(tmpfile); |
|
|
|
|
#else |
|
|
|
|
printf(NA_FORMAT, "n/a\n"); |
|
|
|
|
printf(NA_FORMAT, _("n/a\n")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -356,7 +357,7 @@ test_sync(int writes_per_op) |
|
|
|
|
#ifdef OPEN_SYNC_FLAG |
|
|
|
|
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG | PG_O_DIRECT, 0)) == -1) |
|
|
|
|
{ |
|
|
|
|
printf(NA_FORMAT, "n/a*\n"); |
|
|
|
|
printf(NA_FORMAT, _("n/a*\n")); |
|
|
|
|
fs_warning = true; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
@ -381,28 +382,28 @@ test_sync(int writes_per_op) |
|
|
|
|
close(tmpfile); |
|
|
|
|
} |
|
|
|
|
#else |
|
|
|
|
printf(NA_FORMAT, "n/a\n"); |
|
|
|
|
printf(NA_FORMAT, _("n/a\n")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (fs_warning) |
|
|
|
|
{ |
|
|
|
|
printf("* This file system and its mount options do not support direct\n"); |
|
|
|
|
printf("I/O, e.g. ext4 in journaled mode.\n"); |
|
|
|
|
printf(_("* This file system and its mount options do not support direct\n" |
|
|
|
|
" I/O, e.g. ext4 in journaled mode.\n")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
test_open_syncs(void) |
|
|
|
|
{ |
|
|
|
|
printf("\nCompare open_sync with different write sizes:\n"); |
|
|
|
|
printf("(This is designed to compare the cost of writing 16kB in different write\n" |
|
|
|
|
"open_sync sizes.)\n"); |
|
|
|
|
|
|
|
|
|
test_open_sync(" 1 * 16kB open_sync write", 16); |
|
|
|
|
test_open_sync(" 2 * 8kB open_sync writes", 8); |
|
|
|
|
test_open_sync(" 4 * 4kB open_sync writes", 4); |
|
|
|
|
test_open_sync(" 8 * 2kB open_sync writes", 2); |
|
|
|
|
test_open_sync("16 * 1kB open_sync writes", 1); |
|
|
|
|
printf(_("\nCompare open_sync with different write sizes:\n")); |
|
|
|
|
printf(_("(This is designed to compare the cost of writing 16kB in different write\n" |
|
|
|
|
"open_sync sizes.)\n")); |
|
|
|
|
|
|
|
|
|
test_open_sync(_(" 1 * 16kB open_sync write"), 16); |
|
|
|
|
test_open_sync(_(" 2 * 8kB open_sync writes"), 8); |
|
|
|
|
test_open_sync(_(" 4 * 4kB open_sync writes"), 4); |
|
|
|
|
test_open_sync(_(" 8 * 2kB open_sync writes"), 2); |
|
|
|
|
test_open_sync(_("16 * 1kB open_sync writes"), 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -422,7 +423,7 @@ test_open_sync(const char *msg, int writes_size) |
|
|
|
|
|
|
|
|
|
#ifdef OPEN_SYNC_FLAG |
|
|
|
|
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG | PG_O_DIRECT, 0)) == -1) |
|
|
|
|
printf(NA_FORMAT, "n/a*\n"); |
|
|
|
|
printf(NA_FORMAT, _("n/a*\n")); |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
START_TIMER; |
|
|
|
@ -439,7 +440,7 @@ test_open_sync(const char *msg, int writes_size) |
|
|
|
|
close(tmpfile); |
|
|
|
|
} |
|
|
|
|
#else |
|
|
|
|
printf(NA_FORMAT, "n/a\n"); |
|
|
|
|
printf(NA_FORMAT, _("n/a\n")); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -455,9 +456,9 @@ test_file_descriptor_sync(void) |
|
|
|
|
* against the same file. Possibly this should be done with writethrough |
|
|
|
|
* on platforms which support it. |
|
|
|
|
*/ |
|
|
|
|
printf("\nTest if fsync on non-write file descriptor is honored:\n"); |
|
|
|
|
printf("(If the times are similar, fsync() can sync data written on a different\n" |
|
|
|
|
"descriptor.)\n"); |
|
|
|
|
printf(_("\nTest if fsync on non-write file descriptor is honored:\n")); |
|
|
|
|
printf(_("(If the times are similar, fsync() can sync data written on a different\n" |
|
|
|
|
"descriptor.)\n")); |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* first write, fsync and close, which is the normal behavior without |
|
|
|
@ -521,7 +522,7 @@ test_non_sync(void) |
|
|
|
|
/*
|
|
|
|
|
* Test a simple write without fsync |
|
|
|
|
*/ |
|
|
|
|
printf("\nNon-sync'ed %dkB writes:\n", XLOG_BLCKSZ_K); |
|
|
|
|
printf(_("\nNon-sync'ed %dkB writes:\n"), XLOG_BLCKSZ_K); |
|
|
|
|
printf(LABEL_FORMAT, "write"); |
|
|
|
|
fflush(stdout); |
|
|
|
|
|
|
|
|
@ -598,6 +599,6 @@ process_alarm(LPVOID param) |
|
|
|
|
static void |
|
|
|
|
die(const char *str) |
|
|
|
|
{ |
|
|
|
|
fprintf(stderr, "%s: %s\n", str, strerror(errno)); |
|
|
|
|
fprintf(stderr, _("%s: %s\n"), _(str), strerror(errno)); |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|