Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
ddc19e6e
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
160
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ddc19e6e
编写于
4月 17, 2012
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hpfs: annotate btree nodes, get rid of bitfields mess
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
39413c60
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
51 deletion
+52
-51
fs/hpfs/anode.c
fs/hpfs/anode.c
+20
-15
fs/hpfs/hpfs.h
fs/hpfs/hpfs.h
+28
-32
fs/hpfs/map.c
fs/hpfs/map.c
+4
-4
未找到文件。
fs/hpfs/anode.c
浏览文件 @
ddc19e6e
...
...
@@ -20,7 +20,7 @@ secno hpfs_bplus_lookup(struct super_block *s, struct inode *inode,
int
c1
,
c2
=
0
;
go_down:
if
(
hpfs_sb
(
s
)
->
sb_chk
)
if
(
hpfs_stop_cycles
(
s
,
a
,
&
c1
,
&
c2
,
"hpfs_bplus_lookup"
))
return
-
1
;
if
(
b
tree
->
internal
)
{
if
(
b
p_internal
(
btree
)
)
{
for
(
i
=
0
;
i
<
btree
->
n_used_nodes
;
i
++
)
if
(
le32_to_cpu
(
btree
->
u
.
internal
[
i
].
file_secno
)
>
sec
)
{
a
=
le32_to_cpu
(
btree
->
u
.
internal
[
i
].
down
);
...
...
@@ -82,7 +82,7 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
brelse
(
bh
);
return
-
1
;
}
if
(
b
tree
->
internal
)
{
if
(
b
p_internal
(
btree
)
)
{
a
=
le32_to_cpu
(
btree
->
u
.
internal
[
n
].
down
);
btree
->
u
.
internal
[
n
].
file_secno
=
cpu_to_le32
(
-
1
);
mark_buffer_dirty
(
bh
);
...
...
@@ -129,12 +129,12 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
}
if
(
a
==
node
&&
fnod
)
{
anode
->
up
=
cpu_to_le32
(
node
);
anode
->
btree
.
f
node_parent
=
1
;
anode
->
btree
.
f
lags
|=
BP_fnode_parent
;
anode
->
btree
.
n_used_nodes
=
btree
->
n_used_nodes
;
anode
->
btree
.
first_free
=
btree
->
first_free
;
anode
->
btree
.
n_free_nodes
=
40
-
anode
->
btree
.
n_used_nodes
;
memcpy
(
&
anode
->
u
,
&
btree
->
u
,
btree
->
n_used_nodes
*
12
);
btree
->
internal
=
1
;
btree
->
flags
|=
BP_internal
;
btree
->
n_free_nodes
=
11
;
btree
->
n_used_nodes
=
1
;
btree
->
first_free
=
cpu_to_le16
((
char
*
)
&
(
btree
->
u
.
internal
[
1
])
-
(
char
*
)
btree
);
...
...
@@ -184,7 +184,10 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
hpfs_free_sectors
(
s
,
ra
,
1
);
if
((
anode
=
hpfs_map_anode
(
s
,
na
,
&
bh
)))
{
anode
->
up
=
cpu_to_le32
(
up
);
anode
->
btree
.
fnode_parent
=
up
==
node
&&
fnod
;
if
(
up
==
node
&&
fnod
)
anode
->
btree
.
flags
|=
BP_fnode_parent
;
else
anode
->
btree
.
flags
&=
~
BP_fnode_parent
;
mark_buffer_dirty
(
bh
);
brelse
(
bh
);
}
...
...
@@ -198,7 +201,7 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
if
((
new_anode
=
hpfs_alloc_anode
(
s
,
a
,
&
na
,
&
bh
)))
{
anode
=
new_anode
;
/*anode->up = cpu_to_le32(up != -1 ? up : ra);*/
anode
->
btree
.
internal
=
1
;
anode
->
btree
.
flags
|=
BP_internal
;
anode
->
btree
.
n_used_nodes
=
1
;
anode
->
btree
.
n_free_nodes
=
59
;
anode
->
btree
.
first_free
=
cpu_to_le16
(
16
);
...
...
@@ -215,7 +218,8 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
}
if
((
anode
=
hpfs_map_anode
(
s
,
na
,
&
bh
)))
{
anode
->
up
=
cpu_to_le32
(
node
);
if
(
fnod
)
anode
->
btree
.
fnode_parent
=
1
;
if
(
fnod
)
anode
->
btree
.
flags
|=
BP_fnode_parent
;
mark_buffer_dirty
(
bh
);
brelse
(
bh
);
}
...
...
@@ -234,18 +238,19 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
}
ranode
->
up
=
cpu_to_le32
(
node
);
memcpy
(
&
ranode
->
btree
,
btree
,
le16_to_cpu
(
btree
->
first_free
));
if
(
fnod
)
ranode
->
btree
.
fnode_parent
=
1
;
ranode
->
btree
.
n_free_nodes
=
(
ranode
->
btree
.
internal
?
60
:
40
)
-
ranode
->
btree
.
n_used_nodes
;
if
(
ranode
->
btree
.
internal
)
for
(
n
=
0
;
n
<
ranode
->
btree
.
n_used_nodes
;
n
++
)
{
if
(
fnod
)
ranode
->
btree
.
flags
|=
BP_fnode_parent
;
ranode
->
btree
.
n_free_nodes
=
(
bp_internal
(
&
ranode
->
btree
)
?
60
:
40
)
-
ranode
->
btree
.
n_used_nodes
;
if
(
bp_internal
(
&
ranode
->
btree
))
for
(
n
=
0
;
n
<
ranode
->
btree
.
n_used_nodes
;
n
++
)
{
struct
anode
*
unode
;
if
((
unode
=
hpfs_map_anode
(
s
,
le32_to_cpu
(
ranode
->
u
.
internal
[
n
].
down
),
&
bh1
)))
{
unode
->
up
=
cpu_to_le32
(
ra
);
unode
->
btree
.
f
node_parent
=
0
;
unode
->
btree
.
f
lags
&=
~
BP_fnode_parent
;
mark_buffer_dirty
(
bh1
);
brelse
(
bh1
);
}
}
btree
->
internal
=
1
;
btree
->
flags
|=
BP_internal
;
btree
->
n_free_nodes
=
fnod
?
10
:
58
;
btree
->
n_used_nodes
=
2
;
btree
->
first_free
=
cpu_to_le16
((
char
*
)
&
btree
->
u
.
internal
[
2
]
-
(
char
*
)
btree
);
...
...
@@ -278,7 +283,7 @@ void hpfs_remove_btree(struct super_block *s, struct bplus_header *btree)
int
d1
,
d2
;
go_down:
d2
=
0
;
while
(
b
tree1
->
internal
)
{
while
(
b
p_internal
(
btree1
)
)
{
ano
=
le32_to_cpu
(
btree1
->
u
.
internal
[
pos
].
down
);
if
(
level
)
brelse
(
bh
);
if
(
hpfs_sb
(
s
)
->
sb_chk
)
...
...
@@ -412,13 +417,13 @@ void hpfs_truncate_btree(struct super_block *s, secno f, int fno, unsigned secs)
btree
->
n_free_nodes
=
8
;
btree
->
n_used_nodes
=
0
;
btree
->
first_free
=
cpu_to_le16
(
8
);
btree
->
internal
=
0
;
btree
->
flags
&=
~
BP_internal
;
mark_buffer_dirty
(
bh
);
}
else
hpfs_free_sectors
(
s
,
f
,
1
);
brelse
(
bh
);
return
;
}
while
(
b
tree
->
internal
)
{
while
(
b
p_internal
(
btree
)
)
{
nodes
=
btree
->
n_used_nodes
+
btree
->
n_free_nodes
;
for
(
i
=
0
;
i
<
btree
->
n_used_nodes
;
i
++
)
if
(
le32_to_cpu
(
btree
->
u
.
internal
[
i
].
file_secno
)
>=
secs
)
goto
f
;
...
...
fs/hpfs/hpfs.h
浏览文件 @
ddc19e6e
...
...
@@ -375,50 +375,36 @@ struct hpfs_dirent {
struct
bplus_leaf_node
{
u
32
file_secno
;
/* first file sector in extent */
u32
length
;
/* length, sectors */
secno
disk_secno
;
/* first corresponding disk sector */
__le
32
file_secno
;
/* first file sector in extent */
__le32
length
;
/* length, sectors */
__le32
disk_secno
;
/* first corresponding disk sector */
};
struct
bplus_internal_node
{
u
32
file_secno
;
/* subtree maps sectors < this */
anode_secno
down
;
/* pointer to subtree */
__le
32
file_secno
;
/* subtree maps sectors < this */
__le32
down
;
/* pointer to subtree */
};
enum
{
BP_hbff
=
1
,
BP_fnode_parent
=
0x20
,
BP_binary_search
=
0x40
,
BP_internal
=
0x80
};
struct
bplus_header
{
#ifdef __LITTLE_ENDIAN
u8
hbff
:
1
;
/* high bit of first free entry offset */
u8
flag1234
:
4
;
u8
fnode_parent
:
1
;
/* ? we're pointed to by an fnode,
the data btree or some ea or the
main ea bootage pointer ea_secno */
/* also can get set in fnodes, which
may be a chkdsk glitch or may mean
this bit is irrelevant in fnodes,
or this interpretation is all wet */
u8
binary_search
:
1
;
/* suggest binary search (unused) */
u8
internal
:
1
;
/* 1 -> (internal) tree of anodes
0 -> (leaf) list of extents */
#else
u8
internal
:
1
;
/* 1 -> (internal) tree of anodes
0 -> (leaf) list of extents */
u8
binary_search
:
1
;
/* suggest binary search (unused) */
u8
fnode_parent
:
1
;
/* ? we're pointed to by an fnode,
u8
flags
;
/* bit 0 - high bit of first free entry offset
bit 5 - we're pointed to by an fnode,
the data btree or some ea or the
main ea bootage pointer ea_secno */
/* also can get set in fnodes, which
may be a chkdsk glitch or may mean
this bit is irrelevant in fnodes,
or this interpretation is all wet */
u8
flag1234
:
4
;
u8
hbff
:
1
;
/* high bit of first free entry offset */
#endif
main ea bootage pointer ea_secno
bit 6 - suggest binary search (unused)
bit 7 - 1 -> (internal) tree of anodes
0 -> (leaf) list of extents */
u8
fill
[
3
];
u8
n_free_nodes
;
/* free nodes in following array */
u8
n_used_nodes
;
/* used nodes in following array */
u
16
first_free
;
/* offset from start of header to
__le
16
first_free
;
/* offset from start of header to
first free node in array */
union
{
struct
bplus_internal_node
internal
[
0
];
/* (internal) 2-word entries giving
...
...
@@ -428,6 +414,16 @@ struct bplus_header
}
u
;
};
static
inline
bool
bp_internal
(
struct
bplus_header
*
bp
)
{
return
bp
->
flags
&
BP_internal
;
}
static
inline
bool
bp_fnode_parent
(
struct
bplus_header
*
bp
)
{
return
bp
->
flags
&
BP_fnode_parent
;
}
/* fnode: root of allocation b+ tree, and EA's */
/* Every file and every directory has one fnode, pointed to by the directory
...
...
fs/hpfs/map.c
浏览文件 @
ddc19e6e
...
...
@@ -132,14 +132,14 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea
}
if
(
!
fnode_is_dir
(
fnode
))
{
if
((
unsigned
)
fnode
->
btree
.
n_used_nodes
+
(
unsigned
)
fnode
->
btree
.
n_free_nodes
!=
(
fnode
->
btree
.
internal
?
12
:
8
))
{
(
bp_internal
(
&
fnode
->
btree
)
?
12
:
8
))
{
hpfs_error
(
s
,
"bad number of nodes in fnode %08lx"
,
(
unsigned
long
)
ino
);
goto
bail
;
}
if
(
le16_to_cpu
(
fnode
->
btree
.
first_free
)
!=
8
+
fnode
->
btree
.
n_used_nodes
*
(
fnode
->
btree
.
internal
?
8
:
12
))
{
8
+
fnode
->
btree
.
n_used_nodes
*
(
bp_internal
(
&
fnode
->
btree
)
?
8
:
12
))
{
hpfs_error
(
s
,
"bad first_free pointer in fnode %08lx"
,
(
unsigned
long
)
ino
);
...
...
@@ -187,12 +187,12 @@ struct anode *hpfs_map_anode(struct super_block *s, anode_secno ano, struct buff
goto
bail
;
}
if
((
unsigned
)
anode
->
btree
.
n_used_nodes
+
(
unsigned
)
anode
->
btree
.
n_free_nodes
!=
(
anode
->
btree
.
internal
?
60
:
40
))
{
(
bp_internal
(
&
anode
->
btree
)
?
60
:
40
))
{
hpfs_error
(
s
,
"bad number of nodes in anode %08x"
,
ano
);
goto
bail
;
}
if
(
le16_to_cpu
(
anode
->
btree
.
first_free
)
!=
8
+
anode
->
btree
.
n_used_nodes
*
(
anode
->
btree
.
internal
?
8
:
12
))
{
8
+
anode
->
btree
.
n_used_nodes
*
(
bp_internal
(
&
anode
->
btree
)
?
8
:
12
))
{
hpfs_error
(
s
,
"bad first_free pointer in anode %08x"
,
ano
);
goto
bail
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录