Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xiphi1978
linux
提交
b4100d64
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,发现更多精彩内容 >>
提交
b4100d64
编写于
4月 12, 2007
作者:
C
Chris Mason
提交者:
David Woodhouse
4月 12, 2007
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Btrfs: add a device id to device items
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
8352d8a4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
65 addition
and
12 deletion
+65
-12
fs/btrfs/ctree.h
fs/btrfs/ctree.h
+36
-0
fs/btrfs/disk-io.c
fs/btrfs/disk-io.c
+20
-11
fs/btrfs/disk-io.h
fs/btrfs/disk-io.h
+1
-0
fs/btrfs/super.c
fs/btrfs/super.c
+8
-1
未找到文件。
fs/btrfs/ctree.h
浏览文件 @
b4100d64
...
@@ -91,10 +91,12 @@ struct btrfs_super_block {
...
@@ -91,10 +91,12 @@ struct btrfs_super_block {
__le64
total_blocks
;
__le64
total_blocks
;
__le64
blocks_used
;
__le64
blocks_used
;
__le64
root_dir_objectid
;
__le64
root_dir_objectid
;
__le64
last_device_id
;
/* fields below here vary with the underlying disk */
/* fields below here vary with the underlying disk */
__le64
device_block_start
;
__le64
device_block_start
;
__le64
device_num_blocks
;
__le64
device_num_blocks
;
__le64
device_root
;
__le64
device_root
;
__le64
device_id
;
}
__attribute__
((
__packed__
));
}
__attribute__
((
__packed__
));
/*
/*
...
@@ -230,6 +232,7 @@ struct btrfs_csum_item {
...
@@ -230,6 +232,7 @@ struct btrfs_csum_item {
struct
btrfs_device_item
{
struct
btrfs_device_item
{
__le16
pathlen
;
__le16
pathlen
;
__le64
device_id
;
}
__attribute__
((
__packed__
));
}
__attribute__
((
__packed__
));
struct
crypto_hash
;
struct
crypto_hash
;
...
@@ -798,6 +801,28 @@ static inline void btrfs_set_super_root_dir(struct btrfs_super_block *s, u64
...
@@ -798,6 +801,28 @@ static inline void btrfs_set_super_root_dir(struct btrfs_super_block *s, u64
s
->
root_dir_objectid
=
cpu_to_le64
(
val
);
s
->
root_dir_objectid
=
cpu_to_le64
(
val
);
}
}
static
inline
u64
btrfs_super_last_device_id
(
struct
btrfs_super_block
*
s
)
{
return
le64_to_cpu
(
s
->
last_device_id
);
}
static
inline
void
btrfs_set_super_last_device_id
(
struct
btrfs_super_block
*
s
,
u64
val
)
{
s
->
last_device_id
=
cpu_to_le64
(
val
);
}
static
inline
u64
btrfs_super_device_id
(
struct
btrfs_super_block
*
s
)
{
return
le64_to_cpu
(
s
->
device_id
);
}
static
inline
void
btrfs_set_super_device_id
(
struct
btrfs_super_block
*
s
,
u64
val
)
{
s
->
device_id
=
cpu_to_le64
(
val
);
}
static
inline
u64
btrfs_super_device_block_start
(
struct
btrfs_super_block
*
s
)
static
inline
u64
btrfs_super_device_block_start
(
struct
btrfs_super_block
*
s
)
{
{
return
le64_to_cpu
(
s
->
device_block_start
);
return
le64_to_cpu
(
s
->
device_block_start
);
...
@@ -910,6 +935,17 @@ static inline void btrfs_set_device_pathlen(struct btrfs_device_item *d,
...
@@ -910,6 +935,17 @@ static inline void btrfs_set_device_pathlen(struct btrfs_device_item *d,
d
->
pathlen
=
cpu_to_le16
(
val
);
d
->
pathlen
=
cpu_to_le16
(
val
);
}
}
static
inline
u64
btrfs_device_id
(
struct
btrfs_device_item
*
d
)
{
return
le64_to_cpu
(
d
->
device_id
);
}
static
inline
void
btrfs_set_device_id
(
struct
btrfs_device_item
*
d
,
u64
val
)
{
d
->
device_id
=
cpu_to_le64
(
val
);
}
static
inline
struct
btrfs_root
*
btrfs_sb
(
struct
super_block
*
sb
)
static
inline
struct
btrfs_root
*
btrfs_sb
(
struct
super_block
*
sb
)
{
{
return
sb
->
s_fs_info
;
return
sb
->
s_fs_info
;
...
...
fs/btrfs/disk-io.c
浏览文件 @
b4100d64
...
@@ -13,11 +13,13 @@
...
@@ -13,11 +13,13 @@
struct
dev_lookup
{
struct
dev_lookup
{
u64
block_start
;
u64
block_start
;
u64
num_blocks
;
u64
num_blocks
;
u64
device_id
;
struct
block_device
*
bdev
;
struct
block_device
*
bdev
;
};
};
int
btrfs_insert_dev_radix
(
struct
btrfs_root
*
root
,
int
btrfs_insert_dev_radix
(
struct
btrfs_root
*
root
,
struct
block_device
*
bdev
,
struct
block_device
*
bdev
,
u64
device_id
,
u64
block_start
,
u64
block_start
,
u64
num_blocks
)
u64
num_blocks
)
{
{
...
@@ -31,6 +33,7 @@ int btrfs_insert_dev_radix(struct btrfs_root *root,
...
@@ -31,6 +33,7 @@ int btrfs_insert_dev_radix(struct btrfs_root *root,
lookup
->
block_start
=
block_start
;
lookup
->
block_start
=
block_start
;
lookup
->
num_blocks
=
num_blocks
;
lookup
->
num_blocks
=
num_blocks
;
lookup
->
bdev
=
bdev
;
lookup
->
bdev
=
bdev
;
lookup
->
device_id
=
device_id
;
printk
(
"inserting %s into dev radix %Lu %Lu
\n
"
,
bdevname
(
bdev
,
b
),
block_start
,
num_blocks
);
printk
(
"inserting %s into dev radix %Lu %Lu
\n
"
,
bdevname
(
bdev
,
b
),
block_start
,
num_blocks
);
ret
=
radix_tree_insert
(
&
root
->
fs_info
->
dev_radix
,
block_start
+
ret
=
radix_tree_insert
(
&
root
->
fs_info
->
dev_radix
,
block_start
+
...
@@ -418,17 +421,14 @@ printk("all worked\n");
...
@@ -418,17 +421,14 @@ printk("all worked\n");
return
root
;
return
root
;
}
}
int
btrfs_open_disk
(
struct
btrfs_root
*
root
,
u64
block_start
,
u64
num_blocks
,
static
int
btrfs_open_disk
(
struct
btrfs_root
*
root
,
u64
device_id
,
char
*
filename
,
int
name_len
)
u64
block_start
,
u64
num_blocks
,
char
*
filename
,
int
name_len
)
{
{
char
*
null_filename
;
char
*
null_filename
;
struct
block_device
*
bdev
;
struct
block_device
*
bdev
;
int
ret
;
int
ret
;
if
(
block_start
==
0
)
{
printk
(
"skipping disk with block_start == 0
\n
"
);
return
0
;
}
null_filename
=
kmalloc
(
name_len
+
1
,
GFP_NOFS
);
null_filename
=
kmalloc
(
name_len
+
1
,
GFP_NOFS
);
if
(
!
null_filename
)
if
(
!
null_filename
)
return
-
ENOMEM
;
return
-
ENOMEM
;
...
@@ -441,7 +441,8 @@ return 0;
...
@@ -441,7 +441,8 @@ return 0;
goto
out
;
goto
out
;
}
}
set_blocksize
(
bdev
,
root
->
fs_info
->
sb
->
s_blocksize
);
set_blocksize
(
bdev
,
root
->
fs_info
->
sb
->
s_blocksize
);
ret
=
btrfs_insert_dev_radix
(
root
,
bdev
,
block_start
,
num_blocks
);
ret
=
btrfs_insert_dev_radix
(
root
,
bdev
,
device_id
,
block_start
,
num_blocks
);
BUG_ON
(
ret
);
BUG_ON
(
ret
);
ret
=
0
;
ret
=
0
;
out:
out:
...
@@ -490,10 +491,14 @@ static int read_device_info(struct btrfs_root *root)
...
@@ -490,10 +491,14 @@ static int read_device_info(struct btrfs_root *root)
}
}
dev_item
=
btrfs_item_ptr
(
leaf
,
slot
,
struct
btrfs_device_item
);
dev_item
=
btrfs_item_ptr
(
leaf
,
slot
,
struct
btrfs_device_item
);
printk
(
"found key %Lu %Lu
\n
"
,
key
.
objectid
,
key
.
offset
);
printk
(
"found key %Lu %Lu
\n
"
,
key
.
objectid
,
key
.
offset
);
ret
=
btrfs_open_disk
(
root
,
key
.
objectid
,
key
.
offset
,
if
(
btrfs_device_id
(
dev_item
)
!=
(
char
*
)(
dev_item
+
1
),
btrfs_super_device_id
(
root
->
fs_info
->
disk_super
))
{
btrfs_device_pathlen
(
dev_item
));
ret
=
btrfs_open_disk
(
root
,
btrfs_device_id
(
dev_item
),
BUG_ON
(
ret
);
key
.
objectid
,
key
.
offset
,
(
char
*
)(
dev_item
+
1
),
btrfs_device_pathlen
(
dev_item
));
BUG_ON
(
ret
);
}
path
->
slots
[
0
]
++
;
path
->
slots
[
0
]
++
;
}
}
btrfs_free_path
(
path
);
btrfs_free_path
(
path
);
...
@@ -556,6 +561,7 @@ struct btrfs_root *open_ctree(struct super_block *sb)
...
@@ -556,6 +561,7 @@ struct btrfs_root *open_ctree(struct super_block *sb)
dev_lookup
->
block_start
=
0
;
dev_lookup
->
block_start
=
0
;
dev_lookup
->
num_blocks
=
(
u32
)
-
2
;
dev_lookup
->
num_blocks
=
(
u32
)
-
2
;
dev_lookup
->
bdev
=
sb
->
s_bdev
;
dev_lookup
->
bdev
=
sb
->
s_bdev
;
dev_lookup
->
device_id
=
0
;
ret
=
radix_tree_insert
(
&
fs_info
->
dev_radix
,
(
u32
)
-
2
,
dev_lookup
);
ret
=
radix_tree_insert
(
&
fs_info
->
dev_radix
,
(
u32
)
-
2
,
dev_lookup
);
BUG_ON
(
ret
);
BUG_ON
(
ret
);
fs_info
->
sb_buffer
=
read_tree_block
(
tree_root
,
fs_info
->
sb_buffer
=
read_tree_block
(
tree_root
,
...
@@ -575,6 +581,8 @@ struct btrfs_root *open_ctree(struct super_block *sb)
...
@@ -575,6 +581,8 @@ struct btrfs_root *open_ctree(struct super_block *sb)
radix_tree_delete
(
&
fs_info
->
dev_radix
,
(
u32
)
-
2
);
radix_tree_delete
(
&
fs_info
->
dev_radix
,
(
u32
)
-
2
);
dev_lookup
->
block_start
=
btrfs_super_device_block_start
(
disk_super
);
dev_lookup
->
block_start
=
btrfs_super_device_block_start
(
disk_super
);
dev_lookup
->
num_blocks
=
btrfs_super_device_num_blocks
(
disk_super
);
dev_lookup
->
num_blocks
=
btrfs_super_device_num_blocks
(
disk_super
);
dev_lookup
->
device_id
=
btrfs_super_device_id
(
disk_super
);
ret
=
radix_tree_insert
(
&
fs_info
->
dev_radix
,
ret
=
radix_tree_insert
(
&
fs_info
->
dev_radix
,
dev_lookup
->
block_start
+
dev_lookup
->
block_start
+
dev_lookup
->
num_blocks
-
1
,
dev_lookup
);
dev_lookup
->
num_blocks
-
1
,
dev_lookup
);
...
@@ -659,6 +667,7 @@ int del_fs_roots(struct btrfs_fs_info *fs_info)
...
@@ -659,6 +667,7 @@ int del_fs_roots(struct btrfs_fs_info *fs_info)
}
}
return
0
;
return
0
;
}
}
static
int
free_dev_radix
(
struct
btrfs_fs_info
*
fs_info
)
static
int
free_dev_radix
(
struct
btrfs_fs_info
*
fs_info
)
{
{
struct
dev_lookup
*
lookup
[
8
];
struct
dev_lookup
*
lookup
[
8
];
...
...
fs/btrfs/disk-io.h
浏览文件 @
b4100d64
...
@@ -44,6 +44,7 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,
...
@@ -44,6 +44,7 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,
u64
bh_blocknr
(
struct
buffer_head
*
bh
);
u64
bh_blocknr
(
struct
buffer_head
*
bh
);
int
btrfs_insert_dev_radix
(
struct
btrfs_root
*
root
,
int
btrfs_insert_dev_radix
(
struct
btrfs_root
*
root
,
struct
block_device
*
bdev
,
struct
block_device
*
bdev
,
u64
device_id
,
u64
block_start
,
u64
block_start
,
u64
num_blocks
);
u64
num_blocks
);
int
btrfs_map_bh_to_logical
(
struct
btrfs_root
*
root
,
struct
buffer_head
*
bh
,
int
btrfs_map_bh_to_logical
(
struct
btrfs_root
*
root
,
struct
buffer_head
*
bh
,
...
...
fs/btrfs/super.c
浏览文件 @
b4100d64
...
@@ -1840,7 +1840,9 @@ static int add_disk(struct btrfs_root *root, char *name, int namelen)
...
@@ -1840,7 +1840,9 @@ static int add_disk(struct btrfs_root *root, char *name, int namelen)
u16
item_size
;
u16
item_size
;
u64
num_blocks
;
u64
num_blocks
;
u64
new_blocks
;
u64
new_blocks
;
u64
device_id
;
int
ret
;
int
ret
;
printk
(
"adding disk %s
\n
"
,
name
);
printk
(
"adding disk %s
\n
"
,
name
);
path
=
btrfs_alloc_path
();
path
=
btrfs_alloc_path
();
if
(
!
path
)
if
(
!
path
)
...
@@ -1875,9 +1877,14 @@ printk("insert failed %d\n", ret);
...
@@ -1875,9 +1877,14 @@ printk("insert failed %d\n", ret);
path
->
slots
[
0
],
struct
btrfs_device_item
);
path
->
slots
[
0
],
struct
btrfs_device_item
);
btrfs_set_device_pathlen
(
dev_item
,
namelen
);
btrfs_set_device_pathlen
(
dev_item
,
namelen
);
memcpy
(
dev_item
+
1
,
name
,
namelen
);
memcpy
(
dev_item
+
1
,
name
,
namelen
);
device_id
=
btrfs_super_last_device_id
(
root
->
fs_info
->
disk_super
)
+
1
;
btrfs_set_super_last_device_id
(
root
->
fs_info
->
disk_super
,
device_id
);
btrfs_set_device_id
(
dev_item
,
device_id
);
mark_buffer_dirty
(
path
->
nodes
[
0
]);
mark_buffer_dirty
(
path
->
nodes
[
0
]);
ret
=
btrfs_insert_dev_radix
(
root
,
bdev
,
num_blocks
,
new_blocks
);
ret
=
btrfs_insert_dev_radix
(
root
,
bdev
,
device_id
,
num_blocks
,
new_blocks
);
if
(
!
ret
)
{
if
(
!
ret
)
{
btrfs_set_super_total_blocks
(
root
->
fs_info
->
disk_super
,
btrfs_set_super_total_blocks
(
root
->
fs_info
->
disk_super
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录