Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Metz
oceanbase
提交
18070dfc
O
oceanbase
项目概览
Metz
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
18070dfc
编写于
7月 16, 2021
作者:
O
obdev
提交者:
wangzelin.wzl
7月 16, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support punch hole on block_file
上级
3a827ef0
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
44 addition
and
1 deletion
+44
-1
src/share/parameter/ob_parameter_seed.ipp
src/share/parameter/ob_parameter_seed.ipp
+4
-0
src/storage/blocksstable/ob_local_file_system.h
src/storage/blocksstable/ob_local_file_system.h
+2
-0
src/storage/blocksstable/ob_store_file.cpp
src/storage/blocksstable/ob_store_file.cpp
+36
-1
src/storage/blocksstable/ob_store_file.h
src/storage/blocksstable/ob_store_file.h
+2
-0
未找到文件。
src/share/parameter/ob_parameter_seed.ipp
浏览文件 @
18070dfc
...
...
@@ -1452,3 +1452,7 @@ DEF_BOOL(_auto_drop_tenant_if_restore_failed, OB_CLUSTER_PARAMETER, "True",
DEF_BOOL(ob_proxy_readonly_transaction_routing_policy, OB_TENANT_PARAMETER, "true",
"Proxy route policy for readonly sql",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
DEF_BOOL(_enable_block_file_punch_hole, OB_CLUSTER_PARAMETER, "False",
"specifies whether to punch whole when free blocks in block_file",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
src/storage/blocksstable/ob_local_file_system.h
浏览文件 @
18070dfc
...
...
@@ -113,6 +113,8 @@ public:
virtual
int
get_super_block_version
(
int64_t
&
super_block_version
)
override
;
virtual
int
resize_file
(
const
int64_t
new_data_file_size
,
const
int64_t
new_data_file_disk_percentage
)
override
;
OB_INLINE
int
get_block_file_fd
()
const
{
return
fd_
.
fd_
;
}
TO_STRING_KV
(
"type"
,
"LOCAL"
);
private:
...
...
src/storage/blocksstable/ob_store_file.cpp
浏览文件 @
18070dfc
...
...
@@ -11,6 +11,7 @@
*/
#define USING_LOG_PREFIX STORAGE
#include <linux/falloc.h>
#include "ob_store_file.h"
#include "lib/file/file_directory_utils.h"
#include "share/config/ob_server_config.h"
...
...
@@ -410,7 +411,9 @@ ObStoreFile::ObStoreFile()
store_file_system_
(
NULL
),
is_mark_sweep_enabled_
(
false
),
is_doing_mark_sweep_
(
false
),
cond_
()
cond_
(),
is_fs_support_punch_hole_
(
true
),
block_file_fd_
(
OB_INVALID_FD
)
{
MEMSET
(
used_macro_cnt_
,
0
,
sizeof
(
used_macro_cnt_
));
}
...
...
@@ -430,6 +433,7 @@ int ObStoreFile::init(const ObStorageEnv& storage_env, ObStoreFileSystem* store_
{
int
ret
=
OB_SUCCESS
;
ObLogCursor
replay_start_cursor
;
ObLocalFileSystem
*
local_fs
=
nullptr
;
if
(
OB_UNLIKELY
(
is_inited_
))
{
ret
=
OB_INIT_TWICE
;
...
...
@@ -446,9 +450,17 @@ int ObStoreFile::init(const ObStorageEnv& storage_env, ObStoreFileSystem* store_
STORAGE_LOG
(
WARN
,
"Fail to allocate memory, "
,
K
(
ret
),
K_
(
print_buffer_size
));
}
else
if
(
OB_FAIL
(
cond_
.
init
(
common
::
ObWaitEventIds
::
DEFAULT_COND_WAIT
)))
{
STORAGE_LOG
(
WARN
,
"fail to init thread cond"
,
K
(
ret
));
}
else
if
(
FALSE_IT
(
local_fs
=
dynamic_cast
<
ObLocalFileSystem
*>
(
store_file_system
)))
{
}
else
{
store_file_system_
=
store_file_system
;
if
(
nullptr
!=
local_fs
)
{
block_file_fd_
=
local_fs
->
get_block_file_fd
();
is_fs_support_punch_hole_
=
true
;
}
else
{
is_fs_support_punch_hole_
=
false
;
}
if
(
OB_SUCC
(
ret
))
{
if
(
OB_FAIL
(
alloc_memory
(
store_file_system_
->
get_total_macro_block_count
(),
free_block_array_
,
...
...
@@ -580,6 +592,8 @@ void ObStoreFile::destroy()
is_mark_sweep_enabled_
=
false
;
is_doing_mark_sweep_
=
false
;
cond_
.
destroy
();
is_fs_support_punch_hole_
=
true
;
block_file_fd_
=
OB_INVALID_FD
;
}
void
ObStoreFile
::
stop
()
...
...
@@ -1021,6 +1035,27 @@ void ObStoreFile::free_block(const uint32_t block_idx, bool& is_freed)
free_block_array_
[
free_block_push_pos_
]
=
block_idx
;
free_block_push_pos_
=
(
free_block_push_pos_
+
1
)
%
store_file_system_
->
get_total_macro_block_count
();
++
free_block_cnt_
;
// punch hole
if
(
is_fs_support_punch_hole_
&&
GCONF
.
_enable_block_file_punch_hole
)
{
const
int64_t
len
=
store_file_system_
->
get_macro_block_size
();
const
int64_t
offset
=
store_file_system_
->
get_macro_block_size
()
*
block_idx
;
const
int
sys_ret
=
::
fallocate
(
block_file_fd_
,
FALLOC_FL_PUNCH_HOLE
|
FALLOC_FL_KEEP_SIZE
,
offset
,
len
);
if
(
sys_ret
<
0
)
{
const
int
sys_err
=
errno
;
if
(
EOPNOTSUPP
==
sys_err
)
{
// The file system containing the file referred to by fd does
// not support this operation; or the mode is not supported
// by the file system containing the file referred to by fd.
is_fs_support_punch_hole_
=
false
;
SHARE_LOG
(
WARN
,
"Punch hole not support"
,
K
(
block_idx
),
K
(
offset
),
K
(
len
),
K
(
sys_ret
),
K
(
sys_err
),
KERRMSG
);
}
else
{
SHARE_LOG
(
ERROR
,
"Punch hole fail"
,
K
(
block_idx
),
K
(
offset
),
K
(
len
),
K
(
sys_ret
),
K
(
sys_err
),
KERRMSG
);
}
}
else
{
SHARE_LOG
(
INFO
,
"Punch hole success"
,
K
(
block_idx
),
K
(
offset
),
K
(
len
));
}
}
}
}
...
...
src/storage/blocksstable/ob_store_file.h
浏览文件 @
18070dfc
...
...
@@ -432,6 +432,8 @@ private:
bool
is_mark_sweep_enabled_
;
bool
is_doing_mark_sweep_
;
ObThreadCond
cond_
;
// for mark sweep
bool
is_fs_support_punch_hole_
;
int
block_file_fd_
;
};
OB_INLINE
bool
ObStoreFile
::
is_valid
(
const
MacroBlockId
macro_id
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录