341
341
FreeDir(dbspace_dir);
344
* copy_file() above has already called pg_flush_data() on the
345
* files it created. Now we need to fsync those files, because
346
* a checkpoint won't do it for us while we're in recovery. We
347
* do this in a separate pass to allow the kernel to perform
348
* all the flushes (especially the metadata ones) at once.
350
dbspace_dir = AllocateDir(dbspacedirname);
351
if (dbspace_dir == NULL)
353
/* we just saw this directory, so it really ought to be there */
355
"could not open dbspace directory \"%s\": %m",
360
while ((de = ReadDir(dbspace_dir, dbspacedirname)) != NULL)
364
char oidbuf[OIDCHARS + 1];
365
char mainpath[MAXPGPATH];
367
/* Skip anything that doesn't look like a relation data file. */
368
if (!parse_filename_for_nontemp_relation(de->d_name, &oidchars,
372
/* Also skip it unless this is the init fork. */
373
if (forkNum != INIT_FORKNUM)
376
/* Construct main fork pathname. */
377
memcpy(oidbuf, de->d_name, oidchars);
378
oidbuf[oidchars] = '\0';
379
snprintf(mainpath, sizeof(mainpath), "%s/%s%s",
380
dbspacedirname, oidbuf, de->d_name + oidchars + 1 +
381
strlen(forkNames[INIT_FORKNUM]));
383
fsync_fname(mainpath, false);
386
FreeDir(dbspace_dir);
388
fsync_fname((char *) dbspacedirname, true);