Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Linux-御风守护者
linux
提交
80ea96b1
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,发现更多精彩内容 >>
提交
80ea96b1
编写于
2月 01, 2008
作者:
C
Chris Mason
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Btrfs: Add a lookup cache to the extent state tree
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
4529ba49
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
17 deletion
+41
-17
fs/btrfs/extent_io.c
fs/btrfs/extent_io.c
+40
-17
fs/btrfs/extent_io.h
fs/btrfs/extent_io.h
+1
-0
未找到文件。
fs/btrfs/extent_io.c
浏览文件 @
80ea96b1
...
...
@@ -90,6 +90,7 @@ void extent_io_tree_init(struct extent_io_tree *tree,
tree
->
mapping
=
mapping
;
INIT_LIST_HEAD
(
&
tree
->
buffer_lru
);
tree
->
lru_size
=
0
;
tree
->
last
=
NULL
;
}
EXPORT_SYMBOL
(
extent_io_tree_init
);
...
...
@@ -158,16 +159,23 @@ static struct rb_node *tree_insert(struct rb_root *root, u64 offset,
return
NULL
;
}
static
struct
rb_node
*
__
tree_search
(
struct
rb_root
*
root
,
u64
offset
,
static
struct
rb_node
*
__
etree_search
(
struct
extent_io_tree
*
tree
,
u64
offset
,
struct
rb_node
**
prev_ret
,
struct
rb_node
**
next_ret
)
{
struct
rb_root
*
root
=
&
tree
->
state
;
struct
rb_node
*
n
=
root
->
rb_node
;
struct
rb_node
*
prev
=
NULL
;
struct
rb_node
*
orig_prev
=
NULL
;
struct
tree_entry
*
entry
;
struct
tree_entry
*
prev_entry
=
NULL
;
if
(
tree
->
last
)
{
struct
extent_state
*
state
;
state
=
tree
->
last
;
if
(
state
->
start
<=
offset
&&
offset
<=
state
->
end
)
return
&
tree
->
last
->
rb_node
;
}
while
(
n
)
{
entry
=
rb_entry
(
n
,
struct
tree_entry
,
rb_node
);
prev
=
n
;
...
...
@@ -177,8 +185,10 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset,
n
=
n
->
rb_left
;
else
if
(
offset
>
entry
->
end
)
n
=
n
->
rb_right
;
else
else
{
tree
->
last
=
rb_entry
(
n
,
struct
extent_state
,
rb_node
);
return
n
;
}
}
if
(
prev_ret
)
{
...
...
@@ -202,14 +212,20 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset,
return
NULL
;
}
static
inline
struct
rb_node
*
tree_search
(
struct
rb_root
*
root
,
u64
offset
)
static
inline
struct
rb_node
*
tree_search
(
struct
extent_io_tree
*
tree
,
u64
offset
)
{
struct
rb_node
*
prev
=
NULL
;
struct
rb_node
*
ret
;
ret
=
__tree_search
(
root
,
offset
,
&
prev
,
NULL
);
if
(
!
ret
)
ret
=
__etree_search
(
tree
,
offset
,
&
prev
,
NULL
);
if
(
!
ret
)
{
if
(
prev
)
{
tree
->
last
=
rb_entry
(
prev
,
struct
extent_state
,
rb_node
);
}
return
prev
;
}
return
ret
;
}
...
...
@@ -238,6 +254,8 @@ static int merge_state(struct extent_io_tree *tree,
other
->
state
==
state
->
state
)
{
state
->
start
=
other
->
start
;
other
->
tree
=
NULL
;
if
(
tree
->
last
==
other
)
tree
->
last
=
NULL
;
rb_erase
(
&
other
->
rb_node
,
&
tree
->
state
);
free_extent_state
(
other
);
}
...
...
@@ -249,6 +267,8 @@ static int merge_state(struct extent_io_tree *tree,
other
->
state
==
state
->
state
)
{
other
->
start
=
state
->
start
;
state
->
tree
=
NULL
;
if
(
tree
->
last
==
state
)
tree
->
last
=
NULL
;
rb_erase
(
&
state
->
rb_node
,
&
tree
->
state
);
free_extent_state
(
state
);
}
...
...
@@ -311,6 +331,7 @@ static int insert_state(struct extent_io_tree *tree,
return
-
EEXIST
;
}
state
->
tree
=
tree
;
tree
->
last
=
state
;
merge_state
(
tree
,
state
);
return
0
;
}
...
...
@@ -375,6 +396,8 @@ static int clear_state_bit(struct extent_io_tree *tree,
wake_up
(
&
state
->
wq
);
if
(
delete
||
state
->
state
==
0
)
{
if
(
state
->
tree
)
{
if
(
tree
->
last
==
state
)
tree
->
last
=
NULL
;
rb_erase
(
&
state
->
rb_node
,
&
tree
->
state
);
state
->
tree
=
NULL
;
free_extent_state
(
state
);
...
...
@@ -422,7 +445,7 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
* this search will find the extents that end after
* our range starts
*/
node
=
tree_search
(
&
tree
->
stat
e
,
start
);
node
=
tree_search
(
tre
e
,
start
);
if
(
!
node
)
goto
out
;
state
=
rb_entry
(
node
,
struct
extent_state
,
rb_node
);
...
...
@@ -533,7 +556,7 @@ int wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits)
* this search will find all the extents that end after
* our range starts
*/
node
=
tree_search
(
&
tree
->
stat
e
,
start
);
node
=
tree_search
(
tre
e
,
start
);
if
(
!
node
)
break
;
...
...
@@ -612,7 +635,7 @@ int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits,
* this search will find all the extents that end after
* our range starts.
*/
node
=
tree_search
(
&
tree
->
stat
e
,
start
);
node
=
tree_search
(
tre
e
,
start
);
if
(
!
node
)
{
err
=
insert_state
(
tree
,
prealloc
,
start
,
end
,
bits
);
prealloc
=
NULL
;
...
...
@@ -915,7 +938,7 @@ int find_first_extent_bit(struct extent_io_tree *tree, u64 start,
* this search will find all the extents that end after
* our range starts.
*/
node
=
tree_search
(
&
tree
->
stat
e
,
start
);
node
=
tree_search
(
tre
e
,
start
);
if
(
!
node
||
IS_ERR
(
node
))
{
goto
out
;
}
...
...
@@ -953,7 +976,7 @@ u64 find_lock_delalloc_range(struct extent_io_tree *tree,
* our range starts.
*/
search_again:
node
=
tree_search
(
&
tree
->
stat
e
,
cur_start
);
node
=
tree_search
(
tre
e
,
cur_start
);
if
(
!
node
||
IS_ERR
(
node
))
{
*
end
=
(
u64
)
-
1
;
goto
out
;
...
...
@@ -1041,7 +1064,7 @@ u64 count_range_bits(struct extent_io_tree *tree,
* this search will find all the extents that end after
* our range starts.
*/
node
=
tree_search
(
&
tree
->
stat
e
,
cur_start
);
node
=
tree_search
(
tre
e
,
cur_start
);
if
(
!
node
||
IS_ERR
(
node
))
{
goto
out
;
}
...
...
@@ -1142,7 +1165,7 @@ int set_state_private(struct extent_io_tree *tree, u64 start, u64 private)
* this search will find all the extents that end after
* our range starts.
*/
node
=
tree_search
(
&
tree
->
stat
e
,
start
);
node
=
tree_search
(
tre
e
,
start
);
if
(
!
node
||
IS_ERR
(
node
))
{
ret
=
-
ENOENT
;
goto
out
;
...
...
@@ -1169,7 +1192,7 @@ int get_state_private(struct extent_io_tree *tree, u64 start, u64 *private)
* this search will find all the extents that end after
* our range starts.
*/
node
=
tree_search
(
&
tree
->
stat
e
,
start
);
node
=
tree_search
(
tre
e
,
start
);
if
(
!
node
||
IS_ERR
(
node
))
{
ret
=
-
ENOENT
;
goto
out
;
...
...
@@ -1200,7 +1223,7 @@ int test_range_bit(struct extent_io_tree *tree, u64 start, u64 end,
unsigned
long
flags
;
spin_lock_irqsave
(
&
tree
->
lock
,
flags
);
node
=
tree_search
(
&
tree
->
stat
e
,
start
);
node
=
tree_search
(
tre
e
,
start
);
while
(
node
&&
start
<=
end
)
{
state
=
rb_entry
(
node
,
struct
extent_state
,
rb_node
);
...
...
@@ -1348,7 +1371,7 @@ static int end_bio_extent_writepage(struct bio *bio,
spin_lock_irqsave
(
&
tree
->
lock
,
flags
);
if
(
!
state
||
state
->
end
!=
end
)
{
state
=
NULL
;
node
=
__
tree_search
(
&
tree
->
stat
e
,
start
,
NULL
,
NULL
);
node
=
__
etree_search
(
tre
e
,
start
,
NULL
,
NULL
);
if
(
node
)
{
state
=
rb_entry
(
node
,
struct
extent_state
,
rb_node
);
...
...
@@ -1468,7 +1491,7 @@ static int end_bio_extent_readpage(struct bio *bio,
spin_lock_irqsave
(
&
tree
->
lock
,
flags
);
if
(
!
state
||
state
->
end
!=
end
)
{
state
=
NULL
;
node
=
__
tree_search
(
&
tree
->
stat
e
,
start
,
NULL
,
NULL
);
node
=
__
etree_search
(
tre
e
,
start
,
NULL
,
NULL
);
if
(
node
)
{
state
=
rb_entry
(
node
,
struct
extent_state
,
rb_node
);
...
...
@@ -1631,7 +1654,7 @@ static int submit_one_bio(int rw, struct bio *bio)
end
=
start
+
bvec
->
bv_len
-
1
;
spin_lock_irq
(
&
tree
->
lock
);
node
=
__
tree_search
(
&
tree
->
stat
e
,
start
,
NULL
,
NULL
);
node
=
__
etree_search
(
tre
e
,
start
,
NULL
,
NULL
);
BUG_ON
(
!
node
);
state
=
rb_entry
(
node
,
struct
extent_state
,
rb_node
);
while
(
state
->
end
<
end
)
{
...
...
fs/btrfs/extent_io.h
浏览文件 @
80ea96b1
...
...
@@ -48,6 +48,7 @@ struct extent_io_tree {
spinlock_t
lru_lock
;
struct
list_head
buffer_lru
;
int
lru_size
;
struct
extent_state
*
last
;
};
struct
extent_state
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录