Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Linux-御风守护者
linux
提交
2cc58cf2
L
linux
项目概览
Linux-御风守护者
/
linux
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2cc58cf2
编写于
8月 27, 2007
作者:
C
Chris Mason
提交者:
David Woodhouse
8月 27, 2007
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Btrfs: Do more extensive readahead during tree searches
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
32020611
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
16 deletion
+52
-16
fs/btrfs/ctree.c
fs/btrfs/ctree.c
+49
-13
fs/btrfs/extent-tree.c
fs/btrfs/extent-tree.c
+2
-2
fs/btrfs/inode.c
fs/btrfs/inode.c
+1
-1
未找到文件。
fs/btrfs/ctree.c
浏览文件 @
2cc58cf2
...
...
@@ -43,8 +43,10 @@ struct btrfs_path *btrfs_alloc_path(void)
{
struct
btrfs_path
*
path
;
path
=
kmem_cache_alloc
(
btrfs_path_cachep
,
GFP_NOFS
);
if
(
path
)
if
(
path
)
{
btrfs_init_path
(
path
);
path
->
reada
=
1
;
}
return
path
;
}
...
...
@@ -159,6 +161,34 @@ static int close_blocks(u64 blocknr, u64 other)
return
0
;
}
static
int
should_defrag_leaf
(
struct
buffer_head
*
bh
)
{
struct
btrfs_leaf
*
leaf
=
btrfs_buffer_leaf
(
bh
);
struct
btrfs_disk_key
*
key
;
u32
nritems
;
if
(
buffer_defrag
(
bh
))
return
1
;
nritems
=
btrfs_header_nritems
(
&
leaf
->
header
);
if
(
nritems
==
0
)
return
0
;
key
=
&
leaf
->
items
[
0
].
key
;
if
(
btrfs_disk_key_type
(
key
)
==
BTRFS_DIR_ITEM_KEY
)
return
1
;
key
=
&
leaf
->
items
[
nritems
-
1
].
key
;
if
(
btrfs_disk_key_type
(
key
)
==
BTRFS_DIR_ITEM_KEY
)
return
1
;
if
(
nritems
>
4
)
{
key
=
&
leaf
->
items
[
nritems
/
2
].
key
;
if
(
btrfs_disk_key_type
(
key
)
==
BTRFS_DIR_ITEM_KEY
)
return
1
;
}
return
0
;
}
int
btrfs_realloc_node
(
struct
btrfs_trans_handle
*
trans
,
struct
btrfs_root
*
root
,
struct
buffer_head
*
parent
,
int
cache_only
,
u64
*
last_ret
)
...
...
@@ -217,7 +247,9 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
cur_bh
=
btrfs_find_tree_block
(
root
,
blocknr
);
if
(
!
cur_bh
||
!
buffer_uptodate
(
cur_bh
)
||
buffer_locked
(
cur_bh
)
||
!
buffer_defrag
(
cur_bh
))
{
buffer_locked
(
cur_bh
)
||
(
parent_level
!=
1
&&
!
buffer_defrag
(
cur_bh
))
||
(
parent_level
==
1
&&
!
should_defrag_leaf
(
cur_bh
)))
{
if
(
cache_only
)
{
brelse
(
cur_bh
);
continue
;
...
...
@@ -297,6 +329,7 @@ static int check_node(struct btrfs_root *root, struct btrfs_path *path,
parent
=
btrfs_buffer_node
(
path
->
nodes
[
level
+
1
]);
slot
=
path
->
slots
[
level
];
BUG_ON
(
!
buffer_uptodate
(
path
->
nodes
[
level
]));
BUG_ON
(
nritems
==
0
);
if
(
parent
)
{
struct
btrfs_disk_key
*
parent_key
;
...
...
@@ -511,9 +544,6 @@ static int balance_level(struct btrfs_trans_handle *trans, struct btrfs_root
err_on_enospc
=
1
;
left_buf
=
read_node_slot
(
root
,
parent_buf
,
pslot
-
1
);
right_buf
=
read_node_slot
(
root
,
parent_buf
,
pslot
+
1
);
/* first, try to make some room in the middle buffer */
if
(
left_buf
)
{
wret
=
btrfs_cow_block
(
trans
,
root
,
left_buf
,
parent_buf
,
pslot
-
1
,
&
left_buf
);
...
...
@@ -521,6 +551,19 @@ static int balance_level(struct btrfs_trans_handle *trans, struct btrfs_root
ret
=
wret
;
goto
enospc
;
}
}
right_buf
=
read_node_slot
(
root
,
parent_buf
,
pslot
+
1
);
if
(
right_buf
)
{
wret
=
btrfs_cow_block
(
trans
,
root
,
right_buf
,
parent_buf
,
pslot
+
1
,
&
right_buf
);
if
(
wret
)
{
ret
=
wret
;
goto
enospc
;
}
}
/* first, try to make some room in the middle buffer */
if
(
left_buf
)
{
left
=
btrfs_buffer_node
(
left_buf
);
orig_slot
+=
btrfs_header_nritems
(
&
left
->
header
);
wret
=
push_node_left
(
trans
,
root
,
left_buf
,
mid_buf
);
...
...
@@ -534,13 +577,6 @@ static int balance_level(struct btrfs_trans_handle *trans, struct btrfs_root
* then try to empty the right most buffer into the middle
*/
if
(
right_buf
)
{
wret
=
btrfs_cow_block
(
trans
,
root
,
right_buf
,
parent_buf
,
pslot
+
1
,
&
right_buf
);
if
(
wret
)
{
ret
=
wret
;
goto
enospc
;
}
right
=
btrfs_buffer_node
(
right_buf
);
wret
=
push_node_left
(
trans
,
root
,
mid_buf
,
right_buf
);
if
(
wret
<
0
&&
wret
!=
-
ENOSPC
)
...
...
@@ -817,7 +853,7 @@ static void reada_for_search(struct btrfs_root *root, struct btrfs_path *path,
for
(
i
=
0
;
i
<
ret
;
i
++
)
{
blocknr
=
gang
[
i
];
clear_radix_bit
(
&
found
,
blocknr
);
if
(
nread
>
32
)
if
(
path
->
reada
==
1
&&
nread
>
16
)
continue
;
if
(
close_blocks
(
cluster_start
,
blocknr
))
{
readahead_tree_block
(
root
,
blocknr
);
...
...
fs/btrfs/extent-tree.c
浏览文件 @
2cc58cf2
...
...
@@ -52,7 +52,7 @@ static int cache_block_group(struct btrfs_root *root,
path
=
btrfs_alloc_path
();
if
(
!
path
)
return
-
ENOMEM
;
path
->
reada
=
1
;
path
->
reada
=
2
;
key
.
objectid
=
block_group
->
key
.
objectid
;
key
.
flags
=
0
;
key
.
offset
=
0
;
...
...
@@ -1015,7 +1015,7 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
ins
->
objectid
=
search_start
;
ins
->
offset
=
0
;
start_found
=
0
;
path
->
reada
=
1
;
path
->
reada
=
2
;
ret
=
btrfs_search_slot
(
trans
,
root
,
ins
,
path
,
0
,
0
);
if
(
ret
<
0
)
...
...
fs/btrfs/inode.c
浏览文件 @
2cc58cf2
...
...
@@ -827,7 +827,7 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
btrfs_set_key_type
(
&
key
,
key_type
);
key
.
offset
=
filp
->
f_pos
;
path
=
btrfs_alloc_path
();
path
->
reada
=
1
;
path
->
reada
=
2
;
ret
=
btrfs_search_slot
(
NULL
,
root
,
&
key
,
path
,
0
,
0
);
if
(
ret
<
0
)
goto
err
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录