Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gsplhtlxg
clone-Linux
提交
479965d6
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,发现更多精彩内容 >>
提交
479965d6
编写于
10月 15, 2007
作者:
C
Chris Mason
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Btrfs: Optimizations for the extent_buffer code
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
5f39d397
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
76 addition
and
36 deletion
+76
-36
fs/btrfs/ctree.c
fs/btrfs/ctree.c
+24
-27
fs/btrfs/ctree.h
fs/btrfs/ctree.h
+43
-5
fs/btrfs/extent_map.c
fs/btrfs/extent_map.c
+8
-3
fs/btrfs/extent_map.h
fs/btrfs/extent_map.h
+1
-1
未找到文件。
fs/btrfs/ctree.c
浏览文件 @
479965d6
...
...
@@ -464,22 +464,12 @@ static int check_block(struct btrfs_root *root, struct btrfs_path *path,
int
level
)
{
struct
extent_buffer
*
buf
=
path
->
nodes
[
level
];
char
fsid
[
BTRFS_FSID_SIZE
];
read_extent_buffer
(
buf
,
fsid
,
(
unsigned
long
)
btrfs_header_fsid
(
buf
),
BTRFS_FSID_SIZE
);
if
(
memcmp
(
fsid
,
root
->
fs_info
->
fsid
,
BTRFS_FSID_SIZE
))
{
int
i
=
0
;
if
(
memcmp_extent_buffer
(
buf
,
root
->
fs_info
->
fsid
,
(
unsigned
long
)
btrfs_header_fsid
(
buf
),
BTRFS_FSID_SIZE
))
{
printk
(
"warning bad block %Lu
\n
"
,
buf
->
start
);
if
(
!
btrfs_buffer_uptodate
(
buf
))
{
WARN_ON
(
1
);
}
for
(
i
=
0
;
i
<
BTRFS_FSID_SIZE
;
i
++
)
{
printk
(
"%x:%x "
,
root
->
fs_info
->
fsid
[
i
],
fsid
[
i
]);
}
printk
(
"
\n
"
);
// BUG();
BUG
();
}
if
(
level
==
0
)
return
check_leaf
(
root
,
path
,
level
);
...
...
@@ -504,13 +494,14 @@ static int generic_bin_search(struct extent_buffer *eb, unsigned long p,
int
high
=
max
;
int
mid
;
int
ret
;
struct
btrfs_disk_key
*
tmp
;
struct
btrfs_disk_key
*
tmp
=
NULL
;
struct
btrfs_disk_key
unaligned
;
unsigned
long
offset
;
char
*
map_token
=
NULL
;
char
*
kaddr
=
NULL
;
unsigned
long
map_start
=
0
;
unsigned
long
map_len
=
0
;
int
err
;
while
(
low
<
high
)
{
mid
=
(
low
+
high
)
/
2
;
...
...
@@ -519,19 +510,24 @@ static int generic_bin_search(struct extent_buffer *eb, unsigned long p,
if
(
!
map_token
||
offset
<
map_start
||
(
offset
+
sizeof
(
struct
btrfs_disk_key
))
>
map_start
+
map_len
)
{
if
(
map_token
)
if
(
map_token
)
{
unmap_extent_buffer
(
eb
,
map_token
,
KM_USER0
);
map_extent_buffer
(
eb
,
offset
,
&
map_token
,
&
kaddr
,
&
map_start
,
&
map_len
,
KM_USER0
);
map_token
=
NULL
;
}
err
=
map_extent_buffer
(
eb
,
offset
,
sizeof
(
struct
btrfs_disk_key
),
&
map_token
,
&
kaddr
,
&
map_start
,
&
map_len
,
KM_USER0
);
if
(
!
err
)
{
tmp
=
(
struct
btrfs_disk_key
*
)(
kaddr
+
offset
-
map_start
);
}
else
{
read_extent_buffer
(
eb
,
&
unaligned
,
offset
,
sizeof
(
unaligned
));
tmp
=
&
unaligned
;
}
}
if
(
offset
+
sizeof
(
struct
btrfs_disk_key
)
>
map_start
+
map_len
)
{
unmap_extent_buffer
(
eb
,
map_token
,
KM_USER0
);
read_extent_buffer
(
eb
,
&
unaligned
,
offset
,
sizeof
(
unaligned
));
map_token
=
NULL
;
tmp
=
&
unaligned
;
}
else
{
tmp
=
(
struct
btrfs_disk_key
*
)(
kaddr
+
offset
-
map_start
);
...
...
@@ -544,7 +540,8 @@ static int generic_bin_search(struct extent_buffer *eb, unsigned long p,
high
=
mid
;
else
{
*
slot
=
mid
;
unmap_extent_buffer
(
eb
,
map_token
,
KM_USER0
);
if
(
map_token
)
unmap_extent_buffer
(
eb
,
map_token
,
KM_USER0
);
return
0
;
}
}
...
...
fs/btrfs/ctree.h
浏览文件 @
479965d6
...
...
@@ -22,6 +22,7 @@
#include <linux/fs.h>
#include <linux/workqueue.h>
#include <linux/completion.h>
#include <asm/kmap_types.h>
#include "bit-radix.h"
#include "extent_map.h"
...
...
@@ -431,15 +432,52 @@ struct btrfs_root {
static inline u##bits btrfs_##name(struct extent_buffer *eb, \
type *s) \
{ \
__le##bits res; \
read_eb_member(eb, s, type, member, &res); \
return le##bits##_to_cpu(res); \
int err; \
char *map_token; \
char *kaddr; \
unsigned long map_start; \
unsigned long map_len; \
unsigned long offset = (unsigned long)s + \
offsetof(type, member); \
err = map_extent_buffer(eb, offset, \
sizeof(((type *)0)->member), \
&map_token, &kaddr, \
&map_start, &map_len, KM_USER0); \
if (!err) { \
__le##bits *tmp = (__le##bits *)(kaddr + offset - \
map_start); \
u##bits res = le##bits##_to_cpu(*tmp); \
unmap_extent_buffer(eb, map_token, KM_USER0); \
return res; \
} else { \
__le##bits res; \
read_eb_member(eb, s, type, member, &res); \
return le##bits##_to_cpu(res); \
} \
} \
static inline void btrfs_set_##name(struct extent_buffer *eb, \
type *s, u##bits val) \
{ \
val = cpu_to_le##bits(val); \
write_eb_member(eb, s, type, member, &val); \
int err; \
char *map_token; \
char *kaddr; \
unsigned long map_start; \
unsigned long map_len; \
unsigned long offset = (unsigned long)s + \
offsetof(type, member); \
err = map_extent_buffer(eb, offset, \
sizeof(((type *)0)->member), \
&map_token, &kaddr, \
&map_start, &map_len, KM_USER0); \
if (!err) { \
__le##bits *tmp = (__le##bits *)(kaddr + offset - \
map_start); \
*tmp = cpu_to_le##bits(val); \
unmap_extent_buffer(eb, map_token, KM_USER0); \
} else { \
val = cpu_to_le##bits(val); \
write_eb_member(eb, s, type, member, &val); \
} \
}
#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \
...
...
fs/btrfs/extent_map.c
浏览文件 @
479965d6
...
...
@@ -2140,14 +2140,20 @@ void read_extent_buffer(struct extent_buffer *eb, void *dstv,
EXPORT_SYMBOL
(
read_extent_buffer
);
int
map_extent_buffer
(
struct
extent_buffer
*
eb
,
unsigned
long
start
,
unsigned
long
min_len
,
char
**
token
,
char
**
map
,
unsigned
long
*
map_start
,
unsigned
long
*
map_len
,
int
km
)
{
size_t
offset
;
size_t
offset
=
start
&
(
PAGE_CACHE_SIZE
-
1
)
;
char
*
kaddr
;
size_t
start_offset
=
eb
->
start
&
((
u64
)
PAGE_CACHE_SIZE
-
1
);
unsigned
long
i
=
(
start_offset
+
start
)
>>
PAGE_CACHE_SHIFT
;
unsigned
long
end_i
=
(
start_offset
+
start
+
min_len
)
>>
PAGE_CACHE_SHIFT
;
if
(
i
!=
end_i
)
return
-
EINVAL
;
WARN_ON
(
start
>
eb
->
len
);
...
...
@@ -2155,8 +2161,7 @@ int map_extent_buffer(struct extent_buffer *eb, unsigned long start,
offset
=
start_offset
;
*
map_start
=
0
;
}
else
{
offset
=
0
;
*
map_start
=
(
i
<<
PAGE_CACHE_SHIFT
)
-
offset
;
*
map_start
=
(
i
<<
PAGE_CACHE_SHIFT
)
-
start_offset
;
}
// kaddr = kmap_atomic(eb->pages[i], km);
...
...
fs/btrfs/extent_map.h
浏览文件 @
479965d6
...
...
@@ -173,7 +173,7 @@ int set_extent_buffer_uptodate(struct extent_map_tree *tree,
int
extent_buffer_uptodate
(
struct
extent_map_tree
*
tree
,
struct
extent_buffer
*
eb
);
int
map_extent_buffer
(
struct
extent_buffer
*
eb
,
unsigned
long
offset
,
char
**
token
,
char
**
map
,
unsigned
long
min_len
,
char
**
token
,
char
**
map
,
unsigned
long
*
map_start
,
unsigned
long
*
map_len
,
int
km
);
void
unmap_extent_buffer
(
struct
extent_buffer
*
eb
,
char
*
token
,
int
km
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录