Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
303b7fcd
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
303b7fcd
编写于
3月 10, 2011
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modify pg_test_fsync to match the behavior of git head in regards to
O_DIRECT behavior.
上级
5ca543fb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
81 deletion
+27
-81
contrib/pg_test_fsync/pg_test_fsync.c
contrib/pg_test_fsync/pg_test_fsync.c
+27
-81
未找到文件。
contrib/pg_test_fsync/pg_test_fsync.c
浏览文件 @
303b7fcd
...
...
@@ -23,7 +23,7 @@
#define XLOG_BLCKSZ_K (XLOG_BLCKSZ / 1024)
#define LABEL_FORMAT " %-32s"
#define NA_FORMAT
LABEL_FORMAT
"%18s"
#define NA_FORMAT "%18s"
#define OPS_FORMAT "%9.3f ops/sec"
static
const
char
*
progname
;
...
...
@@ -134,6 +134,11 @@ handle_args(int argc, char *argv[])
}
printf
(
"%d operations per test
\n
"
,
ops_per_test
);
#if PG_O_DIRECT != 0
printf
(
"O_DIRECT supported on this platform for open_datasync and open_sync.
\n
"
);
#else
printf
(
"Direct I/O is not supported on this platform.
\n
"
);
#endif
}
static
void
...
...
@@ -184,43 +189,19 @@ test_sync(int writes_per_op)
/*
* Test open_datasync if available
*/
#ifdef OPEN_DATASYNC_FLAG
printf
(
LABEL_FORMAT
,
"open_datasync"
#if PG_O_DIRECT != 0
" (non-direct I/O)*"
#endif
);
printf
(
LABEL_FORMAT
,
"open_datasync"
);
fflush
(
stdout
);
if
((
tmpfile
=
open
(
filename
,
O_RDWR
|
O_DSYNC
,
0
))
==
-
1
)
die
(
"could not open output file"
);
gettimeofday
(
&
start_t
,
NULL
);
for
(
ops
=
0
;
ops
<
ops_per_test
;
ops
++
)
{
for
(
writes
=
0
;
writes
<
writes_per_op
;
writes
++
)
if
(
write
(
tmpfile
,
buf
,
XLOG_BLCKSZ
)
!=
XLOG_BLCKSZ
)
die
(
"write failed"
);
if
(
lseek
(
tmpfile
,
0
,
SEEK_SET
)
==
-
1
)
die
(
"seek failed"
);
}
gettimeofday
(
&
stop_t
,
NULL
);
close
(
tmpfile
);
print_elapse
(
start_t
,
stop_t
);
/*
* If O_DIRECT is enabled, test that with open_datasync
*/
#if PG_O_DIRECT != 0
#ifdef OPEN_DATASYNC_FLAG
if
((
tmpfile
=
open
(
filename
,
O_RDWR
|
O_DSYNC
|
PG_O_DIRECT
,
0
))
==
-
1
)
{
printf
(
NA_FORMAT
,
"
o_direct"
,
"n/a*
*
\n
"
);
printf
(
NA_FORMAT
,
"
n/a
*
\n
"
);
fs_warning
=
true
;
}
else
{
printf
(
LABEL_FORMAT
,
"open_datasync (direct I/O)"
);
fflush
(
stdout
);
if
((
tmpfile
=
open
(
filename
,
O_RDWR
|
O_DSYNC
|
PG_O_DIRECT
,
0
))
==
-
1
)
die
(
"could not open output file"
);
gettimeofday
(
&
start_t
,
NULL
);
for
(
ops
=
0
;
ops
<
ops_per_test
;
ops
++
)
{
...
...
@@ -234,19 +215,17 @@ test_sync(int writes_per_op)
close
(
tmpfile
);
print_elapse
(
start_t
,
stop_t
);
}
#endif
#else
printf
(
NA_FORMAT
,
"
open_datasync"
,
"
n/a
\n
"
);
printf
(
NA_FORMAT
,
"n/a
\n
"
);
#endif
/*
* Test fdatasync if available
*/
#ifdef HAVE_FDATASYNC
printf
(
LABEL_FORMAT
,
"fdatasync"
);
fflush
(
stdout
);
#ifdef HAVE_FDATASYNC
if
((
tmpfile
=
open
(
filename
,
O_RDWR
,
0
))
==
-
1
)
die
(
"could not open output file"
);
gettimeofday
(
&
start_t
,
NULL
);
...
...
@@ -263,7 +242,7 @@ test_sync(int writes_per_op)
close
(
tmpfile
);
print_elapse
(
start_t
,
stop_t
);
#else
printf
(
NA_FORMAT
,
"
fdatasync"
,
"
n/a
\n
"
);
printf
(
NA_FORMAT
,
"n/a
\n
"
);
#endif
/*
...
...
@@ -292,10 +271,10 @@ test_sync(int writes_per_op)
/*
* If fsync_writethrough is available, test as well
*/
#ifdef HAVE_FSYNC_WRITETHROUGH
printf
(
LABEL_FORMAT
,
"fsync_writethrough"
);
fflush
(
stdout
);
#ifdef HAVE_FSYNC_WRITETHROUGH
if
((
tmpfile
=
open
(
filename
,
O_RDWR
,
0
))
==
-
1
)
die
(
"could not open output file"
);
gettimeofday
(
&
start_t
,
NULL
);
...
...
@@ -313,49 +292,23 @@ test_sync(int writes_per_op)
close
(
tmpfile
);
print_elapse
(
start_t
,
stop_t
);
#else
printf
(
NA_FORMAT
,
"
fsync_writethrough"
,
"
n/a
\n
"
);
printf
(
NA_FORMAT
,
"n/a
\n
"
);
#endif
/*
* Test open_sync if available
*/
#ifdef OPEN_SYNC_FLAG
printf
(
LABEL_FORMAT
,
"open_sync"
#if PG_O_DIRECT != 0
" (non-direct I/O)*"
#endif
);
printf
(
LABEL_FORMAT
,
"open_sync"
);
fflush
(
stdout
);
if
((
tmpfile
=
open
(
filename
,
O_RDWR
|
OPEN_SYNC_FLAG
,
0
))
==
-
1
)
die
(
"could not open output file"
);
gettimeofday
(
&
start_t
,
NULL
);
for
(
ops
=
0
;
ops
<
ops_per_test
;
ops
++
)
{
for
(
writes
=
0
;
writes
<
writes_per_op
;
writes
++
)
if
(
write
(
tmpfile
,
buf
,
XLOG_BLCKSZ
)
!=
XLOG_BLCKSZ
)
die
(
"write failed"
);
if
(
lseek
(
tmpfile
,
0
,
SEEK_SET
)
==
-
1
)
die
(
"seek failed"
);
}
gettimeofday
(
&
stop_t
,
NULL
);
close
(
tmpfile
);
print_elapse
(
start_t
,
stop_t
);
/*
* If O_DIRECT is enabled, test that with open_sync
*/
#if PG_O_DIRECT != 0
#ifdef OPEN_SYNC_FLAG
if
((
tmpfile
=
open
(
filename
,
O_RDWR
|
OPEN_SYNC_FLAG
|
PG_O_DIRECT
,
0
))
==
-
1
)
{
printf
(
NA_FORMAT
,
"
o_direct"
,
"n/a*
*
\n
"
);
printf
(
NA_FORMAT
,
"
n/a
*
\n
"
);
fs_warning
=
true
;
}
else
{
printf
(
LABEL_FORMAT
,
"open_sync (direct I/O)"
);
fflush
(
stdout
);
gettimeofday
(
&
start_t
,
NULL
);
for
(
ops
=
0
;
ops
<
ops_per_test
;
ops
++
)
{
...
...
@@ -369,20 +322,13 @@ test_sync(int writes_per_op)
close
(
tmpfile
);
print_elapse
(
start_t
,
stop_t
);
}
#endif
#else
printf
(
NA_FORMAT
,
"open_sync"
,
"n/a
\n
"
);
#endif
#if defined(OPEN_DATASYNC_FLAG) || defined(OPEN_SYNC_FLAG)
if
(
PG_O_DIRECT
!=
0
)
printf
(
"* This non-direct I/O mode is not used by Postgres.
\n
"
);
printf
(
NA_FORMAT
,
"n/a
\n
"
);
#endif
if
(
fs_warning
)
{
printf
(
"*
*
This file system and its mount options do not support direct
\n
"
);
printf
(
"* This file system and its mount options do not support direct
\n
"
);
printf
(
"I/O, e.g. ext4 in journaled mode.
\n
"
);
}
}
...
...
@@ -407,16 +353,16 @@ test_open_syncs(void)
static
void
test_open_sync
(
const
char
*
msg
,
int
writes_size
)
{
#ifdef OPEN_SYNC_FLAG
int
tmpfile
,
ops
,
writes
;
printf
(
LABEL_FORMAT
,
msg
);
fflush
(
stdout
);
#ifdef OPEN_SYNC_FLAG
if
((
tmpfile
=
open
(
filename
,
O_RDWR
|
OPEN_SYNC_FLAG
|
PG_O_DIRECT
,
0
))
==
-
1
)
printf
(
NA_FORMAT
,
"
o_direct"
,
"n/a*
*
\n
"
);
printf
(
NA_FORMAT
,
"
n/a
*
\n
"
);
else
{
printf
(
LABEL_FORMAT
,
msg
);
fflush
(
stdout
);
gettimeofday
(
&
start_t
,
NULL
);
for
(
ops
=
0
;
ops
<
ops_per_test
;
ops
++
)
{
...
...
@@ -433,7 +379,7 @@ test_open_sync(const char *msg, int writes_size)
}
#else
printf
(
NA_FORMAT
,
"
open_sync"
,
"
n/a
\n
"
);
printf
(
NA_FORMAT
,
"n/a
\n
"
);
#endif
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录