Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gsplhtlxg
clone-Linux
提交
20524f02
C
clone-Linux
项目概览
gsplhtlxg
/
clone-Linux
通知
2
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
clone-Linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
20524f02
编写于
3月 10, 2007
作者:
C
Chris Mason
提交者:
David Woodhouse
3月 10, 2007
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Btrfs: recursion free-first pass
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
0579da42
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
100 addition
and
3 deletion
+100
-3
fs/btrfs/extent-tree.c
fs/btrfs/extent-tree.c
+96
-2
fs/btrfs/quick-test.c
fs/btrfs/quick-test.c
+4
-1
未找到文件。
fs/btrfs/extent-tree.c
浏览文件 @
20524f02
...
...
@@ -50,7 +50,7 @@ static int inc_block_ref(struct ctree_root *root, u64 blocknr)
return
0
;
}
static
int
lookup_block_ref
(
struct
ctree_root
*
root
,
u64
blocknr
,
int
*
refs
)
static
int
lookup_block_ref
(
struct
ctree_root
*
root
,
u64
blocknr
,
u32
*
refs
)
{
struct
ctree_path
path
;
int
ret
;
...
...
@@ -415,6 +415,100 @@ struct tree_buffer *alloc_free_block(struct ctree_root *root)
return
buf
;
}
int
walk_down_tree
(
struct
ctree_root
*
root
,
struct
ctree_path
*
path
,
int
*
level
)
{
struct
tree_buffer
*
next
;
struct
tree_buffer
*
cur
;
u64
blocknr
;
int
ret
;
u32
refs
;
ret
=
lookup_block_ref
(
root
,
path
->
nodes
[
*
level
]
->
blocknr
,
&
refs
);
BUG_ON
(
ret
);
if
(
refs
>
1
)
goto
out
;
while
(
*
level
>
0
)
{
cur
=
path
->
nodes
[
*
level
];
if
(
path
->
slots
[
*
level
]
>=
cur
->
node
.
header
.
nritems
)
break
;
blocknr
=
cur
->
node
.
blockptrs
[
path
->
slots
[
*
level
]];
ret
=
lookup_block_ref
(
root
,
blocknr
,
&
refs
);
if
(
refs
!=
1
||
*
level
==
1
)
{
path
->
slots
[
*
level
]
++
;
ret
=
free_extent
(
root
,
blocknr
,
1
);
BUG_ON
(
ret
);
continue
;
}
BUG_ON
(
ret
);
next
=
read_tree_block
(
root
,
blocknr
);
if
(
path
->
nodes
[
*
level
-
1
])
{
tree_block_release
(
root
,
path
->
nodes
[
*
level
-
1
]);
}
path
->
nodes
[
*
level
-
1
]
=
next
;
*
level
=
node_level
(
next
->
node
.
header
.
flags
);
path
->
slots
[
*
level
]
=
0
;
}
out:
ret
=
free_extent
(
root
,
path
->
nodes
[
*
level
]
->
blocknr
,
1
);
path
->
nodes
[
*
level
]
=
NULL
;
*
level
+=
1
;
BUG_ON
(
ret
);
return
0
;
}
int
walk_up_tree
(
struct
ctree_root
*
root
,
struct
ctree_path
*
path
,
int
*
level
)
{
int
i
;
int
slot
;
int
ret
;
for
(
i
=
*
level
;
i
<
MAX_LEVEL
-
1
&&
path
->
nodes
[
i
];
i
++
)
{
slot
=
path
->
slots
[
i
];
if
(
slot
<
path
->
nodes
[
i
]
->
node
.
header
.
nritems
-
1
)
{
path
->
slots
[
i
]
++
;
*
level
=
i
;
return
0
;
}
else
{
ret
=
free_extent
(
root
,
path
->
nodes
[
*
level
]
->
blocknr
,
1
);
*
level
=
i
+
1
;
BUG_ON
(
ret
);
}
}
return
1
;
}
int
btrfs_drop_snapshot
(
struct
ctree_root
*
root
,
struct
tree_buffer
*
snap
)
{
int
ret
;
int
level
;
struct
ctree_path
path
;
int
i
;
int
orig_level
;
init_path
(
&
path
);
level
=
node_level
(
snap
->
node
.
header
.
flags
);
orig_level
=
level
;
path
.
nodes
[
level
]
=
snap
;
path
.
slots
[
level
]
=
0
;
while
(
1
)
{
ret
=
walk_down_tree
(
root
,
&
path
,
&
level
);
if
(
ret
>
0
)
break
;
ret
=
walk_up_tree
(
root
,
&
path
,
&
level
);
if
(
ret
>
0
)
break
;
}
for
(
i
=
0
;
i
<
orig_level
;
i
++
)
{
if
(
path
.
nodes
[
i
])
tree_block_release
(
root
,
path
.
nodes
[
i
]);
}
return
0
;
}
#if 0
int btrfs_drop_snapshot(struct ctree_root *root, struct tree_buffer *snap)
{
int ret;
...
...
@@ -441,4 +535,4 @@ int btrfs_drop_snapshot(struct ctree_root *root, struct tree_buffer *snap)
BUG_ON(ret);
return 0;
}
#endif
fs/btrfs/quick-test.c
浏览文件 @
20524f02
...
...
@@ -9,7 +9,7 @@
/* for testing only */
int
next_key
(
int
i
,
int
max_key
)
{
return
rand
()
%
max_key
;
//return i;
//
return i;
}
int
main
(
int
ac
,
char
**
av
)
{
...
...
@@ -44,6 +44,9 @@ int main(int ac, char **av) {
if
(
!
ret
)
tree_size
++
;
free
(
buf
);
if
(
i
==
run_size
-
5
)
{
commit_transaction
(
root
,
&
super
);
}
}
close_ctree
(
root
,
&
super
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录