1
1
/*
2
- * $PostgreSQL: pgsql/src/tools/fsync/test_fsync.c,v 1.24 2009/08/10 18:19:06 momjian Exp $
2
+ * $PostgreSQL: pgsql/src/tools/fsync/test_fsync.c,v 1.25 2009/09/21 20:20:56 momjian Exp $
3
3
*
4
4
*
5
5
* test_fsync.c
@@ -149,8 +149,12 @@ main(int argc, char *argv[])
149
149
die ("Cannot open output file." );
150
150
gettimeofday (& start_t , NULL );
151
151
for (i = 0 ; i < loops ; i ++ )
152
+ {
152
153
if (write (tmpfile , buf , WRITE_SIZE ) != WRITE_SIZE )
153
154
die ("write failed" );
155
+ if (lseek (tmpfile , 0 , SEEK_SET ) == -1 )
156
+ die ("seek failed" );
157
+ }
154
158
gettimeofday (& elapse_t , NULL );
155
159
close (tmpfile );
156
160
printf ("\tone 16k o_sync write " );
@@ -167,6 +171,8 @@ main(int argc, char *argv[])
167
171
die ("write failed" );
168
172
if (write (tmpfile , buf , WRITE_SIZE / 2 ) != WRITE_SIZE / 2 )
169
173
die ("write failed" );
174
+ if (lseek (tmpfile , 0 , SEEK_SET ) == -1 )
175
+ die ("seek failed" );
170
176
}
171
177
gettimeofday (& elapse_t , NULL );
172
178
close (tmpfile );
@@ -188,8 +194,12 @@ main(int argc, char *argv[])
188
194
die ("Cannot open output file." );
189
195
gettimeofday (& start_t , NULL );
190
196
for (i = 0 ; i < loops ; i ++ )
197
+ {
191
198
if (write (tmpfile , buf , WRITE_SIZE / 2 ) != WRITE_SIZE / 2 )
192
199
die ("write failed" );
200
+ if (lseek (tmpfile , 0 , SEEK_SET ) == -1 )
201
+ die ("seek failed" );
202
+ }
193
203
gettimeofday (& elapse_t , NULL );
194
204
close (tmpfile );
195
205
printf ("\topen o_dsync, write " );
@@ -205,8 +215,12 @@ main(int argc, char *argv[])
205
215
die ("Cannot open output file." );
206
216
gettimeofday (& start_t , NULL );
207
217
for (i = 0 ; i < loops ; i ++ )
218
+ {
208
219
if (write (tmpfile , buf , WRITE_SIZE / 2 ) != WRITE_SIZE / 2 )
209
220
die ("write failed" );
221
+ if (lseek (tmpfile , 0 , SEEK_SET ) == -1 )
222
+ die ("seek failed" );
223
+ }
210
224
gettimeofday (& elapse_t , NULL );
211
225
close (tmpfile );
212
226
printf ("\topen o_sync, write " );
@@ -226,6 +240,8 @@ main(int argc, char *argv[])
226
240
if (write (tmpfile , buf , WRITE_SIZE / 2 ) != WRITE_SIZE / 2 )
227
241
die ("write failed" );
228
242
fdatasync (tmpfile );
243
+ if (lseek (tmpfile , 0 , SEEK_SET ) == -1 )
244
+ die ("seek failed" );
229
245
}
230
246
gettimeofday (& elapse_t , NULL );
231
247
close (tmpfile );
@@ -246,6 +262,8 @@ main(int argc, char *argv[])
246
262
die ("write failed" );
247
263
if (fsync (tmpfile ) != 0 )
248
264
die ("fsync failed" );
265
+ if (lseek (tmpfile , 0 , SEEK_SET ) == -1 )
266
+ die ("seek failed" );
249
267
}
250
268
gettimeofday (& elapse_t , NULL );
251
269
close (tmpfile );
@@ -269,6 +287,8 @@ main(int argc, char *argv[])
269
287
die ("write failed" );
270
288
if (write (tmpfile , buf , WRITE_SIZE / 2 ) != WRITE_SIZE / 2 )
271
289
die ("write failed" );
290
+ if (lseek (tmpfile , 0 , SEEK_SET ) == -1 )
291
+ die ("seek failed" );
272
292
}
273
293
gettimeofday (& elapse_t , NULL );
274
294
close (tmpfile );
@@ -290,6 +310,8 @@ main(int argc, char *argv[])
290
310
die ("write failed" );
291
311
if (write (tmpfile , buf , WRITE_SIZE / 2 ) != WRITE_SIZE / 2 )
292
312
die ("write failed" );
313
+ if (lseek (tmpfile , 0 , SEEK_SET ) == -1 )
314
+ die ("seek failed" );
293
315
}
294
316
gettimeofday (& elapse_t , NULL );
295
317
close (tmpfile );
@@ -310,6 +332,8 @@ main(int argc, char *argv[])
310
332
if (write (tmpfile , buf , WRITE_SIZE / 2 ) != WRITE_SIZE / 2 )
311
333
die ("write failed" );
312
334
fdatasync (tmpfile );
335
+ if (lseek (tmpfile , 0 , SEEK_SET ) == -1 )
336
+ die ("seek failed" );
313
337
}
314
338
gettimeofday (& elapse_t , NULL );
315
339
close (tmpfile );
@@ -332,6 +356,8 @@ main(int argc, char *argv[])
332
356
die ("write failed" );
333
357
if (fsync (tmpfile ) != 0 )
334
358
die ("fsync failed" );
359
+ if (lseek (tmpfile , 0 , SEEK_SET ) == -1 )
360
+ die ("seek failed" );
335
361
}
336
362
gettimeofday (& elapse_t , NULL );
337
363
close (tmpfile );
0 commit comments