Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
cd1bc465
K
Kernel
项目概览
openeuler
/
Kernel
大约 1 年 前同步成功
通知
6
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cd1bc465
编写于
4月 27, 2007
作者:
C
Chris Mason
提交者:
David Woodhouse
4月 27, 2007
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Btrfs: more block allocator work
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
9078a3e1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
90 addition
and
14 deletion
+90
-14
fs/btrfs/ctree.h
fs/btrfs/ctree.h
+3
-1
fs/btrfs/disk-io.c
fs/btrfs/disk-io.c
+1
-1
fs/btrfs/extent-tree.c
fs/btrfs/extent-tree.c
+83
-12
fs/btrfs/super.c
fs/btrfs/super.c
+3
-0
未找到文件。
fs/btrfs/ctree.h
浏览文件 @
cd1bc465
...
...
@@ -250,6 +250,8 @@ struct btrfs_block_group_item {
struct
btrfs_block_group_cache
{
struct
btrfs_key
key
;
struct
btrfs_block_group_item
item
;
u64
first_free
;
u64
last_alloc
;
};
struct
crypto_hash
;
...
...
@@ -257,7 +259,7 @@ struct btrfs_fs_info {
struct
btrfs_root
*
extent_root
;
struct
btrfs_root
*
tree_root
;
struct
btrfs_root
*
dev_root
;
struct
btrfs_
key
last_insert
;
struct
btrfs_
block_group_cache
*
block_group_cache
;
struct
radix_tree_root
fs_roots_radix
;
struct
radix_tree_root
pending_del_radix
;
struct
radix_tree_root
pinned_radix
;
...
...
fs/btrfs/disk-io.c
浏览文件 @
cd1bc465
...
...
@@ -558,7 +558,7 @@ struct btrfs_root *open_ctree(struct super_block *sb)
}
mutex_init
(
&
fs_info
->
trans_mutex
);
mutex_init
(
&
fs_info
->
fs_mutex
);
memset
(
&
fs_info
->
last_insert
,
0
,
sizeof
(
fs_info
->
last_insert
))
;
fs_info
->
block_group_cache
=
NULL
;
__setup_root
(
sb
->
s_blocksize
,
dev_root
,
fs_info
,
BTRFS_DEV_TREE_OBJECTID
);
...
...
fs/btrfs/extent-tree.c
浏览文件 @
cd1bc465
...
...
@@ -12,6 +12,63 @@ static int finish_current_insert(struct btrfs_trans_handle *trans, struct
static
int
del_pending_extents
(
struct
btrfs_trans_handle
*
trans
,
struct
btrfs_root
*
extent_root
);
static
int
find_search_start
(
struct
btrfs_root
*
root
,
int
data
)
{
struct
btrfs_block_group_cache
*
cache
[
8
];
struct
btrfs_fs_info
*
info
=
root
->
fs_info
;
u64
used
;
u64
last
;
int
i
;
int
ret
;
cache
[
0
]
=
info
->
block_group_cache
;
if
(
!
cache
[
0
])
goto
find_new
;
used
=
btrfs_block_group_used
(
&
cache
[
0
]
->
item
);
if
(
used
<
(
cache
[
0
]
->
key
.
offset
*
3
/
2
))
return
0
;
find_new:
last
=
0
;
while
(
1
)
{
ret
=
radix_tree_gang_lookup_tag
(
&
info
->
block_group_radix
,
(
void
**
)
cache
,
last
,
ARRAY_SIZE
(
cache
),
BTRFS_BLOCK_GROUP_DIRTY
);
if
(
!
ret
)
break
;
for
(
i
=
0
;
i
<
ret
;
i
++
)
{
used
=
btrfs_block_group_used
(
&
cache
[
i
]
->
item
);
if
(
used
<
(
cache
[
i
]
->
key
.
offset
*
3
/
2
))
{
info
->
block_group_cache
=
cache
[
i
];
cache
[
i
]
->
last_alloc
=
cache
[
i
]
->
first_free
;
return
0
;
}
last
=
cache
[
i
]
->
key
.
objectid
+
cache
[
i
]
->
key
.
offset
-
1
;
}
}
last
=
0
;
while
(
1
)
{
ret
=
radix_tree_gang_lookup
(
&
info
->
block_group_radix
,
(
void
**
)
cache
,
last
,
ARRAY_SIZE
(
cache
));
if
(
!
ret
)
break
;
for
(
i
=
0
;
i
<
ret
;
i
++
)
{
used
=
btrfs_block_group_used
(
&
cache
[
i
]
->
item
);
if
(
used
<
(
cache
[
i
]
->
key
.
offset
*
3
/
2
))
{
info
->
block_group_cache
=
cache
[
i
];
cache
[
i
]
->
last_alloc
=
cache
[
i
]
->
first_free
;
return
0
;
}
last
=
cache
[
i
]
->
key
.
objectid
+
cache
[
i
]
->
key
.
offset
-
1
;
}
}
info
->
block_group_cache
=
NULL
;
return
0
;
}
int
btrfs_inc_extent_ref
(
struct
btrfs_trans_handle
*
trans
,
struct
btrfs_root
*
root
,
u64
blocknr
,
u64
num_blocks
)
...
...
@@ -205,8 +262,11 @@ static int update_block_group(struct btrfs_trans_handle *trans,
while
(
total
)
{
ret
=
radix_tree_gang_lookup
(
&
info
->
block_group_radix
,
(
void
**
)
&
cache
,
blocknr
,
1
);
if
(
!
ret
)
if
(
!
ret
)
{
printk
(
KERN_CRIT
"blocknr %Lu lookup failed
\n
"
,
blocknr
);
return
-
1
;
}
block_in_group
=
blocknr
-
cache
->
key
.
objectid
;
WARN_ON
(
block_in_group
>
cache
->
key
.
offset
);
radix_tree_tag_set
(
&
info
->
block_group_radix
,
...
...
@@ -217,10 +277,15 @@ static int update_block_group(struct btrfs_trans_handle *trans,
num
=
min
(
total
,
cache
->
key
.
offset
-
block_in_group
);
total
-=
num
;
blocknr
+=
num
;
if
(
alloc
)
if
(
alloc
)
{
old_val
+=
num
;
else
if
(
blocknr
>
cache
->
last_alloc
)
cache
->
last_alloc
=
blocknr
;
}
else
{
old_val
-=
num
;
if
(
blocknr
<
cache
->
first_free
)
cache
->
first_free
=
blocknr
;
}
btrfs_set_block_group_used
(
&
cache
->
item
,
old_val
);
}
return
0
;
...
...
@@ -246,9 +311,7 @@ int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, struct
clear_radix_bit
(
pinned_radix
,
gang
[
i
]);
}
}
if
(
root
->
fs_info
->
last_insert
.
objectid
>
first
)
root
->
fs_info
->
last_insert
.
objectid
=
first
;
root
->
fs_info
->
last_insert
.
offset
=
0
;
root
->
fs_info
->
block_group_cache
=
NULL
;
return
0
;
}
...
...
@@ -466,8 +529,10 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
num_blocks
=
1
;
total_needed
=
min
(
level
+
2
,
BTRFS_MAX_LEVEL
)
*
3
;
}
if
(
info
->
last_insert
.
objectid
>
search_start
)
search_start
=
info
->
last_insert
.
objectid
;
find_search_start
(
root
,
0
);
if
(
info
->
block_group_cache
&&
info
->
block_group_cache
->
last_alloc
>
search_start
)
search_start
=
info
->
block_group_cache
->
last_alloc
;
check_failed:
btrfs_init_path
(
path
);
...
...
@@ -567,8 +632,7 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
total_found
<
total_needed
)
{
nr
=
total_needed
-
total_found
-
1
;
BUG_ON
(
nr
<
0
);
root
->
fs_info
->
extent_tree_prealloc
[
nr
]
=
test_block
;
info
->
extent_tree_prealloc
[
nr
]
=
test_block
;
total_found
++
;
test_block
++
;
}
...
...
@@ -576,9 +640,14 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
search_start
=
test_block
;
goto
check_failed
;
}
root
->
fs_info
->
extent_tree_prealloc_nr
=
total_found
;
info
->
extent_tree_prealloc_nr
=
total_found
;
}
ret
=
radix_tree_gang_lookup
(
&
info
->
block_group_radix
,
(
void
**
)
&
info
->
block_group_cache
,
ins
->
objectid
,
1
);
if
(
ret
)
{
info
->
block_group_cache
->
last_alloc
=
ins
->
objectid
;
}
root
->
fs_info
->
last_insert
.
objectid
=
ins
->
objectid
;
ins
->
offset
=
num_blocks
;
btrfs_free_path
(
path
);
return
0
;
...
...
@@ -915,6 +984,8 @@ int btrfs_read_block_groups(struct btrfs_root *root)
struct
btrfs_block_group_item
);
memcpy
(
&
cache
->
item
,
bi
,
sizeof
(
*
bi
));
memcpy
(
&
cache
->
key
,
&
found_key
,
sizeof
(
found_key
));
cache
->
last_alloc
=
0
;
cache
->
first_free
=
0
;
key
.
objectid
=
found_key
.
objectid
+
found_key
.
offset
;
btrfs_release_path
(
root
,
path
);
ret
=
radix_tree_insert
(
&
root
->
fs_info
->
block_group_radix
,
...
...
fs/btrfs/super.c
浏览文件 @
cd1bc465
...
...
@@ -223,6 +223,7 @@ static int btrfs_unlink_trans(struct btrfs_trans_handle *trans,
btrfs_update_inode
(
trans
,
root
,
dir
);
drop_nlink
(
dentry
->
d_inode
);
btrfs_update_inode
(
trans
,
root
,
dentry
->
d_inode
);
dir
->
i_sb
->
s_dirt
=
1
;
}
return
ret
;
}
...
...
@@ -411,6 +412,7 @@ static int btrfs_truncate_in_trans(struct btrfs_trans_handle *trans,
error:
btrfs_release_path
(
root
,
path
);
btrfs_free_path
(
path
);
inode
->
i_sb
->
s_dirt
=
1
;
return
ret
;
}
...
...
@@ -935,6 +937,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
goto
out_fail
;
d_instantiate
(
dentry
,
inode
);
drop_on_err
=
0
;
dir
->
i_sb
->
s_dirt
=
1
;
out_fail:
btrfs_end_transaction
(
trans
,
root
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录