postgres 之 initdb 源码分析 四

来源:互联网 发布:域名后缀产生 编辑:程序博客网 时间:2024/05/26 04:40

2.7 函数 perform_fsync

/* * fsync everything down to disk */static voidperform_fsync(void){charpdir[MAXPGPATH];fputs(_("syncing data to disk ... "), stdout);fflush(stdout);/* * We need to name the parent of PGDATA.  get_parent_directory() isn't * enough here, because it can result in an empty string. */snprintf(pdir, MAXPGPATH, "%s/..", pg_data);canonicalize_path(pdir);/* * Hint to the OS so that we're going to fsync each of these files soon. *//* first the parent of the PGDATA directory */pre_sync_fname(pdir, true);/* then recursively through the directory */walkdir(pg_data, pre_sync_fname);/* * Now, do the fsync()s in the same order. *//* first the parent of the PGDATA directory */fsync_fname(pdir, true);/* then recursively through the directory */walkdir(pg_data, fsync_fname);check_ok();}



0 0