加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgres 之 initdb 源码分析 四

发布时间:2020-12-13 17:28: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

2.7 函数perform_fsync

/*
 * fsync everything down to disk
 */
static void
perform_fsync(void)
{
	char		pdir[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,fsync_fname);

	check_ok();
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读