Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
1d4f8a0c
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
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看板
提交
1d4f8a0c
编写于
3月 13, 2007
作者:
C
Chris Mason
提交者:
David Woodhouse
3月 13, 2007
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Btrfs: node->blockptrs endian fixes
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
0783fcfc
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
18 deletion
+33
-18
fs/btrfs/ctree.c
fs/btrfs/ctree.c
+18
-13
fs/btrfs/ctree.h
fs/btrfs/ctree.h
+11
-1
fs/btrfs/extent-tree.c
fs/btrfs/extent-tree.c
+2
-2
fs/btrfs/print-tree.c
fs/btrfs/print-tree.c
+2
-2
未找到文件。
fs/btrfs/ctree.c
浏览文件 @
1d4f8a0c
...
...
@@ -58,7 +58,8 @@ int btrfs_cow_block(struct ctree_root *root,
free_extent
(
root
,
buf
->
blocknr
,
1
);
tree_block_release
(
root
,
buf
);
}
else
{
parent
->
node
.
blockptrs
[
parent_slot
]
=
cow
->
blocknr
;
btrfs_set_node_blockptr
(
&
parent
->
node
,
parent_slot
,
cow
->
blocknr
);
BUG_ON
(
list_empty
(
&
parent
->
dirty
));
free_extent
(
root
,
buf
->
blocknr
,
1
);
}
...
...
@@ -133,7 +134,7 @@ int check_node(struct ctree_path *path, int level)
parent_key
=
&
parent
->
keys
[
parent_slot
];
BUG_ON
(
memcmp
(
parent_key
,
node
->
keys
,
sizeof
(
struct
btrfs_disk_key
)));
BUG_ON
(
parent
->
blockptrs
[
parent_slot
]
!=
BUG_ON
(
btrfs_node_blockptr
(
parent
,
parent_slot
)
!=
btrfs_header_blocknr
(
&
node
->
header
));
}
BUG_ON
(
nritems
>
NODEPTRS_PER_BLOCK
);
...
...
@@ -166,7 +167,7 @@ int check_leaf(struct ctree_path *path, int level)
parent_key
=
&
parent
->
keys
[
parent_slot
];
BUG_ON
(
memcmp
(
parent_key
,
&
leaf
->
items
[
0
].
key
,
sizeof
(
struct
btrfs_disk_key
)));
BUG_ON
(
parent
->
blockptrs
[
parent_slot
]
!=
BUG_ON
(
btrfs_node_blockptr
(
parent
,
parent_slot
)
!=
btrfs_header_blocknr
(
&
leaf
->
header
));
}
for
(
i
=
0
;
nritems
>
1
&&
i
<
nritems
-
2
;
i
++
)
{
...
...
@@ -258,7 +259,7 @@ struct tree_buffer *read_node_slot(struct ctree_root *root,
return
NULL
;
if
(
slot
>=
btrfs_header_nritems
(
&
node
->
header
))
return
NULL
;
return
read_tree_block
(
root
,
node
->
blockptrs
[
slot
]
);
return
read_tree_block
(
root
,
btrfs_node_blockptr
(
node
,
slot
)
);
}
static
int
balance_level
(
struct
ctree_root
*
root
,
struct
ctree_path
*
path
,
...
...
@@ -283,7 +284,7 @@ static int balance_level(struct ctree_root *root, struct ctree_path *path,
mid_buf
=
path
->
nodes
[
level
];
mid
=
&
mid_buf
->
node
;
orig_ptr
=
mid
->
blockptrs
[
orig_slot
]
;
orig_ptr
=
btrfs_node_blockptr
(
mid
,
orig_slot
)
;
if
(
level
<
MAX_LEVEL
-
1
)
parent_buf
=
path
->
nodes
[
level
+
1
];
...
...
@@ -407,7 +408,8 @@ static int balance_level(struct ctree_root *root, struct ctree_path *path,
}
/* double check we haven't messed things up */
check_block
(
path
,
level
);
if
(
orig_ptr
!=
path
->
nodes
[
level
]
->
node
.
blockptrs
[
path
->
slots
[
level
]])
if
(
orig_ptr
!=
btrfs_node_blockptr
(
&
path
->
nodes
[
level
]
->
node
,
path
->
slots
[
level
]))
BUG
();
if
(
right_buf
)
...
...
@@ -482,7 +484,7 @@ int search_slot(struct ctree_root *root, struct btrfs_key *key,
slot
=
p
->
slots
[
level
];
BUG_ON
(
btrfs_header_nritems
(
&
c
->
header
)
==
1
);
}
b
=
read_tree_block
(
root
,
c
->
blockptrs
[
slot
]
);
b
=
read_tree_block
(
root
,
btrfs_node_blockptr
(
c
,
slot
)
);
}
else
{
struct
leaf
*
l
=
(
struct
leaf
*
)
c
;
p
->
slots
[
level
]
=
slot
;
...
...
@@ -660,7 +662,7 @@ static int insert_new_root(struct ctree_root *root,
else
lower_key
=
lower
->
keys
;
memcpy
(
c
->
keys
,
lower_key
,
sizeof
(
struct
btrfs_disk_key
));
c
->
blockptrs
[
0
]
=
path
->
nodes
[
level
-
1
]
->
blocknr
;
btrfs_set_node_blockptr
(
c
,
0
,
path
->
nodes
[
level
-
1
]
->
blocknr
)
;
/* the super has an extra ref to root->node */
tree_block_release
(
root
,
root
->
node
);
root
->
node
=
t
;
...
...
@@ -700,7 +702,7 @@ static int insert_ptr(struct ctree_root *root,
(
nritems
-
slot
)
*
sizeof
(
u64
));
}
memcpy
(
lower
->
keys
+
slot
,
key
,
sizeof
(
struct
btrfs_disk_key
));
lower
->
blockptrs
[
slot
]
=
blocknr
;
btrfs_set_node_blockptr
(
lower
,
slot
,
blocknr
)
;
btrfs_set_header_nritems
(
&
lower
->
header
,
nritems
+
1
);
if
(
lower
->
keys
[
1
].
objectid
==
0
)
BUG
();
...
...
@@ -820,7 +822,8 @@ static int push_leaf_right(struct ctree_root *root, struct ctree_path *path,
if
(
slot
>=
btrfs_header_nritems
(
&
upper
->
node
.
header
)
-
1
)
{
return
1
;
}
right_buf
=
read_tree_block
(
root
,
upper
->
node
.
blockptrs
[
slot
+
1
]);
right_buf
=
read_tree_block
(
root
,
btrfs_node_blockptr
(
&
upper
->
node
,
slot
+
1
));
right
=
&
right_buf
->
leaf
;
free_space
=
leaf_free_space
(
right
);
if
(
free_space
<
data_size
+
sizeof
(
struct
btrfs_item
))
{
...
...
@@ -926,7 +929,8 @@ static int push_leaf_left(struct ctree_root *root, struct ctree_path *path,
if
(
!
path
->
nodes
[
1
])
{
return
1
;
}
t
=
read_tree_block
(
root
,
path
->
nodes
[
1
]
->
node
.
blockptrs
[
slot
-
1
]);
t
=
read_tree_block
(
root
,
btrfs_node_blockptr
(
&
path
->
nodes
[
1
]
->
node
,
slot
-
1
));
left
=
&
t
->
leaf
;
free_space
=
leaf_free_space
(
left
);
if
(
free_space
<
data_size
+
sizeof
(
struct
btrfs_item
))
{
...
...
@@ -1353,7 +1357,7 @@ int next_leaf(struct ctree_root *root, struct ctree_path *path)
level
++
;
continue
;
}
blocknr
=
c
->
node
.
blockptrs
[
slot
]
;
blocknr
=
btrfs_node_blockptr
(
&
c
->
node
,
slot
)
;
if
(
next
)
tree_block_release
(
root
,
next
);
next
=
read_tree_block
(
root
,
blocknr
);
...
...
@@ -1368,7 +1372,8 @@ int next_leaf(struct ctree_root *root, struct ctree_path *path)
path
->
slots
[
level
]
=
0
;
if
(
!
level
)
break
;
next
=
read_tree_block
(
root
,
next
->
node
.
blockptrs
[
0
]);
next
=
read_tree_block
(
root
,
btrfs_node_blockptr
(
&
next
->
node
,
0
));
}
return
0
;
}
...
...
fs/btrfs/ctree.h
浏览文件 @
1d4f8a0c
...
...
@@ -128,7 +128,7 @@ struct leaf {
struct
node
{
struct
btrfs_header
header
;
struct
btrfs_disk_key
keys
[
NODEPTRS_PER_BLOCK
];
u
64
blockptrs
[
NODEPTRS_PER_BLOCK
];
__le
64
blockptrs
[
NODEPTRS_PER_BLOCK
];
}
__attribute__
((
__packed__
));
/*
...
...
@@ -153,6 +153,16 @@ struct ctree_path {
int
slots
[
MAX_LEVEL
];
};
static
inline
u64
btrfs_node_blockptr
(
struct
node
*
n
,
int
nr
)
{
return
le64_to_cpu
(
n
->
blockptrs
[
nr
]);
}
static
inline
void
btrfs_set_node_blockptr
(
struct
node
*
n
,
int
nr
,
u64
val
)
{
n
->
blockptrs
[
nr
]
=
cpu_to_le64
(
val
);
}
static
inline
u16
btrfs_item_offset
(
struct
btrfs_item
*
item
)
{
return
le16_to_cpu
(
item
->
offset
);
...
...
fs/btrfs/extent-tree.c
浏览文件 @
1d4f8a0c
...
...
@@ -85,7 +85,7 @@ int btrfs_inc_ref(struct ctree_root *root, struct tree_buffer *buf)
return
0
;
for
(
i
=
0
;
i
<
btrfs_header_nritems
(
&
buf
->
node
.
header
);
i
++
)
{
blocknr
=
b
uf
->
node
.
blockptrs
[
i
]
;
blocknr
=
b
trfs_node_blockptr
(
&
buf
->
node
,
i
)
;
inc_block_ref
(
root
,
blocknr
);
}
return
0
;
...
...
@@ -437,7 +437,7 @@ int walk_down_tree(struct ctree_root *root, struct ctree_path *path, int *level)
if
(
path
->
slots
[
*
level
]
>=
btrfs_header_nritems
(
&
cur
->
node
.
header
))
break
;
blocknr
=
cur
->
node
.
blockptrs
[
path
->
slots
[
*
level
]]
;
blocknr
=
btrfs_node_blockptr
(
&
cur
->
node
,
path
->
slots
[
*
level
])
;
ret
=
lookup_block_ref
(
root
,
blocknr
,
&
refs
);
if
(
refs
!=
1
||
*
level
==
1
)
{
path
->
slots
[
*
level
]
++
;
...
...
fs/btrfs/print-tree.c
浏览文件 @
1d4f8a0c
...
...
@@ -54,12 +54,12 @@ void print_tree(struct ctree_root *root, struct tree_buffer *t)
printf
(
"
\t
key %d (%Lu %u %Lu) block %Lu
\n
"
,
i
,
c
->
keys
[
i
].
objectid
,
c
->
keys
[
i
].
flags
,
c
->
keys
[
i
].
offset
,
c
->
blockptrs
[
i
]
);
btrfs_node_blockptr
(
c
,
i
)
);
fflush
(
stdout
);
}
for
(
i
=
0
;
i
<
nr
;
i
++
)
{
struct
tree_buffer
*
next_buf
=
read_tree_block
(
root
,
c
->
blockptrs
[
i
]
);
btrfs_node_blockptr
(
c
,
i
)
);
struct
node
*
next
=
&
next_buf
->
node
;
if
(
btrfs_is_leaf
(
next
)
&&
btrfs_header_level
(
&
c
->
header
)
!=
1
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录