MCPcopy Create free account
hub / github.com/apache/cloudberry / test_sync

Function test_sync

src/bin/pg_test_fsync/pg_test_fsync.c:261–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259}
260
261static void
262test_sync(int writes_per_op)
263{
264 int tmpfile,
265 ops,
266 writes;
267 bool fs_warning = false;
268
269 if (writes_per_op == 1)
270 printf(_("\nCompare file sync methods using one %dkB write:\n"), XLOG_BLCKSZ_K);
271 else
272 printf(_("\nCompare file sync methods using two %dkB writes:\n"), XLOG_BLCKSZ_K);
273 printf(_("(in wal_sync_method preference order, except fdatasync is Linux's default)\n"));
274
275 /*
276 * Test open_datasync if available
277 */
278 printf(LABEL_FORMAT, "open_datasync");
279 fflush(stdout);
280
281#ifdef OPEN_DATASYNC_FLAG
282 if ((tmpfile = open(filename, O_RDWR | O_DSYNC | PG_O_DIRECT | PG_BINARY, 0)) == -1)
283 {
284 printf(NA_FORMAT, _("n/a*"));
285 fs_warning = true;
286 }
287 else
288 {
289 START_TIMER;
290 for (ops = 0; alarm_triggered == false; ops++)
291 {
292 for (writes = 0; writes < writes_per_op; writes++)
293 if (pg_pwrite(tmpfile,
294 buf,
295 XLOG_BLCKSZ,
296 writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
297 die("write failed");
298 }
299 STOP_TIMER;
300 close(tmpfile);
301 }
302#else
303 printf(NA_FORMAT, _("n/a"));
304#endif
305
306/*
307 * Test fdatasync if available
308 */
309 printf(LABEL_FORMAT, "fdatasync");
310 fflush(stdout);
311
312#ifdef HAVE_FDATASYNC
313 if ((tmpfile = open(filename, O_RDWR | PG_BINARY, 0)) == -1)
314 die("could not open output file");
315 START_TIMER;
316 for (ops = 0; alarm_triggered == false; ops++)
317 {
318 for (writes = 0; writes < writes_per_op; writes++)

Callers 1

mainFunction · 0.85

Calls 3

pg_pwriteFunction · 0.85
dieFunction · 0.85
pg_fsync_writethroughFunction · 0.70

Tested by

no test coverage detected