Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
3e1ad54f
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
3e1ad54f
编写于
5月 07, 2007
作者:
C
Chris Mason
提交者:
David Woodhouse
5月 07, 2007
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Btrfs: allocator and tuning
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
be744175
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
42 deletion
+34
-42
fs/btrfs/ctree.h
fs/btrfs/ctree.h
+1
-0
fs/btrfs/extent-tree.c
fs/btrfs/extent-tree.c
+33
-42
未找到文件。
fs/btrfs/ctree.h
浏览文件 @
3e1ad54f
...
...
@@ -255,6 +255,7 @@ struct btrfs_block_group_item {
struct
btrfs_block_group_cache
{
struct
btrfs_key
key
;
struct
btrfs_block_group_item
item
;
struct
radix_tree_root
*
radix
;
u64
first_free
;
u64
last_alloc
;
u64
pinned
;
...
...
fs/btrfs/extent-tree.c
浏览文件 @
3e1ad54f
...
...
@@ -23,7 +23,7 @@ static struct btrfs_block_group_cache *lookup_block_group(struct
(
void
**
)
&
block_group
,
blocknr
,
1
);
if
(
ret
)
{
if
(
block_group
->
key
.
objectid
<=
blocknr
&&
blocknr
<
if
(
block_group
->
key
.
objectid
<=
blocknr
&&
blocknr
<
=
block_group
->
key
.
objectid
+
block_group
->
key
.
offset
)
return
block_group
;
}
...
...
@@ -31,11 +31,16 @@ static struct btrfs_block_group_cache *lookup_block_group(struct
(
void
**
)
&
block_group
,
blocknr
,
1
);
if
(
ret
)
{
if
(
block_group
->
key
.
objectid
<=
blocknr
&&
blocknr
<
if
(
block_group
->
key
.
objectid
<=
blocknr
&&
blocknr
<
=
block_group
->
key
.
objectid
+
block_group
->
key
.
offset
)
return
block_group
;
}
printk
(
"lookup_block_group fails for blocknr %Lu
\n
"
,
blocknr
);
WARN_ON
(
1
);
printk
(
"lookup_block_group fails for blocknr %Lu
\n
"
,
blocknr
);
printk
(
"last ret was %d
\n
"
,
ret
);
if
(
ret
)
{
printk
(
"last block group was %Lu %Lu
\n
"
,
block_group
->
key
.
objectid
,
block_group
->
key
.
offset
);
}
return
NULL
;
}
...
...
@@ -356,45 +361,20 @@ static int update_block_group(struct btrfs_trans_handle *trans,
{
struct
btrfs_block_group_cache
*
cache
;
struct
btrfs_fs_info
*
info
=
root
->
fs_info
;
struct
radix_tree_root
*
radix
;
u64
total
=
num
;
u64
old_val
;
u64
block_in_group
;
int
ret
;
if
(
num
!=
1
)
radix
=
&
info
->
block_group_data_radix
;
else
radix
=
&
info
->
block_group_radix
;
while
(
total
)
{
ret
=
radix_tree_gang_lookup
(
radix
,
(
void
**
)
&
cache
,
blocknr
,
1
);
if
(
!
ret
)
{
cache
=
lookup_block_group
(
info
,
blocknr
);
if
(
!
cache
)
{
printk
(
KERN_CRIT
"blocknr %Lu lookup failed
\n
"
,
blocknr
);
return
-
1
;
}
block_in_group
=
blocknr
-
cache
->
key
.
objectid
;
if
(
block_in_group
>
cache
->
key
.
offset
||
cache
->
key
.
objectid
>
blocknr
)
{
if
(
radix
==
&
info
->
block_group_data_radix
)
radix
=
&
info
->
block_group_radix
;
else
radix
=
&
info
->
block_group_data_radix
;
ret
=
radix_tree_gang_lookup
(
radix
,
(
void
**
)
&
cache
,
blocknr
,
1
);
if
(
!
ret
)
{
printk
(
KERN_CRIT
"blocknr %Lu lookup failed
\n
"
,
blocknr
);
return
-
1
;
}
block_in_group
=
blocknr
-
cache
->
key
.
objectid
;
if
(
block_in_group
>
cache
->
key
.
offset
||
cache
->
key
.
objectid
>
blocknr
)
{
BUG
();
}
}
WARN_ON
(
block_in_group
>
cache
->
key
.
offset
);
radix_tree_tag_set
(
radix
,
cache
->
key
.
objectid
+
radix_tree_tag_set
(
cache
->
radix
,
cache
->
key
.
objectid
+
cache
->
key
.
offset
-
1
,
BTRFS_BLOCK_GROUP_DIRTY
);
...
...
@@ -693,6 +673,8 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
num_blocks
=
1
;
total_needed
=
(
min
(
level
+
1
,
BTRFS_MAX_LEVEL
)
+
2
)
*
3
;
}
if
(
search_end
==
(
u64
)
-
1
)
search_end
=
btrfs_super_total_blocks
(
info
->
disk_super
);
if
(
search_start
)
{
block_group
=
lookup_block_group
(
info
,
search_start
);
block_group
=
btrfs_find_block_group
(
root
,
block_group
,
...
...
@@ -704,7 +686,7 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
}
check_failed:
if
(
block_group
->
data
!=
data
)
if
(
!
full_scan
&&
block_group
->
data
!=
data
)
WARN_ON
(
1
);
if
(
block_group
->
last_alloc
>
search_start
)
search_start
=
block_group
->
last_alloc
;
...
...
@@ -734,13 +716,13 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
goto
error
;
if
(
!
start_found
)
{
ins
->
objectid
=
search_start
;
ins
->
offset
=
(
u64
)
-
1
-
search_start
;
ins
->
offset
=
search_end
-
search_start
;
start_found
=
1
;
goto
check_pending
;
}
ins
->
objectid
=
last_block
>
search_start
?
last_block
:
search_start
;
ins
->
offset
=
(
u64
)
-
1
-
ins
->
objectid
;
ins
->
offset
=
search_end
-
ins
->
objectid
;
goto
check_pending
;
}
btrfs_disk_key_to_cpu
(
&
key
,
&
l
->
items
[
slot
].
key
);
...
...
@@ -777,7 +759,7 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
*/
btrfs_release_path
(
root
,
path
);
BUG_ON
(
ins
->
objectid
<
search_start
);
if
(
ins
->
objectid
>=
btrfs_super_total_blocks
(
info
->
disk_super
)
)
{
if
(
ins
->
objectid
+
num_blocks
>=
search_end
)
{
if
(
full_scan
)
return
-
ENOSPC
;
search_start
=
orig_search_start
;
...
...
@@ -840,7 +822,7 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
return
0
;
new_group:
if
(
search_start
>=
btrfs_super_total_blocks
(
info
->
disk_super
)
)
{
if
(
search_start
+
num_blocks
>=
search_end
)
{
search_start
=
orig_search_start
;
full_scan
=
1
;
}
...
...
@@ -900,7 +882,12 @@ int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
return
ret
;
/* then do prealloc for the extent tree */
ret
=
find_free_extent
(
trans
,
root
,
0
,
ins
->
objectid
+
ins
->
offset
,
if
(
ins
->
objectid
+
ins
->
offset
>=
search_end
)
search_end
=
ins
->
objectid
-
1
;
else
search_start
=
ins
->
objectid
+
ins
->
offset
;
ret
=
find_free_extent
(
trans
,
root
,
0
,
search_start
,
search_end
,
&
prealloc_key
,
0
);
if
(
ret
)
return
ret
;
...
...
@@ -1198,6 +1185,12 @@ int btrfs_read_block_groups(struct btrfs_root *root)
err
=
-
1
;
break
;
}
if
(
nr
&
1
)
radix
=
&
info
->
block_group_data_radix
;
else
radix
=
&
info
->
block_group_radix
;
bi
=
btrfs_item_ptr
(
leaf
,
path
->
slots
[
0
],
struct
btrfs_block_group_item
);
memcpy
(
&
cache
->
item
,
bi
,
sizeof
(
*
bi
));
...
...
@@ -1206,12 +1199,10 @@ int btrfs_read_block_groups(struct btrfs_root *root)
cache
->
first_free
=
cache
->
key
.
objectid
;
cache
->
pinned
=
0
;
cache
->
data
=
(
nr
&
1
);
cache
->
radix
=
radix
;
key
.
objectid
=
found_key
.
objectid
+
found_key
.
offset
;
btrfs_release_path
(
root
,
path
);
if
(
nr
&
1
)
radix
=
&
info
->
block_group_data_radix
;
else
radix
=
&
info
->
block_group_radix
;
ret
=
radix_tree_insert
(
radix
,
found_key
.
objectid
+
found_key
.
offset
-
1
,
(
void
*
)
cache
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录