Jeff Janes wrote:
> 
> The following bug has been logged online:
> 
> Bug reference:      4965
> Logged by:          Jeff Janes
> Email address:      jeff.ja...@gmail.com
> PostgreSQL version: 8.4.0
> Operating system:   Linux
> Description:        missing tests in tools/fsync/test_fsync.c
> Details: 
> 
> In the part that implements "Compare file sync methods with one 8k write",
> the #ifdef OPEN_SYNC_FLAG code
> is nested within the #ifdef OPEN_DATASYNC_FLAG code.
> 
> This causes o_sync to be skipped if o_dsync is unavailable, but only for
> this particular section (the section with 2 8k writes doesn't have this
> problem.)
> 
> Also, the statement that prints the "Compare file sync methods with one 8k
> write" section title is up in the #ifdef block of a previous section, where
> it might be omitted on systems without an o_sync.

Yea, that C file needed some help.  I have applied the attached patch to
CVS HEAD and 8.4.X.  Thanks for the report and let me know if you think
this can be improved further.

-- 
  Bruce Momjian  <br...@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/tools/fsync/test_fsync.c
===================================================================
RCS file: /cvsroot/pgsql/src/tools/fsync/test_fsync.c,v
retrieving revision 1.23
diff -c -c -r1.23 test_fsync.c
*** src/tools/fsync/test_fsync.c	11 Jun 2009 14:49:15 -0000	1.23
--- src/tools/fsync/test_fsync.c	10 Aug 2009 18:14:36 -0000
***************
*** 30,36 ****
  #define FSYNC_FILENAME	"/var/tmp/test_fsync.out"
  #endif
  
! #define WRITE_SIZE	(16 * 1024)
  
  void		die(char *str);
  void		print_elapse(struct timeval start_t, struct timeval elapse_t);
--- 30,36 ----
  #define FSYNC_FILENAME	"/var/tmp/test_fsync.out"
  #endif
  
! #define WRITE_SIZE	(16 * 1024) /* 16k */
  
  void		die(char *str);
  void		print_elapse(struct timeval start_t, struct timeval elapse_t);
***************
*** 71,76 ****
--- 71,79 ----
  
  	buf = (char *) TYPEALIGN(ALIGNOF_XLOG_BUFFER, full_buf);
  
+ 	/*
+ 	 *	Simple write
+ 	 */
  	printf("Simple write timing:\n");
  	/* write only */
  	gettimeofday(&start_t, NULL);
***************
*** 87,94 ****
  	print_elapse(start_t, elapse_t);
  	printf("\n");
  
  	printf("\nCompare fsync times on write() and non-write() descriptor:\n");
! 	printf("(If the times are similar, fsync() can sync data written\n on a different descriptor.)\n");
  
  	/* write, fsync, close */
  	gettimeofday(&start_t, NULL);
--- 90,100 ----
  	print_elapse(start_t, elapse_t);
  	printf("\n");
  
+ 	/*
+ 	 *	Fsync another file descriptor?
+ 	 */
  	printf("\nCompare fsync times on write() and non-write() descriptor:\n");
! 	printf("If the times are similar, fsync() can sync data written\non a different descriptor.\n");
  
  	/* write, fsync, close */
  	gettimeofday(&start_t, NULL);
***************
*** 132,137 ****
--- 138,146 ----
  	print_elapse(start_t, elapse_t);
  	printf("\n");
  
+ 	/*
+ 	 *	Compare 1 to 2 writes
+ 	 */
  	printf("\nCompare one o_sync write to two:\n");
  
  #ifdef OPEN_SYNC_FLAG
***************
*** 148,154 ****
  	print_elapse(start_t, elapse_t);
  	printf("\n");
  
! 	/* 2*8k o_sync writes */
  	if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG, 0)) == -1)
  		die("Cannot open output file.");
  	gettimeofday(&start_t, NULL);
--- 157,163 ----
  	print_elapse(start_t, elapse_t);
  	printf("\n");
  
! 	/* Two 8k o_sync writes */
  	if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG, 0)) == -1)
  		die("Cannot open output file.");
  	gettimeofday(&start_t, NULL);
***************
*** 163,176 ****
  	close(tmpfile);
  	printf("\ttwo 8k o_sync writes   ");
  	print_elapse(start_t, elapse_t);
- 	printf("\n");
- 
- 	printf("\nCompare file sync methods with one 8k write:\n");
  #else
  	printf("\t(o_sync unavailable)  ");
  #endif
  	printf("\n");
  
  #ifdef OPEN_DATASYNC_FLAG
  	/* open_dsync, write */
  	if ((tmpfile = open(filename, O_RDWR | O_DSYNC, 0)) == -1)
--- 172,187 ----
  	close(tmpfile);
  	printf("\ttwo 8k o_sync writes   ");
  	print_elapse(start_t, elapse_t);
  #else
  	printf("\t(o_sync unavailable)  ");
  #endif
  	printf("\n");
  
+ 	/*
+ 	 *	Compare file sync methods with one 8k write
+ 	 */
+ 	printf("\nCompare file sync methods with one 8k write:\n");
+ 
  #ifdef OPEN_DATASYNC_FLAG
  	/* open_dsync, write */
  	if ((tmpfile = open(filename, O_RDWR | O_DSYNC, 0)) == -1)
***************
*** 183,189 ****
--- 194,204 ----
  	close(tmpfile);
  	printf("\topen o_dsync, write    ");
  	print_elapse(start_t, elapse_t);
+ #else
+ 	printf("\t(o_dsync unavailable)  ");
+ #endif
  	printf("\n");
+ 
  #ifdef OPEN_SYNC_FLAG
  	/* open_fsync, write */
  	if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG, 0)) == -1)
***************
*** 196,204 ****
  	close(tmpfile);
  	printf("\topen o_sync, write     ");
  	print_elapse(start_t, elapse_t);
- #endif
  #else
! 	printf("\t(o_dsync unavailable)  ");
  #endif
  	printf("\n");
  
--- 211,218 ----
  	close(tmpfile);
  	printf("\topen o_sync, write     ");
  	print_elapse(start_t, elapse_t);
  #else
! 	printf("\t(o_sync unavailable)  ");
  #endif
  	printf("\n");
  
***************
*** 235,245 ****
  	}
  	gettimeofday(&elapse_t, NULL);
  	close(tmpfile);
! 	printf("\twrite, fsync,          ");
  	print_elapse(start_t, elapse_t);
  	printf("\n");
  
! 	printf("\nCompare file sync methods with 2 8k writes:\n");
  
  #ifdef OPEN_DATASYNC_FLAG
  	/* open_dsync, write */
--- 249,262 ----
  	}
  	gettimeofday(&elapse_t, NULL);
  	close(tmpfile);
! 	printf("\twrite, fsync           ");
  	print_elapse(start_t, elapse_t);
  	printf("\n");
  
! 	/*
! 	 *	Compare file sync methods with two 8k write
! 	 */
! 	printf("\nCompare file sync methods with two 8k writes:\n");
  
  #ifdef OPEN_DATASYNC_FLAG
  	/* open_dsync, write */
***************
*** 318,324 ****
  	}
  	gettimeofday(&elapse_t, NULL);
  	close(tmpfile);
! 	printf("\twrite, fsync,          ");
  	print_elapse(start_t, elapse_t);
  	printf("\n");
  
--- 335,341 ----
  	}
  	gettimeofday(&elapse_t, NULL);
  	close(tmpfile);
! 	printf("\twrite, fsync           ");
  	print_elapse(start_t, elapse_t);
  	printf("\n");
  
-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to