Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xiphi1978
linux
提交
cf27e1ee
L
linux
项目概览
xiphi1978
/
linux
通知
2
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,发现更多精彩内容 >>
提交
cf27e1ee
编写于
3月 13, 2007
作者:
C
Chris Mason
提交者:
David Woodhouse
3月 13, 2007
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Btrfs: struct extent_item endian
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
1d4f8a0c
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
39 addition
and
15 deletion
+39
-15
fs/btrfs/ctree.h
fs/btrfs/ctree.h
+22
-2
fs/btrfs/extent-tree.c
fs/btrfs/extent-tree.c
+13
-9
fs/btrfs/mkfs.c
fs/btrfs/mkfs.c
+4
-4
未找到文件。
fs/btrfs/ctree.h
浏览文件 @
cf27e1ee
...
@@ -136,8 +136,8 @@ struct node {
...
@@ -136,8 +136,8 @@ struct node {
* owner of the block and the number of references
* owner of the block and the number of references
*/
*/
struct
extent_item
{
struct
extent_item
{
u
32
refs
;
__le
32
refs
;
u
64
owner
;
__le
64
owner
;
}
__attribute__
((
__packed__
));
}
__attribute__
((
__packed__
));
/*
/*
...
@@ -153,6 +153,26 @@ struct ctree_path {
...
@@ -153,6 +153,26 @@ struct ctree_path {
int
slots
[
MAX_LEVEL
];
int
slots
[
MAX_LEVEL
];
};
};
static
inline
u64
btrfs_extent_owner
(
struct
extent_item
*
ei
)
{
return
le64_to_cpu
(
ei
->
owner
);
}
static
inline
void
btrfs_set_extent_owner
(
struct
extent_item
*
ei
,
u64
val
)
{
ei
->
owner
=
cpu_to_le64
(
val
);
}
static
inline
u32
btrfs_extent_refs
(
struct
extent_item
*
ei
)
{
return
le32_to_cpu
(
ei
->
refs
);
}
static
inline
void
btrfs_set_extent_refs
(
struct
extent_item
*
ei
,
u32
val
)
{
ei
->
refs
=
cpu_to_le32
(
val
);
}
static
inline
u64
btrfs_node_blockptr
(
struct
node
*
n
,
int
nr
)
static
inline
u64
btrfs_node_blockptr
(
struct
node
*
n
,
int
nr
)
{
{
return
le64_to_cpu
(
n
->
blockptrs
[
nr
]);
return
le64_to_cpu
(
n
->
blockptrs
[
nr
]);
...
...
fs/btrfs/extent-tree.c
浏览文件 @
cf27e1ee
...
@@ -29,6 +29,7 @@ static int inc_block_ref(struct ctree_root *root, u64 blocknr)
...
@@ -29,6 +29,7 @@ static int inc_block_ref(struct ctree_root *root, u64 blocknr)
struct
leaf
*
l
;
struct
leaf
*
l
;
struct
extent_item
*
item
;
struct
extent_item
*
item
;
struct
btrfs_key
ins
;
struct
btrfs_key
ins
;
u32
refs
;
find_free_extent
(
root
->
extent_root
,
0
,
0
,
(
u64
)
-
1
,
&
ins
);
find_free_extent
(
root
->
extent_root
,
0
,
0
,
(
u64
)
-
1
,
&
ins
);
init_path
(
&
path
);
init_path
(
&
path
);
...
@@ -42,7 +43,8 @@ static int inc_block_ref(struct ctree_root *root, u64 blocknr)
...
@@ -42,7 +43,8 @@ static int inc_block_ref(struct ctree_root *root, u64 blocknr)
l
=
&
path
.
nodes
[
0
]
->
leaf
;
l
=
&
path
.
nodes
[
0
]
->
leaf
;
item
=
(
struct
extent_item
*
)(
l
->
data
+
btrfs_item_offset
(
l
->
items
+
item
=
(
struct
extent_item
*
)(
l
->
data
+
btrfs_item_offset
(
l
->
items
+
path
.
slots
[
0
]));
path
.
slots
[
0
]));
item
->
refs
++
;
refs
=
btrfs_extent_refs
(
item
);
btrfs_set_extent_refs
(
item
,
refs
+
1
);
BUG_ON
(
list_empty
(
&
path
.
nodes
[
0
]
->
dirty
));
BUG_ON
(
list_empty
(
&
path
.
nodes
[
0
]
->
dirty
));
release_path
(
root
->
extent_root
,
&
path
);
release_path
(
root
->
extent_root
,
&
path
);
...
@@ -69,7 +71,7 @@ static int lookup_block_ref(struct ctree_root *root, u64 blocknr, u32 *refs)
...
@@ -69,7 +71,7 @@ static int lookup_block_ref(struct ctree_root *root, u64 blocknr, u32 *refs)
item
=
(
struct
extent_item
*
)(
l
->
data
+
item
=
(
struct
extent_item
*
)(
l
->
data
+
btrfs_item_offset
(
l
->
items
+
btrfs_item_offset
(
l
->
items
+
path
.
slots
[
0
]));
path
.
slots
[
0
]));
*
refs
=
item
->
refs
;
*
refs
=
btrfs_extent_refs
(
item
)
;
release_path
(
root
->
extent_root
,
&
path
);
release_path
(
root
->
extent_root
,
&
path
);
return
0
;
return
0
;
}
}
...
@@ -120,9 +122,9 @@ static int finish_current_insert(struct ctree_root *extent_root)
...
@@ -120,9 +122,9 @@ static int finish_current_insert(struct ctree_root *extent_root)
int
i
;
int
i
;
int
ret
;
int
ret
;
extent_item
.
refs
=
1
;
btrfs_set_extent_refs
(
&
extent_item
,
1
)
;
extent_item
.
owner
=
btrfs_set_extent_owner
(
&
extent_item
,
btrfs_header_parentid
(
&
extent_root
->
node
->
node
.
header
);
btrfs_header_parentid
(
&
extent_root
->
node
->
node
.
header
)
)
;
ins
.
offset
=
1
;
ins
.
offset
=
1
;
ins
.
flags
=
0
;
ins
.
flags
=
0
;
...
@@ -148,6 +150,7 @@ int __free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks)
...
@@ -148,6 +150,7 @@ int __free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks)
struct
btrfs_item
*
item
;
struct
btrfs_item
*
item
;
struct
extent_item
*
ei
;
struct
extent_item
*
ei
;
struct
btrfs_key
ins
;
struct
btrfs_key
ins
;
u32
refs
;
key
.
objectid
=
blocknr
;
key
.
objectid
=
blocknr
;
key
.
flags
=
0
;
key
.
flags
=
0
;
...
@@ -166,8 +169,9 @@ int __free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks)
...
@@ -166,8 +169,9 @@ int __free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks)
ei
=
(
struct
extent_item
*
)(
path
.
nodes
[
0
]
->
leaf
.
data
+
ei
=
(
struct
extent_item
*
)(
path
.
nodes
[
0
]
->
leaf
.
data
+
btrfs_item_offset
(
item
));
btrfs_item_offset
(
item
));
BUG_ON
(
ei
->
refs
==
0
);
BUG_ON
(
ei
->
refs
==
0
);
ei
->
refs
--
;
refs
=
btrfs_extent_refs
(
ei
)
-
1
;
if
(
ei
->
refs
==
0
)
{
btrfs_set_extent_refs
(
ei
,
refs
);
if
(
refs
==
0
)
{
if
(
root
==
extent_root
)
{
if
(
root
==
extent_root
)
{
int
err
;
int
err
;
radix_tree_preload
(
GFP_KERNEL
);
radix_tree_preload
(
GFP_KERNEL
);
...
@@ -368,8 +372,8 @@ int alloc_extent(struct ctree_root *root, u64 num_blocks, u64 search_start,
...
@@ -368,8 +372,8 @@ int alloc_extent(struct ctree_root *root, u64 num_blocks, u64 search_start,
struct
ctree_root
*
extent_root
=
root
->
extent_root
;
struct
ctree_root
*
extent_root
=
root
->
extent_root
;
struct
extent_item
extent_item
;
struct
extent_item
extent_item
;
extent_item
.
refs
=
1
;
btrfs_set_extent_refs
(
&
extent_item
,
1
)
;
extent_item
.
owner
=
owner
;
btrfs_set_extent_owner
(
&
extent_item
,
owner
)
;
if
(
root
==
extent_root
)
{
if
(
root
==
extent_root
)
{
BUG_ON
(
extent_root
->
current_insert
.
offset
==
0
);
BUG_ON
(
extent_root
->
current_insert
.
offset
==
0
);
...
...
fs/btrfs/mkfs.c
浏览文件 @
cf27e1ee
...
@@ -51,8 +51,8 @@ int mkfs(int fd)
...
@@ -51,8 +51,8 @@ int mkfs(int fd)
btrfs_set_item_offset
(
&
item
,
btrfs_set_item_offset
(
&
item
,
LEAF_DATA_SIZE
-
sizeof
(
struct
extent_item
));
LEAF_DATA_SIZE
-
sizeof
(
struct
extent_item
));
btrfs_set_item_size
(
&
item
,
sizeof
(
struct
extent_item
));
btrfs_set_item_size
(
&
item
,
sizeof
(
struct
extent_item
));
extent_item
.
refs
=
1
;
btrfs_set_extent_refs
(
&
extent_item
,
1
)
;
extent_item
.
owner
=
0
;
btrfs_set_extent_owner
(
&
extent_item
,
0
)
;
memcpy
(
empty_leaf
.
items
,
&
item
,
sizeof
(
item
));
memcpy
(
empty_leaf
.
items
,
&
item
,
sizeof
(
item
));
memcpy
(
empty_leaf
.
data
+
btrfs_item_offset
(
&
item
),
&
extent_item
,
memcpy
(
empty_leaf
.
data
+
btrfs_item_offset
(
&
item
),
&
extent_item
,
btrfs_item_size
(
&
item
));
btrfs_item_size
(
&
item
));
...
@@ -62,7 +62,7 @@ int mkfs(int fd)
...
@@ -62,7 +62,7 @@ int mkfs(int fd)
btrfs_set_key_offset
(
&
item
.
key
,
1
);
btrfs_set_key_offset
(
&
item
.
key
,
1
);
btrfs_set_item_offset
(
&
item
,
btrfs_set_item_offset
(
&
item
,
LEAF_DATA_SIZE
-
sizeof
(
struct
extent_item
)
*
2
);
LEAF_DATA_SIZE
-
sizeof
(
struct
extent_item
)
*
2
);
extent_item
.
owner
=
1
;
btrfs_set_extent_owner
(
&
extent_item
,
1
)
;
memcpy
(
empty_leaf
.
items
+
1
,
&
item
,
sizeof
(
item
));
memcpy
(
empty_leaf
.
items
+
1
,
&
item
,
sizeof
(
item
));
memcpy
(
empty_leaf
.
data
+
btrfs_item_offset
(
&
item
),
&
extent_item
,
memcpy
(
empty_leaf
.
data
+
btrfs_item_offset
(
&
item
),
&
extent_item
,
btrfs_item_size
(
&
item
));
btrfs_item_size
(
&
item
));
...
@@ -72,7 +72,7 @@ int mkfs(int fd)
...
@@ -72,7 +72,7 @@ int mkfs(int fd)
btrfs_set_key_offset
(
&
item
.
key
,
1
);
btrfs_set_key_offset
(
&
item
.
key
,
1
);
btrfs_set_item_offset
(
&
item
,
btrfs_set_item_offset
(
&
item
,
LEAF_DATA_SIZE
-
sizeof
(
struct
extent_item
)
*
3
);
LEAF_DATA_SIZE
-
sizeof
(
struct
extent_item
)
*
3
);
extent_item
.
owner
=
2
;
btrfs_set_extent_owner
(
&
extent_item
,
2
)
;
memcpy
(
empty_leaf
.
items
+
2
,
&
item
,
sizeof
(
item
));
memcpy
(
empty_leaf
.
items
+
2
,
&
item
,
sizeof
(
item
));
memcpy
(
empty_leaf
.
data
+
btrfs_item_offset
(
&
item
),
&
extent_item
,
memcpy
(
empty_leaf
.
data
+
btrfs_item_offset
(
&
item
),
&
extent_item
,
btrfs_item_size
(
&
item
));
btrfs_item_size
(
&
item
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录