Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
023a824f
K
Kernel
项目概览
openeuler
/
Kernel
接近 2 年 前同步成功
通知
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看板
提交
023a824f
编写于
7月 26, 2016
作者:
C
Chris Mason
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'kdave-v4.8' into for-linus-4.8
上级
8b8b08cb
66642832
变更
45
展开全部
隐藏空白更改
内联
并排
Showing
45 changed file
with
1074 addition
and
826 deletion
+1074
-826
fs/btrfs/acl.c
fs/btrfs/acl.c
+1
-2
fs/btrfs/async-thread.c
fs/btrfs/async-thread.c
+25
-6
fs/btrfs/async-thread.h
fs/btrfs/async-thread.h
+5
-1
fs/btrfs/backref.c
fs/btrfs/backref.c
+2
-2
fs/btrfs/compression.c
fs/btrfs/compression.c
+8
-2
fs/btrfs/ctree.c
fs/btrfs/ctree.c
+63
-28
fs/btrfs/ctree.h
fs/btrfs/ctree.h
+59
-42
fs/btrfs/dedupe.h
fs/btrfs/dedupe.h
+24
-0
fs/btrfs/delayed-inode.c
fs/btrfs/delayed-inode.c
+2
-2
fs/btrfs/delayed-ref.c
fs/btrfs/delayed-ref.c
+9
-8
fs/btrfs/dev-replace.c
fs/btrfs/dev-replace.c
+2
-2
fs/btrfs/disk-io.c
fs/btrfs/disk-io.c
+54
-47
fs/btrfs/disk-io.h
fs/btrfs/disk-io.h
+2
-1
fs/btrfs/extent-tree.c
fs/btrfs/extent-tree.c
+71
-53
fs/btrfs/extent_io.c
fs/btrfs/extent_io.c
+24
-6
fs/btrfs/extent_map.c
fs/btrfs/extent_map.c
+1
-1
fs/btrfs/file-item.c
fs/btrfs/file-item.c
+4
-5
fs/btrfs/file.c
fs/btrfs/file.c
+6
-6
fs/btrfs/free-space-cache.c
fs/btrfs/free-space-cache.c
+4
-4
fs/btrfs/free-space-tree.c
fs/btrfs/free-space-tree.c
+8
-8
fs/btrfs/inode-map.c
fs/btrfs/inode-map.c
+8
-8
fs/btrfs/inode.c
fs/btrfs/inode.c
+115
-103
fs/btrfs/ioctl.c
fs/btrfs/ioctl.c
+18
-22
fs/btrfs/ordered-data.c
fs/btrfs/ordered-data.c
+1
-1
fs/btrfs/props.c
fs/btrfs/props.c
+3
-3
fs/btrfs/qgroup.c
fs/btrfs/qgroup.c
+13
-12
fs/btrfs/qgroup.h
fs/btrfs/qgroup.h
+5
-4
fs/btrfs/relocation.c
fs/btrfs/relocation.c
+12
-8
fs/btrfs/root-tree.c
fs/btrfs/root-tree.c
+5
-5
fs/btrfs/scrub.c
fs/btrfs/scrub.c
+6
-6
fs/btrfs/super.c
fs/btrfs/super.c
+100
-118
fs/btrfs/sysfs.c
fs/btrfs/sysfs.c
+2
-0
fs/btrfs/tests/btrfs-tests.c
fs/btrfs/tests/btrfs-tests.c
+62
-5
fs/btrfs/tests/btrfs-tests.h
fs/btrfs/tests/btrfs-tests.h
+4
-32
fs/btrfs/tests/extent-buffer-tests.c
fs/btrfs/tests/extent-buffer-tests.c
+16
-7
fs/btrfs/tests/free-space-tests.c
fs/btrfs/tests/free-space-tests.c
+9
-5
fs/btrfs/tests/free-space-tree-tests.c
fs/btrfs/tests/free-space-tree-tests.c
+10
-8
fs/btrfs/tests/inode-tests.c
fs/btrfs/tests/inode-tests.c
+24
-22
fs/btrfs/tests/qgroup-tests.c
fs/btrfs/tests/qgroup-tests.c
+13
-10
fs/btrfs/transaction.c
fs/btrfs/transaction.c
+19
-18
fs/btrfs/transaction.h
fs/btrfs/transaction.h
+1
-0
fs/btrfs/tree-log.c
fs/btrfs/tree-log.c
+13
-9
fs/btrfs/volumes.c
fs/btrfs/volumes.c
+81
-57
include/trace/events/btrfs.h
include/trace/events/btrfs.h
+159
-136
include/uapi/linux/btrfs.h
include/uapi/linux/btrfs.h
+1
-1
未找到文件。
fs/btrfs/acl.c
浏览文件 @
023a824f
...
@@ -55,8 +55,7 @@ struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
...
@@ -55,8 +55,7 @@ struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
}
}
if
(
size
>
0
)
{
if
(
size
>
0
)
{
acl
=
posix_acl_from_xattr
(
&
init_user_ns
,
value
,
size
);
acl
=
posix_acl_from_xattr
(
&
init_user_ns
,
value
,
size
);
}
else
if
(
size
==
-
ENOENT
||
size
==
-
ENODATA
||
size
==
0
)
{
}
else
if
(
size
==
-
ERANGE
||
size
==
-
ENODATA
||
size
==
0
)
{
/* FIXME, who returns -ENOENT? I think nobody */
acl
=
NULL
;
acl
=
NULL
;
}
else
{
}
else
{
acl
=
ERR_PTR
(
-
EIO
);
acl
=
ERR_PTR
(
-
EIO
);
...
...
fs/btrfs/async-thread.c
浏览文件 @
023a824f
...
@@ -34,6 +34,10 @@
...
@@ -34,6 +34,10 @@
struct
__btrfs_workqueue
{
struct
__btrfs_workqueue
{
struct
workqueue_struct
*
normal_wq
;
struct
workqueue_struct
*
normal_wq
;
/* File system this workqueue services */
struct
btrfs_fs_info
*
fs_info
;
/* List head pointing to ordered work list */
/* List head pointing to ordered work list */
struct
list_head
ordered_list
;
struct
list_head
ordered_list
;
...
@@ -70,6 +74,18 @@ void btrfs_##name(struct work_struct *arg) \
...
@@ -70,6 +74,18 @@ void btrfs_##name(struct work_struct *arg) \
normal_work_helper(work); \
normal_work_helper(work); \
}
}
struct
btrfs_fs_info
*
btrfs_workqueue_owner
(
struct
__btrfs_workqueue
*
wq
)
{
return
wq
->
fs_info
;
}
struct
btrfs_fs_info
*
btrfs_work_owner
(
struct
btrfs_work
*
work
)
{
return
work
->
wq
->
fs_info
;
}
BTRFS_WORK_HELPER
(
worker_helper
);
BTRFS_WORK_HELPER
(
worker_helper
);
BTRFS_WORK_HELPER
(
delalloc_helper
);
BTRFS_WORK_HELPER
(
delalloc_helper
);
BTRFS_WORK_HELPER
(
flush_delalloc_helper
);
BTRFS_WORK_HELPER
(
flush_delalloc_helper
);
...
@@ -94,14 +110,15 @@ BTRFS_WORK_HELPER(scrubnc_helper);
...
@@ -94,14 +110,15 @@ BTRFS_WORK_HELPER(scrubnc_helper);
BTRFS_WORK_HELPER
(
scrubparity_helper
);
BTRFS_WORK_HELPER
(
scrubparity_helper
);
static
struct
__btrfs_workqueue
*
static
struct
__btrfs_workqueue
*
__btrfs_alloc_workqueue
(
const
char
*
name
,
unsigned
int
flags
,
int
limit_activ
e
,
__btrfs_alloc_workqueue
(
struct
btrfs_fs_info
*
fs_info
,
const
char
*
nam
e
,
int
thresh
)
unsigned
int
flags
,
int
limit_active
,
int
thresh
)
{
{
struct
__btrfs_workqueue
*
ret
=
kzalloc
(
sizeof
(
*
ret
),
GFP_KERNEL
);
struct
__btrfs_workqueue
*
ret
=
kzalloc
(
sizeof
(
*
ret
),
GFP_KERNEL
);
if
(
!
ret
)
if
(
!
ret
)
return
NULL
;
return
NULL
;
ret
->
fs_info
=
fs_info
;
ret
->
limit_active
=
limit_active
;
ret
->
limit_active
=
limit_active
;
atomic_set
(
&
ret
->
pending
,
0
);
atomic_set
(
&
ret
->
pending
,
0
);
if
(
thresh
==
0
)
if
(
thresh
==
0
)
...
@@ -143,7 +160,8 @@ __btrfs_alloc_workqueue(const char *name, unsigned int flags, int limit_active,
...
@@ -143,7 +160,8 @@ __btrfs_alloc_workqueue(const char *name, unsigned int flags, int limit_active,
static
inline
void
static
inline
void
__btrfs_destroy_workqueue
(
struct
__btrfs_workqueue
*
wq
);
__btrfs_destroy_workqueue
(
struct
__btrfs_workqueue
*
wq
);
struct
btrfs_workqueue
*
btrfs_alloc_workqueue
(
const
char
*
name
,
struct
btrfs_workqueue
*
btrfs_alloc_workqueue
(
struct
btrfs_fs_info
*
fs_info
,
const
char
*
name
,
unsigned
int
flags
,
unsigned
int
flags
,
int
limit_active
,
int
limit_active
,
int
thresh
)
int
thresh
)
...
@@ -153,7 +171,8 @@ struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name,
...
@@ -153,7 +171,8 @@ struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name,
if
(
!
ret
)
if
(
!
ret
)
return
NULL
;
return
NULL
;
ret
->
normal
=
__btrfs_alloc_workqueue
(
name
,
flags
&
~
WQ_HIGHPRI
,
ret
->
normal
=
__btrfs_alloc_workqueue
(
fs_info
,
name
,
flags
&
~
WQ_HIGHPRI
,
limit_active
,
thresh
);
limit_active
,
thresh
);
if
(
!
ret
->
normal
)
{
if
(
!
ret
->
normal
)
{
kfree
(
ret
);
kfree
(
ret
);
...
@@ -161,8 +180,8 @@ struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name,
...
@@ -161,8 +180,8 @@ struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name,
}
}
if
(
flags
&
WQ_HIGHPRI
)
{
if
(
flags
&
WQ_HIGHPRI
)
{
ret
->
high
=
__btrfs_alloc_workqueue
(
name
,
flags
,
limit_active
,
ret
->
high
=
__btrfs_alloc_workqueue
(
fs_info
,
name
,
flags
,
thresh
);
limit_active
,
thresh
);
if
(
!
ret
->
high
)
{
if
(
!
ret
->
high
)
{
__btrfs_destroy_workqueue
(
ret
->
normal
);
__btrfs_destroy_workqueue
(
ret
->
normal
);
kfree
(
ret
);
kfree
(
ret
);
...
...
fs/btrfs/async-thread.h
浏览文件 @
023a824f
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#define __BTRFS_ASYNC_THREAD_
#define __BTRFS_ASYNC_THREAD_
#include <linux/workqueue.h>
#include <linux/workqueue.h>
struct
btrfs_fs_info
;
struct
btrfs_workqueue
;
struct
btrfs_workqueue
;
/* Internal use only */
/* Internal use only */
struct
__btrfs_workqueue
;
struct
__btrfs_workqueue
;
...
@@ -67,7 +68,8 @@ BTRFS_WORK_HELPER_PROTO(scrubnc_helper);
...
@@ -67,7 +68,8 @@ BTRFS_WORK_HELPER_PROTO(scrubnc_helper);
BTRFS_WORK_HELPER_PROTO
(
scrubparity_helper
);
BTRFS_WORK_HELPER_PROTO
(
scrubparity_helper
);
struct
btrfs_workqueue
*
btrfs_alloc_workqueue
(
const
char
*
name
,
struct
btrfs_workqueue
*
btrfs_alloc_workqueue
(
struct
btrfs_fs_info
*
fs_info
,
const
char
*
name
,
unsigned
int
flags
,
unsigned
int
flags
,
int
limit_active
,
int
limit_active
,
int
thresh
);
int
thresh
);
...
@@ -80,4 +82,6 @@ void btrfs_queue_work(struct btrfs_workqueue *wq,
...
@@ -80,4 +82,6 @@ void btrfs_queue_work(struct btrfs_workqueue *wq,
void
btrfs_destroy_workqueue
(
struct
btrfs_workqueue
*
wq
);
void
btrfs_destroy_workqueue
(
struct
btrfs_workqueue
*
wq
);
void
btrfs_workqueue_set_max
(
struct
btrfs_workqueue
*
wq
,
int
max
);
void
btrfs_workqueue_set_max
(
struct
btrfs_workqueue
*
wq
,
int
max
);
void
btrfs_set_work_high_priority
(
struct
btrfs_work
*
work
);
void
btrfs_set_work_high_priority
(
struct
btrfs_work
*
work
);
struct
btrfs_fs_info
*
btrfs_work_owner
(
struct
btrfs_work
*
work
);
struct
btrfs_fs_info
*
btrfs_workqueue_owner
(
struct
__btrfs_workqueue
*
wq
);
#endif
#endif
fs/btrfs/backref.c
浏览文件 @
023a824f
...
@@ -139,7 +139,7 @@ int __init btrfs_prelim_ref_init(void)
...
@@ -139,7 +139,7 @@ int __init btrfs_prelim_ref_init(void)
btrfs_prelim_ref_cache
=
kmem_cache_create
(
"btrfs_prelim_ref"
,
btrfs_prelim_ref_cache
=
kmem_cache_create
(
"btrfs_prelim_ref"
,
sizeof
(
struct
__prelim_ref
),
sizeof
(
struct
__prelim_ref
),
0
,
0
,
SLAB_
RECLAIM_ACCOUNT
|
SLAB_
MEM_SPREAD
,
SLAB_MEM_SPREAD
,
NULL
);
NULL
);
if
(
!
btrfs_prelim_ref_cache
)
if
(
!
btrfs_prelim_ref_cache
)
return
-
ENOMEM
;
return
-
ENOMEM
;
...
@@ -361,7 +361,7 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
...
@@ -361,7 +361,7 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
goto
out
;
goto
out
;
}
}
if
(
btrfs_
test_is_dummy_root
(
root
))
{
if
(
btrfs_
is_testing
(
fs_info
))
{
srcu_read_unlock
(
&
fs_info
->
subvol_srcu
,
index
);
srcu_read_unlock
(
&
fs_info
->
subvol_srcu
,
index
);
ret
=
-
ENOENT
;
ret
=
-
ENOENT
;
goto
out
;
goto
out
;
...
...
fs/btrfs/compression.c
浏览文件 @
023a824f
...
@@ -402,7 +402,10 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
...
@@ -402,7 +402,10 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
}
}
ret
=
btrfs_map_bio
(
root
,
WRITE
,
bio
,
0
,
1
);
ret
=
btrfs_map_bio
(
root
,
WRITE
,
bio
,
0
,
1
);
BUG_ON
(
ret
);
/* -ENOMEM */
if
(
ret
)
{
bio
->
bi_error
=
ret
;
bio_endio
(
bio
);
}
bio_put
(
bio
);
bio_put
(
bio
);
...
@@ -432,7 +435,10 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
...
@@ -432,7 +435,10 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
}
}
ret
=
btrfs_map_bio
(
root
,
WRITE
,
bio
,
0
,
1
);
ret
=
btrfs_map_bio
(
root
,
WRITE
,
bio
,
0
,
1
);
BUG_ON
(
ret
);
/* -ENOMEM */
if
(
ret
)
{
bio
->
bi_error
=
ret
;
bio_endio
(
bio
);
}
bio_put
(
bio
);
bio_put
(
bio
);
return
0
;
return
0
;
...
...
fs/btrfs/ctree.c
浏览文件 @
023a824f
...
@@ -1153,14 +1153,14 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
...
@@ -1153,14 +1153,14 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
ret
=
update_ref_for_cow
(
trans
,
root
,
buf
,
cow
,
&
last_ref
);
ret
=
update_ref_for_cow
(
trans
,
root
,
buf
,
cow
,
&
last_ref
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
return
ret
;
return
ret
;
}
}
if
(
test_bit
(
BTRFS_ROOT_REF_COWS
,
&
root
->
state
))
{
if
(
test_bit
(
BTRFS_ROOT_REF_COWS
,
&
root
->
state
))
{
ret
=
btrfs_reloc_cow_block
(
trans
,
root
,
buf
,
cow
);
ret
=
btrfs_reloc_cow_block
(
trans
,
root
,
buf
,
cow
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
return
ret
;
return
ret
;
}
}
}
}
...
@@ -1198,7 +1198,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
...
@@ -1198,7 +1198,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
if
(
last_ref
)
{
if
(
last_ref
)
{
ret
=
tree_mod_log_free_eb
(
root
->
fs_info
,
buf
);
ret
=
tree_mod_log_free_eb
(
root
->
fs_info
,
buf
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
return
ret
;
return
ret
;
}
}
}
}
...
@@ -1505,7 +1505,7 @@ static inline int should_cow_block(struct btrfs_trans_handle *trans,
...
@@ -1505,7 +1505,7 @@ static inline int should_cow_block(struct btrfs_trans_handle *trans,
struct
btrfs_root
*
root
,
struct
btrfs_root
*
root
,
struct
extent_buffer
*
buf
)
struct
extent_buffer
*
buf
)
{
{
if
(
btrfs_
test_is_dummy_root
(
root
))
if
(
btrfs_
is_testing
(
root
->
fs_info
))
return
0
;
return
0
;
/* ensure we can see the force_cow */
/* ensure we can see the force_cow */
...
@@ -1771,6 +1771,14 @@ static noinline int generic_bin_search(struct extent_buffer *eb,
...
@@ -1771,6 +1771,14 @@ static noinline int generic_bin_search(struct extent_buffer *eb,
unsigned
long
map_len
=
0
;
unsigned
long
map_len
=
0
;
int
err
;
int
err
;
if
(
low
>
high
)
{
btrfs_err
(
eb
->
fs_info
,
"%s: low (%d) > high (%d) eb %llu owner %llu level %d"
,
__func__
,
low
,
high
,
eb
->
start
,
btrfs_header_owner
(
eb
),
btrfs_header_level
(
eb
));
return
-
EINVAL
;
}
while
(
low
<
high
)
{
while
(
low
<
high
)
{
mid
=
(
low
+
high
)
/
2
;
mid
=
(
low
+
high
)
/
2
;
offset
=
p
+
mid
*
item_size
;
offset
=
p
+
mid
*
item_size
;
...
@@ -1858,7 +1866,6 @@ static void root_sub_used(struct btrfs_root *root, u32 size)
...
@@ -1858,7 +1866,6 @@ static void root_sub_used(struct btrfs_root *root, u32 size)
/* given a node and slot number, this reads the blocks it points to. The
/* given a node and slot number, this reads the blocks it points to. The
* extent buffer is returned with a reference taken (but unlocked).
* extent buffer is returned with a reference taken (but unlocked).
* NULL is returned on error.
*/
*/
static
noinline
struct
extent_buffer
*
read_node_slot
(
struct
btrfs_root
*
root
,
static
noinline
struct
extent_buffer
*
read_node_slot
(
struct
btrfs_root
*
root
,
struct
extent_buffer
*
parent
,
int
slot
)
struct
extent_buffer
*
parent
,
int
slot
)
...
@@ -1866,19 +1873,16 @@ static noinline struct extent_buffer *read_node_slot(struct btrfs_root *root,
...
@@ -1866,19 +1873,16 @@ static noinline struct extent_buffer *read_node_slot(struct btrfs_root *root,
int
level
=
btrfs_header_level
(
parent
);
int
level
=
btrfs_header_level
(
parent
);
struct
extent_buffer
*
eb
;
struct
extent_buffer
*
eb
;
if
(
slot
<
0
)
if
(
slot
<
0
||
slot
>=
btrfs_header_nritems
(
parent
))
return
NULL
;
return
ERR_PTR
(
-
ENOENT
);
if
(
slot
>=
btrfs_header_nritems
(
parent
))
return
NULL
;
BUG_ON
(
level
==
0
);
BUG_ON
(
level
==
0
);
eb
=
read_tree_block
(
root
,
btrfs_node_blockptr
(
parent
,
slot
),
eb
=
read_tree_block
(
root
,
btrfs_node_blockptr
(
parent
,
slot
),
btrfs_node_ptr_generation
(
parent
,
slot
));
btrfs_node_ptr_generation
(
parent
,
slot
));
if
(
IS_ERR
(
eb
)
||
!
extent_buffer_uptodate
(
eb
))
{
if
(
!
IS_ERR
(
eb
)
&&
!
extent_buffer_uptodate
(
eb
))
{
if
(
!
IS_ERR
(
eb
))
free_extent_buffer
(
eb
);
free_extent_buffer
(
eb
);
eb
=
ERR_PTR
(
-
EIO
);
eb
=
NULL
;
}
}
return
eb
;
return
eb
;
...
@@ -1931,8 +1935,8 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
...
@@ -1931,8 +1935,8 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
/* promote the child to a root */
/* promote the child to a root */
child
=
read_node_slot
(
root
,
mid
,
0
);
child
=
read_node_slot
(
root
,
mid
,
0
);
if
(
!
child
)
{
if
(
IS_ERR
(
child
)
)
{
ret
=
-
EROFS
;
ret
=
PTR_ERR
(
child
)
;
btrfs_handle_fs_error
(
root
->
fs_info
,
ret
,
NULL
);
btrfs_handle_fs_error
(
root
->
fs_info
,
ret
,
NULL
);
goto
enospc
;
goto
enospc
;
}
}
...
@@ -1970,6 +1974,9 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
...
@@ -1970,6 +1974,9 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
return
0
;
return
0
;
left
=
read_node_slot
(
root
,
parent
,
pslot
-
1
);
left
=
read_node_slot
(
root
,
parent
,
pslot
-
1
);
if
(
IS_ERR
(
left
))
left
=
NULL
;
if
(
left
)
{
if
(
left
)
{
btrfs_tree_lock
(
left
);
btrfs_tree_lock
(
left
);
btrfs_set_lock_blocking
(
left
);
btrfs_set_lock_blocking
(
left
);
...
@@ -1980,7 +1987,11 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
...
@@ -1980,7 +1987,11 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
goto
enospc
;
goto
enospc
;
}
}
}
}
right
=
read_node_slot
(
root
,
parent
,
pslot
+
1
);
right
=
read_node_slot
(
root
,
parent
,
pslot
+
1
);
if
(
IS_ERR
(
right
))
right
=
NULL
;
if
(
right
)
{
if
(
right
)
{
btrfs_tree_lock
(
right
);
btrfs_tree_lock
(
right
);
btrfs_set_lock_blocking
(
right
);
btrfs_set_lock_blocking
(
right
);
...
@@ -2135,6 +2146,8 @@ static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans,
...
@@ -2135,6 +2146,8 @@ static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans,
return
1
;
return
1
;
left
=
read_node_slot
(
root
,
parent
,
pslot
-
1
);
left
=
read_node_slot
(
root
,
parent
,
pslot
-
1
);
if
(
IS_ERR
(
left
))
left
=
NULL
;
/* first, try to make some room in the middle buffer */
/* first, try to make some room in the middle buffer */
if
(
left
)
{
if
(
left
)
{
...
@@ -2185,6 +2198,8 @@ static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans,
...
@@ -2185,6 +2198,8 @@ static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans,
free_extent_buffer
(
left
);
free_extent_buffer
(
left
);
}
}
right
=
read_node_slot
(
root
,
parent
,
pslot
+
1
);
right
=
read_node_slot
(
root
,
parent
,
pslot
+
1
);
if
(
IS_ERR
(
right
))
right
=
NULL
;
/*
/*
* then try to empty the right most buffer into the middle
* then try to empty the right most buffer into the middle
...
@@ -3240,7 +3255,7 @@ static int push_node_left(struct btrfs_trans_handle *trans,
...
@@ -3240,7 +3255,7 @@ static int push_node_left(struct btrfs_trans_handle *trans,
ret
=
tree_mod_log_eb_copy
(
root
->
fs_info
,
dst
,
src
,
dst_nritems
,
0
,
ret
=
tree_mod_log_eb_copy
(
root
->
fs_info
,
dst
,
src
,
dst_nritems
,
0
,
push_items
);
push_items
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
return
ret
;
return
ret
;
}
}
copy_extent_buffer
(
dst
,
src
,
copy_extent_buffer
(
dst
,
src
,
...
@@ -3315,7 +3330,7 @@ static int balance_node_right(struct btrfs_trans_handle *trans,
...
@@ -3315,7 +3330,7 @@ static int balance_node_right(struct btrfs_trans_handle *trans,
ret
=
tree_mod_log_eb_copy
(
root
->
fs_info
,
dst
,
src
,
0
,
ret
=
tree_mod_log_eb_copy
(
root
->
fs_info
,
dst
,
src
,
0
,
src_nritems
-
push_items
,
push_items
);
src_nritems
-
push_items
,
push_items
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
return
ret
;
return
ret
;
}
}
copy_extent_buffer
(
dst
,
src
,
copy_extent_buffer
(
dst
,
src
,
...
@@ -3519,7 +3534,7 @@ static noinline int split_node(struct btrfs_trans_handle *trans,
...
@@ -3519,7 +3534,7 @@ static noinline int split_node(struct btrfs_trans_handle *trans,
ret
=
tree_mod_log_eb_copy
(
root
->
fs_info
,
split
,
c
,
0
,
ret
=
tree_mod_log_eb_copy
(
root
->
fs_info
,
split
,
c
,
0
,
mid
,
c_nritems
-
mid
);
mid
,
c_nritems
-
mid
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
return
ret
;
return
ret
;
}
}
copy_extent_buffer
(
split
,
c
,
copy_extent_buffer
(
split
,
c
,
...
@@ -3773,7 +3788,11 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root
...
@@ -3773,7 +3788,11 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root
btrfs_assert_tree_locked
(
path
->
nodes
[
1
]);
btrfs_assert_tree_locked
(
path
->
nodes
[
1
]);
right
=
read_node_slot
(
root
,
upper
,
slot
+
1
);
right
=
read_node_slot
(
root
,
upper
,
slot
+
1
);
if
(
right
==
NULL
)
/*
* slot + 1 is not valid or we fail to read the right node,
* no big deal, just return.
*/
if
(
IS_ERR
(
right
))
return
1
;
return
1
;
btrfs_tree_lock
(
right
);
btrfs_tree_lock
(
right
);
...
@@ -4003,7 +4022,11 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
...
@@ -4003,7 +4022,11 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
btrfs_assert_tree_locked
(
path
->
nodes
[
1
]);
btrfs_assert_tree_locked
(
path
->
nodes
[
1
]);
left
=
read_node_slot
(
root
,
path
->
nodes
[
1
],
slot
-
1
);
left
=
read_node_slot
(
root
,
path
->
nodes
[
1
],
slot
-
1
);
if
(
left
==
NULL
)
/*
* slot - 1 is not valid or we fail to read the left node,
* no big deal, just return.
*/
if
(
IS_ERR
(
left
))
return
1
;
return
1
;
btrfs_tree_lock
(
left
);
btrfs_tree_lock
(
left
);
...
@@ -5210,7 +5233,10 @@ int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key,
...
@@ -5210,7 +5233,10 @@ int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key,
}
}
btrfs_set_path_blocking
(
path
);
btrfs_set_path_blocking
(
path
);
cur
=
read_node_slot
(
root
,
cur
,
slot
);
cur
=
read_node_slot
(
root
,
cur
,
slot
);
BUG_ON
(
!
cur
);
/* -ENOMEM */
if
(
IS_ERR
(
cur
))
{
ret
=
PTR_ERR
(
cur
);
goto
out
;
}
btrfs_tree_read_lock
(
cur
);
btrfs_tree_read_lock
(
cur
);
...
@@ -5229,15 +5255,21 @@ int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key,
...
@@ -5229,15 +5255,21 @@ int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key,
return
ret
;
return
ret
;
}
}
static
void
tree_move_down
(
struct
btrfs_root
*
root
,
static
int
tree_move_down
(
struct
btrfs_root
*
root
,
struct
btrfs_path
*
path
,
struct
btrfs_path
*
path
,
int
*
level
,
int
root_level
)
int
*
level
,
int
root_level
)
{
{
struct
extent_buffer
*
eb
;
BUG_ON
(
*
level
==
0
);
BUG_ON
(
*
level
==
0
);
path
->
nodes
[
*
level
-
1
]
=
read_node_slot
(
root
,
path
->
nodes
[
*
level
],
eb
=
read_node_slot
(
root
,
path
->
nodes
[
*
level
],
path
->
slots
[
*
level
]);
path
->
slots
[
*
level
]);
if
(
IS_ERR
(
eb
))
return
PTR_ERR
(
eb
);
path
->
nodes
[
*
level
-
1
]
=
eb
;
path
->
slots
[
*
level
-
1
]
=
0
;
path
->
slots
[
*
level
-
1
]
=
0
;
(
*
level
)
--
;
(
*
level
)
--
;
return
0
;
}
}
static
int
tree_move_next_or_upnext
(
struct
btrfs_root
*
root
,
static
int
tree_move_next_or_upnext
(
struct
btrfs_root
*
root
,
...
@@ -5282,8 +5314,7 @@ static int tree_advance(struct btrfs_root *root,
...
@@ -5282,8 +5314,7 @@ static int tree_advance(struct btrfs_root *root,
if
(
*
level
==
0
||
!
allow_down
)
{
if
(
*
level
==
0
||
!
allow_down
)
{
ret
=
tree_move_next_or_upnext
(
root
,
path
,
level
,
root_level
);
ret
=
tree_move_next_or_upnext
(
root
,
path
,
level
,
root_level
);
}
else
{
}
else
{
tree_move_down
(
root
,
path
,
level
,
root_level
);
ret
=
tree_move_down
(
root
,
path
,
level
,
root_level
);
ret
=
0
;
}
}
if
(
ret
>=
0
)
{
if
(
ret
>=
0
)
{
if
(
*
level
==
0
)
if
(
*
level
==
0
)
...
@@ -5457,8 +5488,10 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
...
@@ -5457,8 +5488,10 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
left_root_level
,
left_root_level
,
advance_left
!=
ADVANCE_ONLY_NEXT
,
advance_left
!=
ADVANCE_ONLY_NEXT
,
&
left_key
);
&
left_key
);
if
(
ret
<
0
)
if
(
ret
==
-
1
)
left_end_reached
=
ADVANCE
;
left_end_reached
=
ADVANCE
;
else
if
(
ret
<
0
)
goto
out
;
advance_left
=
0
;
advance_left
=
0
;
}
}
if
(
advance_right
&&
!
right_end_reached
)
{
if
(
advance_right
&&
!
right_end_reached
)
{
...
@@ -5466,8 +5499,10 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
...
@@ -5466,8 +5499,10 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
right_root_level
,
right_root_level
,
advance_right
!=
ADVANCE_ONLY_NEXT
,
advance_right
!=
ADVANCE_ONLY_NEXT
,
&
right_key
);
&
right_key
);
if
(
ret
<
0
)
if
(
ret
==
-
1
)
right_end_reached
=
ADVANCE
;
right_end_reached
=
ADVANCE
;
else
if
(
ret
<
0
)
goto
out
;
advance_right
=
0
;
advance_right
=
0
;
}
}
...
...
fs/btrfs/ctree.h
浏览文件 @
023a824f
...
@@ -117,6 +117,7 @@ static inline unsigned long btrfs_chunk_item_size(int num_stripes)
...
@@ -117,6 +117,7 @@ static inline unsigned long btrfs_chunk_item_size(int num_stripes)
#define BTRFS_FS_STATE_REMOUNTING 1
#define BTRFS_FS_STATE_REMOUNTING 1
#define BTRFS_FS_STATE_TRANS_ABORTED 2
#define BTRFS_FS_STATE_TRANS_ABORTED 2
#define BTRFS_FS_STATE_DEV_REPLACING 3
#define BTRFS_FS_STATE_DEV_REPLACING 3
#define BTRFS_FS_STATE_DUMMY_FS_INFO 4
#define BTRFS_BACKREF_REV_MAX 256
#define BTRFS_BACKREF_REV_MAX 256
#define BTRFS_BACKREF_REV_SHIFT 56
#define BTRFS_BACKREF_REV_SHIFT 56
...
@@ -144,21 +145,6 @@ struct btrfs_header {
...
@@ -144,21 +145,6 @@ struct btrfs_header {
u8
level
;
u8
level
;
}
__attribute__
((
__packed__
));
}
__attribute__
((
__packed__
));
#define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->nodesize - \
sizeof(struct btrfs_header)) / \
sizeof(struct btrfs_key_ptr))
#define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header))
#define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->nodesize))
#define BTRFS_FILE_EXTENT_INLINE_DATA_START \
(offsetof(struct btrfs_file_extent_item, disk_bytenr))
#define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
sizeof(struct btrfs_item) - \
BTRFS_FILE_EXTENT_INLINE_DATA_START)
#define BTRFS_MAX_XATTR_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
sizeof(struct btrfs_item) -\
sizeof(struct btrfs_dir_item))
/*
/*
* this is a very generous portion of the super block, giving us
* this is a very generous portion of the super block, giving us
* room to translate 14 chunks with 3 stripes each.
* room to translate 14 chunks with 3 stripes each.
...
@@ -1114,12 +1100,11 @@ struct btrfs_subvolume_writers {
...
@@ -1114,12 +1100,11 @@ struct btrfs_subvolume_writers {
#define BTRFS_ROOT_REF_COWS 1
#define BTRFS_ROOT_REF_COWS 1
#define BTRFS_ROOT_TRACK_DIRTY 2
#define BTRFS_ROOT_TRACK_DIRTY 2
#define BTRFS_ROOT_IN_RADIX 3
#define BTRFS_ROOT_IN_RADIX 3
#define BTRFS_ROOT_DUMMY_ROOT 4
#define BTRFS_ROOT_ORPHAN_ITEM_INSERTED 4
#define BTRFS_ROOT_ORPHAN_ITEM_INSERTED 5
#define BTRFS_ROOT_DEFRAG_RUNNING 5
#define BTRFS_ROOT_DEFRAG_RUNNING 6
#define BTRFS_ROOT_FORCE_COW 6
#define BTRFS_ROOT_FORCE_COW 7
#define BTRFS_ROOT_MULTI_LOG_TASKS 7
#define BTRFS_ROOT_MULTI_LOG_TASKS 8
#define BTRFS_ROOT_DIRTY 8
#define BTRFS_ROOT_DIRTY 9
/*
/*
* in ram representation of the tree. extent_root is used for all allocations
* in ram representation of the tree. extent_root is used for all allocations
...
@@ -1181,8 +1166,10 @@ struct btrfs_root {
...
@@ -1181,8 +1166,10 @@ struct btrfs_root {
u64
highest_objectid
;
u64
highest_objectid
;
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
/* only used with CONFIG_BTRFS_FS_RUN_SANITY_TESTS is enabled */
/* only used with CONFIG_BTRFS_FS_RUN_SANITY_TESTS is enabled */
u64
alloc_bytenr
;
u64
alloc_bytenr
;
#endif
u64
defrag_trans_start
;
u64
defrag_trans_start
;
struct
btrfs_key
defrag_progress
;
struct
btrfs_key
defrag_progress
;
...
@@ -1259,6 +1246,39 @@ struct btrfs_root {
...
@@ -1259,6 +1246,39 @@ struct btrfs_root {
atomic_t
qgroup_meta_rsv
;
atomic_t
qgroup_meta_rsv
;
};
};
static
inline
u32
__BTRFS_LEAF_DATA_SIZE
(
u32
blocksize
)
{
return
blocksize
-
sizeof
(
struct
btrfs_header
);
}
static
inline
u32
BTRFS_LEAF_DATA_SIZE
(
const
struct
btrfs_root
*
root
)
{
return
__BTRFS_LEAF_DATA_SIZE
(
root
->
nodesize
);
}
static
inline
u32
BTRFS_MAX_ITEM_SIZE
(
const
struct
btrfs_root
*
root
)
{
return
BTRFS_LEAF_DATA_SIZE
(
root
)
-
sizeof
(
struct
btrfs_item
);
}
static
inline
u32
BTRFS_NODEPTRS_PER_BLOCK
(
const
struct
btrfs_root
*
root
)
{
return
BTRFS_LEAF_DATA_SIZE
(
root
)
/
sizeof
(
struct
btrfs_key_ptr
);
}
#define BTRFS_FILE_EXTENT_INLINE_DATA_START \
(offsetof(struct btrfs_file_extent_item, disk_bytenr))
static
inline
u32
BTRFS_MAX_INLINE_DATA_SIZE
(
const
struct
btrfs_root
*
root
)
{
return
BTRFS_MAX_ITEM_SIZE
(
root
)
-
BTRFS_FILE_EXTENT_INLINE_DATA_START
;
}
static
inline
u32
BTRFS_MAX_XATTR_SIZE
(
const
struct
btrfs_root
*
root
)
{
return
BTRFS_MAX_ITEM_SIZE
(
root
)
-
sizeof
(
struct
btrfs_dir_item
);
}
/*
/*
* Flags for mount options.
* Flags for mount options.
*
*
...
@@ -1299,21 +1319,21 @@ struct btrfs_root {
...
@@ -1299,21 +1319,21 @@ struct btrfs_root {
#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
#define btrfs_raw_test_opt(o, opt) ((o) & BTRFS_MOUNT_##opt)
#define btrfs_raw_test_opt(o, opt) ((o) & BTRFS_MOUNT_##opt)
#define btrfs_test_opt(
root, opt) ((root)->fs_info
->mount_opt & \
#define btrfs_test_opt(
fs_info, opt) ((fs_info)
->mount_opt & \
BTRFS_MOUNT_##opt)
BTRFS_MOUNT_##opt)
#define btrfs_set_and_info(
root
, opt, fmt, args...) \
#define btrfs_set_and_info(
fs_info
, opt, fmt, args...) \
{ \
{ \
if (!btrfs_test_opt(
root, opt))
\
if (!btrfs_test_opt(
fs_info, opt))
\
btrfs_info(
root->
fs_info, fmt, ##args); \
btrfs_info(fs_info, fmt, ##args); \
btrfs_set_opt(
root->fs_info->mount_opt, opt);
\
btrfs_set_opt(
fs_info->mount_opt, opt);
\
}
}
#define btrfs_clear_and_info(
root, opt, fmt, args...)
\
#define btrfs_clear_and_info(
fs_info, opt, fmt, args...)
\
{ \
{ \
if (btrfs_test_opt(
root, opt))
\
if (btrfs_test_opt(
fs_info, opt))
\
btrfs_info(
root->
fs_info, fmt, ##args); \
btrfs_info(fs_info, fmt, ##args); \
btrfs_clear_opt(
root->
fs_info->mount_opt, opt); \
btrfs_clear_opt(fs_info->mount_opt, opt); \
}
}
#ifdef CONFIG_BTRFS_DEBUG
#ifdef CONFIG_BTRFS_DEBUG
...
@@ -1321,9 +1341,9 @@ static inline int
...
@@ -1321,9 +1341,9 @@ static inline int
btrfs_should_fragment_free_space
(
struct
btrfs_root
*
root
,
btrfs_should_fragment_free_space
(
struct
btrfs_root
*
root
,
struct
btrfs_block_group_cache
*
block_group
)
struct
btrfs_block_group_cache
*
block_group
)
{
{
return
(
btrfs_test_opt
(
root
,
FRAGMENT_METADATA
)
&&
return
(
btrfs_test_opt
(
root
->
fs_info
,
FRAGMENT_METADATA
)
&&
block_group
->
flags
&
BTRFS_BLOCK_GROUP_METADATA
)
||
block_group
->
flags
&
BTRFS_BLOCK_GROUP_METADATA
)
||
(
btrfs_test_opt
(
root
,
FRAGMENT_DATA
)
&&
(
btrfs_test_opt
(
root
->
fs_info
,
FRAGMENT_DATA
)
&&
block_group
->
flags
&
BTRFS_BLOCK_GROUP_DATA
);
block_group
->
flags
&
BTRFS_BLOCK_GROUP_DATA
);
}
}
#endif
#endif
...
@@ -2886,9 +2906,6 @@ void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info,
...
@@ -2886,9 +2906,6 @@ void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info,
int
btrfs_old_root_level
(
struct
btrfs_root
*
root
,
u64
time_seq
);
int
btrfs_old_root_level
(
struct
btrfs_root
*
root
,
u64
time_seq
);
/* root-item.c */
/* root-item.c */
int
btrfs_find_root_ref
(
struct
btrfs_root
*
tree_root
,
struct
btrfs_path
*
path
,
u64
root_id
,
u64
ref_id
);
int
btrfs_add_root_ref
(
struct
btrfs_trans_handle
*
trans
,
int
btrfs_add_root_ref
(
struct
btrfs_trans_handle
*
trans
,
struct
btrfs_root
*
tree_root
,
struct
btrfs_root
*
tree_root
,
u64
root_id
,
u64
ref_id
,
u64
dirid
,
u64
sequence
,
u64
root_id
,
u64
ref_id
,
u64
dirid
,
u64
sequence
,
...
@@ -3362,23 +3379,23 @@ const char *btrfs_decode_error(int errno);
...
@@ -3362,23 +3379,23 @@ const char *btrfs_decode_error(int errno);
__cold
__cold
void
__btrfs_abort_transaction
(
struct
btrfs_trans_handle
*
trans
,
void
__btrfs_abort_transaction
(
struct
btrfs_trans_handle
*
trans
,
struct
btrfs_root
*
root
,
const
char
*
function
,
const
char
*
function
,
unsigned
int
line
,
int
errno
);
unsigned
int
line
,
int
errno
);
/*
/*
* Call btrfs_abort_transaction as early as possible when an error condition is
* Call btrfs_abort_transaction as early as possible when an error condition is
* detected, that way the exact line number is reported.
* detected, that way the exact line number is reported.
*/
*/
#define btrfs_abort_transaction(trans,
root,
errno) \
#define btrfs_abort_transaction(trans, errno) \
do { \
do { \
/* Report first abort since mount */
\
/* Report first abort since mount */
\
if (!test_and_set_bit(BTRFS_FS_STATE_TRANS_ABORTED, \
if (!test_and_set_bit(BTRFS_FS_STATE_TRANS_ABORTED, \
&((
root
)->fs_info->fs_state))) { \
&((
trans
)->fs_info->fs_state))) { \
WARN(1, KERN_DEBUG \
WARN(1, KERN_DEBUG \
"BTRFS: Transaction aborted (error %d)\n", \
"BTRFS: Transaction aborted (error %d)\n", \
(errno)); \
(errno)); \
} \
} \
__btrfs_abort_transaction((trans),
(root), __func__,
\
__btrfs_abort_transaction((trans),
__func__,
\
__LINE__, (errno)); \
__LINE__, (errno)); \
} while (0)
} while (0)
...
@@ -3610,13 +3627,13 @@ static inline int btrfs_defrag_cancelled(struct btrfs_fs_info *fs_info)
...
@@ -3610,13 +3627,13 @@ static inline int btrfs_defrag_cancelled(struct btrfs_fs_info *fs_info)
void
btrfs_test_destroy_inode
(
struct
inode
*
inode
);
void
btrfs_test_destroy_inode
(
struct
inode
*
inode
);
#endif
#endif
static
inline
int
btrfs_
test_is_dummy_root
(
struct
btrfs_root
*
root
)
static
inline
int
btrfs_
is_testing
(
struct
btrfs_fs_info
*
fs_info
)
{
{
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
if
(
unlikely
(
test_bit
(
BTRFS_ROOT_DUMMY_ROOT
,
&
root
->
state
)))
if
(
unlikely
(
test_bit
(
BTRFS_FS_STATE_DUMMY_FS_INFO
,
&
fs_info
->
fs_state
)))
return
1
;
return
1
;
#endif
#endif
return
0
;
return
0
;
}
}
#endif
#endif
fs/btrfs/dedupe.h
0 → 100644
浏览文件 @
023a824f
/*
* Copyright (C) 2016 Fujitsu. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License v2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*/
#ifndef __BTRFS_DEDUPE__
#define __BTRFS_DEDUPE__
/* later in-band dedupe will expand this struct */
struct
btrfs_dedupe_hash
;
#endif
fs/btrfs/delayed-inode.c
浏览文件 @
023a824f
...
@@ -34,7 +34,7 @@ int __init btrfs_delayed_inode_init(void)
...
@@ -34,7 +34,7 @@ int __init btrfs_delayed_inode_init(void)
delayed_node_cache
=
kmem_cache_create
(
"btrfs_delayed_node"
,
delayed_node_cache
=
kmem_cache_create
(
"btrfs_delayed_node"
,
sizeof
(
struct
btrfs_delayed_node
),
sizeof
(
struct
btrfs_delayed_node
),
0
,
0
,
SLAB_
RECLAIM_ACCOUNT
|
SLAB_
MEM_SPREAD
,
SLAB_MEM_SPREAD
,
NULL
);
NULL
);
if
(
!
delayed_node_cache
)
if
(
!
delayed_node_cache
)
return
-
ENOMEM
;
return
-
ENOMEM
;
...
@@ -1170,7 +1170,7 @@ static int __btrfs_run_delayed_items(struct btrfs_trans_handle *trans,
...
@@ -1170,7 +1170,7 @@ static int __btrfs_run_delayed_items(struct btrfs_trans_handle *trans,
if
(
ret
)
{
if
(
ret
)
{
btrfs_release_delayed_node
(
curr_node
);
btrfs_release_delayed_node
(
curr_node
);
curr_node
=
NULL
;
curr_node
=
NULL
;
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
break
;
break
;
}
}
...
...
fs/btrfs/delayed-ref.c
浏览文件 @
023a824f
...
@@ -606,7 +606,8 @@ add_delayed_ref_head(struct btrfs_fs_info *fs_info,
...
@@ -606,7 +606,8 @@ add_delayed_ref_head(struct btrfs_fs_info *fs_info,
qrecord
->
num_bytes
=
num_bytes
;
qrecord
->
num_bytes
=
num_bytes
;
qrecord
->
old_roots
=
NULL
;
qrecord
->
old_roots
=
NULL
;
qexisting
=
btrfs_qgroup_insert_dirty_extent
(
delayed_refs
,
qexisting
=
btrfs_qgroup_insert_dirty_extent
(
fs_info
,
delayed_refs
,
qrecord
);
qrecord
);
if
(
qexisting
)
if
(
qexisting
)
kfree
(
qrecord
);
kfree
(
qrecord
);
...
@@ -615,7 +616,7 @@ add_delayed_ref_head(struct btrfs_fs_info *fs_info,
...
@@ -615,7 +616,7 @@ add_delayed_ref_head(struct btrfs_fs_info *fs_info,
spin_lock_init
(
&
head_ref
->
lock
);
spin_lock_init
(
&
head_ref
->
lock
);
mutex_init
(
&
head_ref
->
mutex
);
mutex_init
(
&
head_ref
->
mutex
);
trace_add_delayed_ref_head
(
ref
,
head_ref
,
action
);
trace_add_delayed_ref_head
(
fs_info
,
ref
,
head_ref
,
action
);
existing
=
htree_insert
(
&
delayed_refs
->
href_root
,
existing
=
htree_insert
(
&
delayed_refs
->
href_root
,
&
head_ref
->
href_node
);
&
head_ref
->
href_node
);
...
@@ -682,7 +683,7 @@ add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
...
@@ -682,7 +683,7 @@ add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
ref
->
type
=
BTRFS_TREE_BLOCK_REF_KEY
;
ref
->
type
=
BTRFS_TREE_BLOCK_REF_KEY
;
full_ref
->
level
=
level
;
full_ref
->
level
=
level
;
trace_add_delayed_tree_ref
(
ref
,
full_ref
,
action
);
trace_add_delayed_tree_ref
(
fs_info
,
ref
,
full_ref
,
action
);
ret
=
add_delayed_ref_tail_merge
(
trans
,
delayed_refs
,
head_ref
,
ref
);
ret
=
add_delayed_ref_tail_merge
(
trans
,
delayed_refs
,
head_ref
,
ref
);
...
@@ -739,7 +740,7 @@ add_delayed_data_ref(struct btrfs_fs_info *fs_info,
...
@@ -739,7 +740,7 @@ add_delayed_data_ref(struct btrfs_fs_info *fs_info,
full_ref
->
objectid
=
owner
;
full_ref
->
objectid
=
owner
;
full_ref
->
offset
=
offset
;
full_ref
->
offset
=
offset
;
trace_add_delayed_data_ref
(
ref
,
full_ref
,
action
);
trace_add_delayed_data_ref
(
fs_info
,
ref
,
full_ref
,
action
);
ret
=
add_delayed_ref_tail_merge
(
trans
,
delayed_refs
,
head_ref
,
ref
);
ret
=
add_delayed_ref_tail_merge
(
trans
,
delayed_refs
,
head_ref
,
ref
);
...
@@ -940,28 +941,28 @@ int btrfs_delayed_ref_init(void)
...
@@ -940,28 +941,28 @@ int btrfs_delayed_ref_init(void)
btrfs_delayed_ref_head_cachep
=
kmem_cache_create
(
btrfs_delayed_ref_head_cachep
=
kmem_cache_create
(
"btrfs_delayed_ref_head"
,
"btrfs_delayed_ref_head"
,
sizeof
(
struct
btrfs_delayed_ref_head
),
0
,
sizeof
(
struct
btrfs_delayed_ref_head
),
0
,
SLAB_
RECLAIM_ACCOUNT
|
SLAB_
MEM_SPREAD
,
NULL
);
SLAB_MEM_SPREAD
,
NULL
);
if
(
!
btrfs_delayed_ref_head_cachep
)
if
(
!
btrfs_delayed_ref_head_cachep
)
goto
fail
;
goto
fail
;
btrfs_delayed_tree_ref_cachep
=
kmem_cache_create
(
btrfs_delayed_tree_ref_cachep
=
kmem_cache_create
(
"btrfs_delayed_tree_ref"
,
"btrfs_delayed_tree_ref"
,
sizeof
(
struct
btrfs_delayed_tree_ref
),
0
,
sizeof
(
struct
btrfs_delayed_tree_ref
),
0
,
SLAB_
RECLAIM_ACCOUNT
|
SLAB_
MEM_SPREAD
,
NULL
);
SLAB_MEM_SPREAD
,
NULL
);
if
(
!
btrfs_delayed_tree_ref_cachep
)
if
(
!
btrfs_delayed_tree_ref_cachep
)
goto
fail
;
goto
fail
;
btrfs_delayed_data_ref_cachep
=
kmem_cache_create
(
btrfs_delayed_data_ref_cachep
=
kmem_cache_create
(
"btrfs_delayed_data_ref"
,
"btrfs_delayed_data_ref"
,
sizeof
(
struct
btrfs_delayed_data_ref
),
0
,
sizeof
(
struct
btrfs_delayed_data_ref
),
0
,
SLAB_
RECLAIM_ACCOUNT
|
SLAB_
MEM_SPREAD
,
NULL
);
SLAB_MEM_SPREAD
,
NULL
);
if
(
!
btrfs_delayed_data_ref_cachep
)
if
(
!
btrfs_delayed_data_ref_cachep
)
goto
fail
;
goto
fail
;
btrfs_delayed_extent_op_cachep
=
kmem_cache_create
(
btrfs_delayed_extent_op_cachep
=
kmem_cache_create
(
"btrfs_delayed_extent_op"
,
"btrfs_delayed_extent_op"
,
sizeof
(
struct
btrfs_delayed_extent_op
),
0
,
sizeof
(
struct
btrfs_delayed_extent_op
),
0
,
SLAB_
RECLAIM_ACCOUNT
|
SLAB_
MEM_SPREAD
,
NULL
);
SLAB_MEM_SPREAD
,
NULL
);
if
(
!
btrfs_delayed_extent_op_cachep
)
if
(
!
btrfs_delayed_extent_op_cachep
)
goto
fail
;
goto
fail
;
...
...
fs/btrfs/dev-replace.c
浏览文件 @
023a824f
...
@@ -142,7 +142,7 @@ int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info)
...
@@ -142,7 +142,7 @@ int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info)
* missing
* missing
*/
*/
if
(
!
dev_replace
->
srcdev
&&
if
(
!
dev_replace
->
srcdev
&&
!
btrfs_test_opt
(
dev_root
,
DEGRADED
))
{
!
btrfs_test_opt
(
dev_root
->
fs_info
,
DEGRADED
))
{
ret
=
-
EIO
;
ret
=
-
EIO
;
btrfs_warn
(
fs_info
,
btrfs_warn
(
fs_info
,
"cannot mount because device replace operation is ongoing and"
);
"cannot mount because device replace operation is ongoing and"
);
...
@@ -151,7 +151,7 @@ int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info)
...
@@ -151,7 +151,7 @@ int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info)
src_devid
);
src_devid
);
}
}
if
(
!
dev_replace
->
tgtdev
&&
if
(
!
dev_replace
->
tgtdev
&&
!
btrfs_test_opt
(
dev_root
,
DEGRADED
))
{
!
btrfs_test_opt
(
dev_root
->
fs_info
,
DEGRADED
))
{
ret
=
-
EIO
;
ret
=
-
EIO
;
btrfs_warn
(
fs_info
,
btrfs_warn
(
fs_info
,
"cannot mount because device replace operation is ongoing and"
);
"cannot mount because device replace operation is ongoing and"
);
...
...
fs/btrfs/disk-io.c
浏览文件 @
023a824f
...
@@ -101,7 +101,7 @@ int __init btrfs_end_io_wq_init(void)
...
@@ -101,7 +101,7 @@ int __init btrfs_end_io_wq_init(void)
btrfs_end_io_wq_cache
=
kmem_cache_create
(
"btrfs_end_io_wq"
,
btrfs_end_io_wq_cache
=
kmem_cache_create
(
"btrfs_end_io_wq"
,
sizeof
(
struct
btrfs_end_io_wq
),
sizeof
(
struct
btrfs_end_io_wq
),
0
,
0
,
SLAB_
RECLAIM_ACCOUNT
|
SLAB_
MEM_SPREAD
,
SLAB_MEM_SPREAD
,
NULL
);
NULL
);
if
(
!
btrfs_end_io_wq_cache
)
if
(
!
btrfs_end_io_wq_cache
)
return
-
ENOMEM
;
return
-
ENOMEM
;
...
@@ -1146,7 +1146,7 @@ struct extent_buffer *btrfs_find_tree_block(struct btrfs_fs_info *fs_info,
...
@@ -1146,7 +1146,7 @@ struct extent_buffer *btrfs_find_tree_block(struct btrfs_fs_info *fs_info,
struct
extent_buffer
*
btrfs_find_create_tree_block
(
struct
btrfs_root
*
root
,
struct
extent_buffer
*
btrfs_find_create_tree_block
(
struct
btrfs_root
*
root
,
u64
bytenr
)
u64
bytenr
)
{
{
if
(
btrfs_
test_is_dummy_root
(
root
))
if
(
btrfs_
is_testing
(
root
->
fs_info
))
return
alloc_test_extent_buffer
(
root
->
fs_info
,
bytenr
,
return
alloc_test_extent_buffer
(
root
->
fs_info
,
bytenr
,
root
->
nodesize
);
root
->
nodesize
);
return
alloc_extent_buffer
(
root
->
fs_info
,
bytenr
);
return
alloc_extent_buffer
(
root
->
fs_info
,
bytenr
);
...
@@ -1233,6 +1233,7 @@ static void __setup_root(u32 nodesize, u32 sectorsize, u32 stripesize,
...
@@ -1233,6 +1233,7 @@ static void __setup_root(u32 nodesize, u32 sectorsize, u32 stripesize,
struct
btrfs_root
*
root
,
struct
btrfs_fs_info
*
fs_info
,
struct
btrfs_root
*
root
,
struct
btrfs_fs_info
*
fs_info
,
u64
objectid
)
u64
objectid
)
{
{
bool
dummy
=
test_bit
(
BTRFS_FS_STATE_DUMMY_FS_INFO
,
&
fs_info
->
fs_state
);
root
->
node
=
NULL
;
root
->
node
=
NULL
;
root
->
commit_root
=
NULL
;
root
->
commit_root
=
NULL
;
root
->
sectorsize
=
sectorsize
;
root
->
sectorsize
=
sectorsize
;
...
@@ -1287,14 +1288,14 @@ static void __setup_root(u32 nodesize, u32 sectorsize, u32 stripesize,
...
@@ -1287,14 +1288,14 @@ static void __setup_root(u32 nodesize, u32 sectorsize, u32 stripesize,
root
->
log_transid
=
0
;
root
->
log_transid
=
0
;
root
->
log_transid_committed
=
-
1
;
root
->
log_transid_committed
=
-
1
;
root
->
last_log_commit
=
0
;
root
->
last_log_commit
=
0
;
if
(
fs_info
)
if
(
!
dummy
)
extent_io_tree_init
(
&
root
->
dirty_log_pages
,
extent_io_tree_init
(
&
root
->
dirty_log_pages
,
fs_info
->
btree_inode
->
i_mapping
);
fs_info
->
btree_inode
->
i_mapping
);
memset
(
&
root
->
root_key
,
0
,
sizeof
(
root
->
root_key
));
memset
(
&
root
->
root_key
,
0
,
sizeof
(
root
->
root_key
));
memset
(
&
root
->
root_item
,
0
,
sizeof
(
root
->
root_item
));
memset
(
&
root
->
root_item
,
0
,
sizeof
(
root
->
root_item
));
memset
(
&
root
->
defrag_progress
,
0
,
sizeof
(
root
->
defrag_progress
));
memset
(
&
root
->
defrag_progress
,
0
,
sizeof
(
root
->
defrag_progress
));
if
(
fs_info
)
if
(
!
dummy
)
root
->
defrag_trans_start
=
fs_info
->
generation
;
root
->
defrag_trans_start
=
fs_info
->
generation
;
else
else
root
->
defrag_trans_start
=
0
;
root
->
defrag_trans_start
=
0
;
...
@@ -1315,17 +1316,20 @@ static struct btrfs_root *btrfs_alloc_root(struct btrfs_fs_info *fs_info,
...
@@ -1315,17 +1316,20 @@ static struct btrfs_root *btrfs_alloc_root(struct btrfs_fs_info *fs_info,
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
/* Should only be used by the testing infrastructure */
/* Should only be used by the testing infrastructure */
struct
btrfs_root
*
btrfs_alloc_dummy_root
(
u32
sectorsize
,
u32
nodesize
)
struct
btrfs_root
*
btrfs_alloc_dummy_root
(
struct
btrfs_fs_info
*
fs_info
,
u32
sectorsize
,
u32
nodesize
)
{
{
struct
btrfs_root
*
root
;
struct
btrfs_root
*
root
;
root
=
btrfs_alloc_root
(
NULL
,
GFP_KERNEL
);
if
(
!
fs_info
)
return
ERR_PTR
(
-
EINVAL
);
root
=
btrfs_alloc_root
(
fs_info
,
GFP_KERNEL
);
if
(
!
root
)
if
(
!
root
)
return
ERR_PTR
(
-
ENOMEM
);
return
ERR_PTR
(
-
ENOMEM
);
/* We don't use the stripesize in selftest, set it as sectorsize */
/* We don't use the stripesize in selftest, set it as sectorsize */
__setup_root
(
nodesize
,
sectorsize
,
sectorsize
,
root
,
NULL
,
__setup_root
(
nodesize
,
sectorsize
,
sectorsize
,
root
,
fs_info
,
BTRFS_ROOT_TREE_OBJECTID
);
BTRFS_ROOT_TREE_OBJECTID
);
set_bit
(
BTRFS_ROOT_DUMMY_ROOT
,
&
root
->
state
);
root
->
alloc_bytenr
=
0
;
root
->
alloc_bytenr
=
0
;
return
root
;
return
root
;
...
@@ -1600,14 +1604,14 @@ int btrfs_init_fs_root(struct btrfs_root *root)
...
@@ -1600,14 +1604,14 @@ int btrfs_init_fs_root(struct btrfs_root *root)
ret
=
get_anon_bdev
(
&
root
->
anon_dev
);
ret
=
get_anon_bdev
(
&
root
->
anon_dev
);
if
(
ret
)
if
(
ret
)
goto
f
ree_writers
;
goto
f
ail
;
mutex_lock
(
&
root
->
objectid_mutex
);
mutex_lock
(
&
root
->
objectid_mutex
);
ret
=
btrfs_find_highest_objectid
(
root
,
ret
=
btrfs_find_highest_objectid
(
root
,
&
root
->
highest_objectid
);
&
root
->
highest_objectid
);
if
(
ret
)
{
if
(
ret
)
{
mutex_unlock
(
&
root
->
objectid_mutex
);
mutex_unlock
(
&
root
->
objectid_mutex
);
goto
f
ree_root_dev
;
goto
f
ail
;
}
}
ASSERT
(
root
->
highest_objectid
<=
BTRFS_LAST_FREE_OBJECTID
);
ASSERT
(
root
->
highest_objectid
<=
BTRFS_LAST_FREE_OBJECTID
);
...
@@ -1615,14 +1619,8 @@ int btrfs_init_fs_root(struct btrfs_root *root)
...
@@ -1615,14 +1619,8 @@ int btrfs_init_fs_root(struct btrfs_root *root)
mutex_unlock
(
&
root
->
objectid_mutex
);
mutex_unlock
(
&
root
->
objectid_mutex
);
return
0
;
return
0
;
free_root_dev:
free_anon_bdev
(
root
->
anon_dev
);
free_writers:
btrfs_free_subvolume_writers
(
root
->
subv_writers
);
fail:
fail:
kfree
(
root
->
free_ino_ctl
);
/* the caller is responsible to call free_fs_root */
kfree
(
root
->
free_ino_pinned
);
return
ret
;
return
ret
;
}
}
...
@@ -2316,17 +2314,19 @@ static int btrfs_init_workqueues(struct btrfs_fs_info *fs_info,
...
@@ -2316,17 +2314,19 @@ static int btrfs_init_workqueues(struct btrfs_fs_info *fs_info,
unsigned
int
flags
=
WQ_MEM_RECLAIM
|
WQ_FREEZABLE
|
WQ_UNBOUND
;
unsigned
int
flags
=
WQ_MEM_RECLAIM
|
WQ_FREEZABLE
|
WQ_UNBOUND
;
fs_info
->
workers
=
fs_info
->
workers
=
btrfs_alloc_workqueue
(
"worker"
,
flags
|
WQ_HIGHPRI
,
btrfs_alloc_workqueue
(
fs_info
,
"worker"
,
max_active
,
16
);
flags
|
WQ_HIGHPRI
,
max_active
,
16
);
fs_info
->
delalloc_workers
=
fs_info
->
delalloc_workers
=
btrfs_alloc_workqueue
(
"delalloc"
,
flags
,
max_active
,
2
);
btrfs_alloc_workqueue
(
fs_info
,
"delalloc"
,
flags
,
max_active
,
2
);
fs_info
->
flush_workers
=
fs_info
->
flush_workers
=
btrfs_alloc_workqueue
(
"flush_delalloc"
,
flags
,
max_active
,
0
);
btrfs_alloc_workqueue
(
fs_info
,
"flush_delalloc"
,
flags
,
max_active
,
0
);
fs_info
->
caching_workers
=
fs_info
->
caching_workers
=
btrfs_alloc_workqueue
(
"cache"
,
flags
,
max_active
,
0
);
btrfs_alloc_workqueue
(
fs_info
,
"cache"
,
flags
,
max_active
,
0
);
/*
/*
* a higher idle thresh on the submit workers makes it much more
* a higher idle thresh on the submit workers makes it much more
...
@@ -2334,41 +2334,48 @@ static int btrfs_init_workqueues(struct btrfs_fs_info *fs_info,
...
@@ -2334,41 +2334,48 @@ static int btrfs_init_workqueues(struct btrfs_fs_info *fs_info,
* devices
* devices
*/
*/
fs_info
->
submit_workers
=
fs_info
->
submit_workers
=
btrfs_alloc_workqueue
(
"submit"
,
flags
,
btrfs_alloc_workqueue
(
fs_info
,
"submit"
,
flags
,
min_t
(
u64
,
fs_devices
->
num_devices
,
min_t
(
u64
,
fs_devices
->
num_devices
,
max_active
),
64
);
max_active
),
64
);
fs_info
->
fixup_workers
=
fs_info
->
fixup_workers
=
btrfs_alloc_workqueue
(
"fixup"
,
flags
,
1
,
0
);
btrfs_alloc_workqueue
(
fs_info
,
"fixup"
,
flags
,
1
,
0
);
/*
/*
* endios are largely parallel and should have a very
* endios are largely parallel and should have a very
* low idle thresh
* low idle thresh
*/
*/
fs_info
->
endio_workers
=
fs_info
->
endio_workers
=
btrfs_alloc_workqueue
(
"endio"
,
flags
,
max_active
,
4
);
btrfs_alloc_workqueue
(
fs_info
,
"endio"
,
flags
,
max_active
,
4
);
fs_info
->
endio_meta_workers
=
fs_info
->
endio_meta_workers
=
btrfs_alloc_workqueue
(
"endio-meta"
,
flags
,
max_active
,
4
);
btrfs_alloc_workqueue
(
fs_info
,
"endio-meta"
,
flags
,
max_active
,
4
);
fs_info
->
endio_meta_write_workers
=
fs_info
->
endio_meta_write_workers
=
btrfs_alloc_workqueue
(
"endio-meta-write"
,
flags
,
max_active
,
2
);
btrfs_alloc_workqueue
(
fs_info
,
"endio-meta-write"
,
flags
,
max_active
,
2
);
fs_info
->
endio_raid56_workers
=
fs_info
->
endio_raid56_workers
=
btrfs_alloc_workqueue
(
"endio-raid56"
,
flags
,
max_active
,
4
);
btrfs_alloc_workqueue
(
fs_info
,
"endio-raid56"
,
flags
,
max_active
,
4
);
fs_info
->
endio_repair_workers
=
fs_info
->
endio_repair_workers
=
btrfs_alloc_workqueue
(
"endio-repair"
,
flags
,
1
,
0
);
btrfs_alloc_workqueue
(
fs_info
,
"endio-repair"
,
flags
,
1
,
0
);
fs_info
->
rmw_workers
=
fs_info
->
rmw_workers
=
btrfs_alloc_workqueue
(
"rmw"
,
flags
,
max_active
,
2
);
btrfs_alloc_workqueue
(
fs_info
,
"rmw"
,
flags
,
max_active
,
2
);
fs_info
->
endio_write_workers
=
fs_info
->
endio_write_workers
=
btrfs_alloc_workqueue
(
"endio-write"
,
flags
,
max_active
,
2
);
btrfs_alloc_workqueue
(
fs_info
,
"endio-write"
,
flags
,
max_active
,
2
);
fs_info
->
endio_freespace_worker
=
fs_info
->
endio_freespace_worker
=
btrfs_alloc_workqueue
(
"freespace-write"
,
flags
,
max_active
,
0
);
btrfs_alloc_workqueue
(
fs_info
,
"freespace-write"
,
flags
,
max_active
,
0
);
fs_info
->
delayed_workers
=
fs_info
->
delayed_workers
=
btrfs_alloc_workqueue
(
"delayed-meta"
,
flags
,
max_active
,
0
);
btrfs_alloc_workqueue
(
fs_info
,
"delayed-meta"
,
flags
,
max_active
,
0
);
fs_info
->
readahead_workers
=
fs_info
->
readahead_workers
=
btrfs_alloc_workqueue
(
"readahead"
,
flags
,
max_active
,
2
);
btrfs_alloc_workqueue
(
fs_info
,
"readahead"
,
flags
,
max_active
,
2
);
fs_info
->
qgroup_rescan_workers
=
fs_info
->
qgroup_rescan_workers
=
btrfs_alloc_workqueue
(
"qgroup-rescan"
,
flags
,
1
,
0
);
btrfs_alloc_workqueue
(
fs_info
,
"qgroup-rescan"
,
flags
,
1
,
0
);
fs_info
->
extent_workers
=
fs_info
->
extent_workers
=
btrfs_alloc_workqueue
(
"extent-refs"
,
flags
,
btrfs_alloc_workqueue
(
fs_info
,
"extent-refs"
,
flags
,
min_t
(
u64
,
fs_devices
->
num_devices
,
min_t
(
u64
,
fs_devices
->
num_devices
,
max_active
),
8
);
max_active
),
8
);
...
@@ -3016,8 +3023,8 @@ int open_ctree(struct super_block *sb,
...
@@ -3016,8 +3023,8 @@ int open_ctree(struct super_block *sb,
if
(
IS_ERR
(
fs_info
->
transaction_kthread
))
if
(
IS_ERR
(
fs_info
->
transaction_kthread
))
goto
fail_cleaner
;
goto
fail_cleaner
;
if
(
!
btrfs_test_opt
(
tree_root
,
SSD
)
&&
if
(
!
btrfs_test_opt
(
tree_root
->
fs_info
,
SSD
)
&&
!
btrfs_test_opt
(
tree_root
,
NOSSD
)
&&
!
btrfs_test_opt
(
tree_root
->
fs_info
,
NOSSD
)
&&
!
fs_info
->
fs_devices
->
rotating
)
{
!
fs_info
->
fs_devices
->
rotating
)
{
btrfs_info
(
fs_info
,
"detected SSD devices, enabling SSD mode"
);
btrfs_info
(
fs_info
,
"detected SSD devices, enabling SSD mode"
);
btrfs_set_opt
(
fs_info
->
mount_opt
,
SSD
);
btrfs_set_opt
(
fs_info
->
mount_opt
,
SSD
);
...
@@ -3030,9 +3037,9 @@ int open_ctree(struct super_block *sb,
...
@@ -3030,9 +3037,9 @@ int open_ctree(struct super_block *sb,
btrfs_apply_pending_changes
(
fs_info
);
btrfs_apply_pending_changes
(
fs_info
);
#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
if
(
btrfs_test_opt
(
tree_root
,
CHECK_INTEGRITY
))
{
if
(
btrfs_test_opt
(
tree_root
->
fs_info
,
CHECK_INTEGRITY
))
{
ret
=
btrfsic_mount
(
tree_root
,
fs_devices
,
ret
=
btrfsic_mount
(
tree_root
,
fs_devices
,
btrfs_test_opt
(
tree_root
,
btrfs_test_opt
(
tree_root
->
fs_info
,
CHECK_INTEGRITY_INCLUDING_EXTENT_DATA
)
?
CHECK_INTEGRITY_INCLUDING_EXTENT_DATA
)
?
1
:
0
,
1
:
0
,
fs_info
->
check_integrity_print_mask
);
fs_info
->
check_integrity_print_mask
);
...
@@ -3048,7 +3055,7 @@ int open_ctree(struct super_block *sb,
...
@@ -3048,7 +3055,7 @@ int open_ctree(struct super_block *sb,
/* do not make disk changes in broken FS or nologreplay is given */
/* do not make disk changes in broken FS or nologreplay is given */
if
(
btrfs_super_log_root
(
disk_super
)
!=
0
&&
if
(
btrfs_super_log_root
(
disk_super
)
!=
0
&&
!
btrfs_test_opt
(
tree_root
,
NOLOGREPLAY
))
{
!
btrfs_test_opt
(
tree_root
->
fs_info
,
NOLOGREPLAY
))
{
ret
=
btrfs_replay_log
(
fs_info
,
fs_devices
);
ret
=
btrfs_replay_log
(
fs_info
,
fs_devices
);
if
(
ret
)
{
if
(
ret
)
{
err
=
ret
;
err
=
ret
;
...
@@ -3089,7 +3096,7 @@ int open_ctree(struct super_block *sb,
...
@@ -3089,7 +3096,7 @@ int open_ctree(struct super_block *sb,
if
(
sb
->
s_flags
&
MS_RDONLY
)
if
(
sb
->
s_flags
&
MS_RDONLY
)
return
0
;
return
0
;
if
(
btrfs_test_opt
(
tree_root
,
FREE_SPACE_TREE
)
&&
if
(
btrfs_test_opt
(
tree_root
->
fs_info
,
FREE_SPACE_TREE
)
&&
!
btrfs_fs_compat_ro
(
fs_info
,
FREE_SPACE_TREE
))
{
!
btrfs_fs_compat_ro
(
fs_info
,
FREE_SPACE_TREE
))
{
btrfs_info
(
fs_info
,
"creating free space tree"
);
btrfs_info
(
fs_info
,
"creating free space tree"
);
ret
=
btrfs_create_free_space_tree
(
fs_info
);
ret
=
btrfs_create_free_space_tree
(
fs_info
);
...
@@ -3126,7 +3133,7 @@ int open_ctree(struct super_block *sb,
...
@@ -3126,7 +3133,7 @@ int open_ctree(struct super_block *sb,
btrfs_qgroup_rescan_resume
(
fs_info
);
btrfs_qgroup_rescan_resume
(
fs_info
);
if
(
btrfs_test_opt
(
tree_root
,
CLEAR_CACHE
)
&&
if
(
btrfs_test_opt
(
tree_root
->
fs_info
,
CLEAR_CACHE
)
&&
btrfs_fs_compat_ro
(
fs_info
,
FREE_SPACE_TREE
))
{
btrfs_fs_compat_ro
(
fs_info
,
FREE_SPACE_TREE
))
{
btrfs_info
(
fs_info
,
"clearing free space tree"
);
btrfs_info
(
fs_info
,
"clearing free space tree"
);
ret
=
btrfs_clear_free_space_tree
(
fs_info
);
ret
=
btrfs_clear_free_space_tree
(
fs_info
);
...
@@ -3147,7 +3154,7 @@ int open_ctree(struct super_block *sb,
...
@@ -3147,7 +3154,7 @@ int open_ctree(struct super_block *sb,
close_ctree
(
tree_root
);
close_ctree
(
tree_root
);
return
ret
;
return
ret
;
}
}
}
else
if
(
btrfs_test_opt
(
tree_root
,
RESCAN_UUID_TREE
)
||
}
else
if
(
btrfs_test_opt
(
tree_root
->
fs_info
,
RESCAN_UUID_TREE
)
||
fs_info
->
generation
!=
fs_info
->
generation
!=
btrfs_super_uuid_tree_generation
(
disk_super
))
{
btrfs_super_uuid_tree_generation
(
disk_super
))
{
btrfs_info
(
fs_info
,
"checking UUID tree"
);
btrfs_info
(
fs_info
,
"checking UUID tree"
);
...
@@ -3224,7 +3231,7 @@ int open_ctree(struct super_block *sb,
...
@@ -3224,7 +3231,7 @@ int open_ctree(struct super_block *sb,
return
err
;
return
err
;
recovery_tree_root:
recovery_tree_root:
if
(
!
btrfs_test_opt
(
tree_root
,
USEBACKUPROOT
))
if
(
!
btrfs_test_opt
(
tree_root
->
fs_info
,
USEBACKUPROOT
))
goto
fail_tree_roots
;
goto
fail_tree_roots
;
free_root_pointers
(
fs_info
,
0
);
free_root_pointers
(
fs_info
,
0
);
...
@@ -3639,7 +3646,7 @@ static int write_all_supers(struct btrfs_root *root, int max_mirrors)
...
@@ -3639,7 +3646,7 @@ static int write_all_supers(struct btrfs_root *root, int max_mirrors)
int
total_errors
=
0
;
int
total_errors
=
0
;
u64
flags
;
u64
flags
;
do_barriers
=
!
btrfs_test_opt
(
root
,
NOBARRIER
);
do_barriers
=
!
btrfs_test_opt
(
root
->
fs_info
,
NOBARRIER
);
backup_super_roots
(
root
->
fs_info
);
backup_super_roots
(
root
->
fs_info
);
sb
=
root
->
fs_info
->
super_for_commit
;
sb
=
root
->
fs_info
->
super_for_commit
;
...
@@ -3923,7 +3930,7 @@ void close_ctree(struct btrfs_root *root)
...
@@ -3923,7 +3930,7 @@ void close_ctree(struct btrfs_root *root)
iput
(
fs_info
->
btree_inode
);
iput
(
fs_info
->
btree_inode
);
#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
if
(
btrfs_test_opt
(
root
,
CHECK_INTEGRITY
))
if
(
btrfs_test_opt
(
root
->
fs_info
,
CHECK_INTEGRITY
))
btrfsic_unmount
(
root
,
fs_info
->
fs_devices
);
btrfsic_unmount
(
root
,
fs_info
->
fs_devices
);
#endif
#endif
...
...
fs/btrfs/disk-io.h
浏览文件 @
023a824f
...
@@ -90,7 +90,8 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,
...
@@ -90,7 +90,8 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,
void
btrfs_free_fs_root
(
struct
btrfs_root
*
root
);
void
btrfs_free_fs_root
(
struct
btrfs_root
*
root
);
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
struct
btrfs_root
*
btrfs_alloc_dummy_root
(
u32
sectorsize
,
u32
nodesize
);
struct
btrfs_root
*
btrfs_alloc_dummy_root
(
struct
btrfs_fs_info
*
fs_info
,
u32
sectorsize
,
u32
nodesize
);
#endif
#endif
/*
/*
...
...
fs/btrfs/extent-tree.c
浏览文件 @
023a824f
...
@@ -2180,7 +2180,7 @@ static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
...
@@ -2180,7 +2180,7 @@ static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
path
,
bytenr
,
parent
,
root_objectid
,
path
,
bytenr
,
parent
,
root_objectid
,
owner
,
offset
,
refs_to_add
);
owner
,
offset
,
refs_to_add
);
if
(
ret
)
if
(
ret
)
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
out:
out:
btrfs_free_path
(
path
);
btrfs_free_path
(
path
);
return
ret
;
return
ret
;
...
@@ -2204,7 +2204,7 @@ static int run_delayed_data_ref(struct btrfs_trans_handle *trans,
...
@@ -2204,7 +2204,7 @@ static int run_delayed_data_ref(struct btrfs_trans_handle *trans,
ins
.
type
=
BTRFS_EXTENT_ITEM_KEY
;
ins
.
type
=
BTRFS_EXTENT_ITEM_KEY
;
ref
=
btrfs_delayed_node_to_data_ref
(
node
);
ref
=
btrfs_delayed_node_to_data_ref
(
node
);
trace_run_delayed_data_ref
(
node
,
ref
,
node
->
action
);
trace_run_delayed_data_ref
(
root
->
fs_info
,
node
,
ref
,
node
->
action
);
if
(
node
->
type
==
BTRFS_SHARED_DATA_REF_KEY
)
if
(
node
->
type
==
BTRFS_SHARED_DATA_REF_KEY
)
parent
=
ref
->
parent
;
parent
=
ref
->
parent
;
...
@@ -2359,7 +2359,7 @@ static int run_delayed_tree_ref(struct btrfs_trans_handle *trans,
...
@@ -2359,7 +2359,7 @@ static int run_delayed_tree_ref(struct btrfs_trans_handle *trans,
SKINNY_METADATA
);
SKINNY_METADATA
);
ref
=
btrfs_delayed_node_to_tree_ref
(
node
);
ref
=
btrfs_delayed_node_to_tree_ref
(
node
);
trace_run_delayed_tree_ref
(
node
,
ref
,
node
->
action
);
trace_run_delayed_tree_ref
(
root
->
fs_info
,
node
,
ref
,
node
->
action
);
if
(
node
->
type
==
BTRFS_SHARED_BLOCK_REF_KEY
)
if
(
node
->
type
==
BTRFS_SHARED_BLOCK_REF_KEY
)
parent
=
ref
->
parent
;
parent
=
ref
->
parent
;
...
@@ -2423,7 +2423,8 @@ static int run_one_delayed_ref(struct btrfs_trans_handle *trans,
...
@@ -2423,7 +2423,8 @@ static int run_one_delayed_ref(struct btrfs_trans_handle *trans,
*/
*/
BUG_ON
(
extent_op
);
BUG_ON
(
extent_op
);
head
=
btrfs_delayed_node_to_head
(
node
);
head
=
btrfs_delayed_node_to_head
(
node
);
trace_run_delayed_ref_head
(
node
,
head
,
node
->
action
);
trace_run_delayed_ref_head
(
root
->
fs_info
,
node
,
head
,
node
->
action
);
if
(
insert_reserved
)
{
if
(
insert_reserved
)
{
btrfs_pin_extent
(
root
,
node
->
bytenr
,
btrfs_pin_extent
(
root
,
node
->
bytenr
,
...
@@ -2778,7 +2779,7 @@ u64 btrfs_csum_bytes_to_leaves(struct btrfs_root *root, u64 csum_bytes)
...
@@ -2778,7 +2779,7 @@ u64 btrfs_csum_bytes_to_leaves(struct btrfs_root *root, u64 csum_bytes)
u64
num_csums_per_leaf
;
u64
num_csums_per_leaf
;
u64
num_csums
;
u64
num_csums
;
csum_size
=
BTRFS_
LEAF_DATA_SIZE
(
root
)
-
sizeof
(
struct
btrfs_item
);
csum_size
=
BTRFS_
MAX_ITEM_SIZE
(
root
);
num_csums_per_leaf
=
div64_u64
(
csum_size
,
num_csums_per_leaf
=
div64_u64
(
csum_size
,
(
u64
)
btrfs_super_csum_size
(
root
->
fs_info
->
super_copy
));
(
u64
)
btrfs_super_csum_size
(
root
->
fs_info
->
super_copy
));
num_csums
=
div64_u64
(
csum_bytes
,
root
->
sectorsize
);
num_csums
=
div64_u64
(
csum_bytes
,
root
->
sectorsize
);
...
@@ -2970,7 +2971,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
...
@@ -2970,7 +2971,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
trans
->
can_flush_pending_bgs
=
false
;
trans
->
can_flush_pending_bgs
=
false
;
ret
=
__btrfs_run_delayed_refs
(
trans
,
root
,
count
);
ret
=
__btrfs_run_delayed_refs
(
trans
,
root
,
count
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
return
ret
;
return
ret
;
}
}
...
@@ -3234,7 +3235,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
...
@@ -3234,7 +3235,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
u64
,
u64
,
u64
,
u64
,
u64
,
u64
);
u64
,
u64
,
u64
,
u64
,
u64
,
u64
);
if
(
btrfs_
test_is_dummy_root
(
root
))
if
(
btrfs_
is_testing
(
root
->
fs_info
))
return
0
;
return
0
;
ref_root
=
btrfs_header_owner
(
buf
);
ref_root
=
btrfs_header_owner
(
buf
);
...
@@ -3429,7 +3430,7 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
...
@@ -3429,7 +3430,7 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
* transaction, this only happens in really bad situations
* transaction, this only happens in really bad situations
* anyway.
* anyway.
*/
*/
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out_put
;
goto
out_put
;
}
}
WARN_ON
(
ret
);
WARN_ON
(
ret
);
...
@@ -3447,7 +3448,7 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
...
@@ -3447,7 +3448,7 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
spin_lock
(
&
block_group
->
lock
);
spin_lock
(
&
block_group
->
lock
);
if
(
block_group
->
cached
!=
BTRFS_CACHE_FINISHED
||
if
(
block_group
->
cached
!=
BTRFS_CACHE_FINISHED
||
!
btrfs_test_opt
(
root
,
SPACE_CACHE
))
{
!
btrfs_test_opt
(
root
->
fs_info
,
SPACE_CACHE
))
{
/*
/*
* don't bother trying to write stuff out _if_
* don't bother trying to write stuff out _if_
* a) we're not cached,
* a) we're not cached,
...
@@ -3524,7 +3525,7 @@ int btrfs_setup_space_cache(struct btrfs_trans_handle *trans,
...
@@ -3524,7 +3525,7 @@ int btrfs_setup_space_cache(struct btrfs_trans_handle *trans,
struct
btrfs_path
*
path
;
struct
btrfs_path
*
path
;
if
(
list_empty
(
&
cur_trans
->
dirty_bgs
)
||
if
(
list_empty
(
&
cur_trans
->
dirty_bgs
)
||
!
btrfs_test_opt
(
root
,
SPACE_CACHE
))
!
btrfs_test_opt
(
root
->
fs_info
,
SPACE_CACHE
))
return
0
;
return
0
;
path
=
btrfs_alloc_path
();
path
=
btrfs_alloc_path
();
...
@@ -3669,7 +3670,7 @@ int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans,
...
@@ -3669,7 +3670,7 @@ int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans,
}
}
spin_unlock
(
&
cur_trans
->
dirty_bgs_lock
);
spin_unlock
(
&
cur_trans
->
dirty_bgs_lock
);
}
else
if
(
ret
)
{
}
else
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
}
}
}
}
...
@@ -3815,7 +3816,7 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
...
@@ -3815,7 +3816,7 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
cache
);
cache
);
}
}
if
(
ret
)
if
(
ret
)
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
}
}
/* if its not on the io list, we need to put the block group */
/* if its not on the io list, we need to put the block group */
...
@@ -4443,7 +4444,7 @@ void check_system_chunk(struct btrfs_trans_handle *trans,
...
@@ -4443,7 +4444,7 @@ void check_system_chunk(struct btrfs_trans_handle *trans,
thresh
=
btrfs_calc_trunc_metadata_size
(
root
,
num_devs
)
+
thresh
=
btrfs_calc_trunc_metadata_size
(
root
,
num_devs
)
+
btrfs_calc_trans_metadata_size
(
root
,
1
);
btrfs_calc_trans_metadata_size
(
root
,
1
);
if
(
left
<
thresh
&&
btrfs_test_opt
(
root
,
ENOSPC_DEBUG
))
{
if
(
left
<
thresh
&&
btrfs_test_opt
(
root
->
fs_info
,
ENOSPC_DEBUG
))
{
btrfs_info
(
root
->
fs_info
,
"left=%llu, need=%llu, flags=%llu"
,
btrfs_info
(
root
->
fs_info
,
"left=%llu, need=%llu, flags=%llu"
,
left
,
thresh
,
type
);
left
,
thresh
,
type
);
dump_space_info
(
info
,
0
,
0
);
dump_space_info
(
info
,
0
,
0
);
...
@@ -4588,7 +4589,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
...
@@ -4588,7 +4589,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
*/
*/
if
(
trans
->
can_flush_pending_bgs
&&
if
(
trans
->
can_flush_pending_bgs
&&
trans
->
chunk_bytes_reserved
>=
(
u64
)
SZ_2M
)
{
trans
->
chunk_bytes_reserved
>=
(
u64
)
SZ_2M
)
{
btrfs_create_pending_block_groups
(
trans
,
trans
->
root
);
btrfs_create_pending_block_groups
(
trans
,
extent_
root
);
btrfs_trans_release_chunk_metadata
(
trans
);
btrfs_trans_release_chunk_metadata
(
trans
);
}
}
return
ret
;
return
ret
;
...
@@ -5729,7 +5730,7 @@ void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
...
@@ -5729,7 +5730,7 @@ void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
*/
*/
void
btrfs_trans_release_chunk_metadata
(
struct
btrfs_trans_handle
*
trans
)
void
btrfs_trans_release_chunk_metadata
(
struct
btrfs_trans_handle
*
trans
)
{
{
struct
btrfs_fs_info
*
fs_info
=
trans
->
root
->
fs_info
;
struct
btrfs_fs_info
*
fs_info
=
trans
->
fs_info
;
if
(
!
trans
->
chunk_bytes_reserved
)
if
(
!
trans
->
chunk_bytes_reserved
)
return
;
return
;
...
@@ -6100,7 +6101,7 @@ void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes)
...
@@ -6100,7 +6101,7 @@ void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes)
if
(
dropped
>
0
)
if
(
dropped
>
0
)
to_free
+=
btrfs_calc_trans_metadata_size
(
root
,
dropped
);
to_free
+=
btrfs_calc_trans_metadata_size
(
root
,
dropped
);
if
(
btrfs_
test_is_dummy_root
(
root
))
if
(
btrfs_
is_testing
(
root
->
fs_info
))
return
;
return
;
trace_btrfs_space_reservation
(
root
->
fs_info
,
"delalloc"
,
trace_btrfs_space_reservation
(
root
->
fs_info
,
"delalloc"
,
...
@@ -6215,7 +6216,7 @@ static int update_block_group(struct btrfs_trans_handle *trans,
...
@@ -6215,7 +6216,7 @@ static int update_block_group(struct btrfs_trans_handle *trans,
spin_lock
(
&
cache
->
space_info
->
lock
);
spin_lock
(
&
cache
->
space_info
->
lock
);
spin_lock
(
&
cache
->
lock
);
spin_lock
(
&
cache
->
lock
);
if
(
btrfs_test_opt
(
root
,
SPACE_CACHE
)
&&
if
(
btrfs_test_opt
(
root
->
fs_info
,
SPACE_CACHE
)
&&
cache
->
disk_cache_state
<
BTRFS_DC_CLEAR
)
cache
->
disk_cache_state
<
BTRFS_DC_CLEAR
)
cache
->
disk_cache_state
=
BTRFS_DC_CLEAR
;
cache
->
disk_cache_state
=
BTRFS_DC_CLEAR
;
...
@@ -6597,7 +6598,7 @@ fetch_cluster_info(struct btrfs_root *root, struct btrfs_space_info *space_info,
...
@@ -6597,7 +6598,7 @@ fetch_cluster_info(struct btrfs_root *root, struct btrfs_space_info *space_info,
u64
*
empty_cluster
)
u64
*
empty_cluster
)
{
{
struct
btrfs_free_cluster
*
ret
=
NULL
;
struct
btrfs_free_cluster
*
ret
=
NULL
;
bool
ssd
=
btrfs_test_opt
(
root
,
SSD
);
bool
ssd
=
btrfs_test_opt
(
root
->
fs_info
,
SSD
);
*
empty_cluster
=
0
;
*
empty_cluster
=
0
;
if
(
btrfs_mixed_space_info
(
space_info
))
if
(
btrfs_mixed_space_info
(
space_info
))
...
@@ -6742,7 +6743,7 @@ int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
...
@@ -6742,7 +6743,7 @@ int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
break
;
break
;
}
}
if
(
btrfs_test_opt
(
root
,
DISCARD
))
if
(
btrfs_test_opt
(
root
->
fs_info
,
DISCARD
))
ret
=
btrfs_discard_extent
(
root
,
start
,
ret
=
btrfs_discard_extent
(
root
,
start
,
end
+
1
-
start
,
NULL
);
end
+
1
-
start
,
NULL
);
...
@@ -6880,7 +6881,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
...
@@ -6880,7 +6881,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
NULL
,
refs_to_drop
,
NULL
,
refs_to_drop
,
is_data
,
&
last_ref
);
is_data
,
&
last_ref
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
extent_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
btrfs_release_path
(
path
);
btrfs_release_path
(
path
);
...
@@ -6929,7 +6930,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
...
@@ -6929,7 +6930,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
path
->
nodes
[
0
]);
path
->
nodes
[
0
]);
}
}
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
btrfs_abort_transaction
(
trans
,
extent_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
extent_slot
=
path
->
slots
[
0
];
extent_slot
=
path
->
slots
[
0
];
...
@@ -6940,10 +6941,10 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
...
@@ -6940,10 +6941,10 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
"unable to find ref byte nr %llu parent %llu root %llu owner %llu offset %llu"
,
"unable to find ref byte nr %llu parent %llu root %llu owner %llu offset %llu"
,
bytenr
,
parent
,
root_objectid
,
owner_objectid
,
bytenr
,
parent
,
root_objectid
,
owner_objectid
,
owner_offset
);
owner_offset
);
btrfs_abort_transaction
(
trans
,
extent_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
else
{
}
else
{
btrfs_abort_transaction
(
trans
,
extent_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
...
@@ -6955,7 +6956,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
...
@@ -6955,7 +6956,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
ret
=
convert_extent_item_v0
(
trans
,
extent_root
,
path
,
ret
=
convert_extent_item_v0
(
trans
,
extent_root
,
path
,
owner_objectid
,
0
);
owner_objectid
,
0
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
btrfs_abort_transaction
(
trans
,
extent_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
...
@@ -6974,7 +6975,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
...
@@ -6974,7 +6975,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
btrfs_print_leaf
(
extent_root
,
path
->
nodes
[
0
]);
btrfs_print_leaf
(
extent_root
,
path
->
nodes
[
0
]);
}
}
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
btrfs_abort_transaction
(
trans
,
extent_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
...
@@ -6999,7 +7000,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
...
@@ -6999,7 +7000,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
btrfs_err
(
info
,
"trying to drop %d refs but we only have %Lu "
btrfs_err
(
info
,
"trying to drop %d refs but we only have %Lu "
"for bytenr %Lu"
,
refs_to_drop
,
refs
,
bytenr
);
"for bytenr %Lu"
,
refs_to_drop
,
refs
,
bytenr
);
ret
=
-
EINVAL
;
ret
=
-
EINVAL
;
btrfs_abort_transaction
(
trans
,
extent_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
refs
-=
refs_to_drop
;
refs
-=
refs_to_drop
;
...
@@ -7022,7 +7023,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
...
@@ -7022,7 +7023,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
iref
,
refs_to_drop
,
iref
,
refs_to_drop
,
is_data
,
&
last_ref
);
is_data
,
&
last_ref
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
extent_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
}
}
...
@@ -7045,7 +7046,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
...
@@ -7045,7 +7046,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
ret
=
btrfs_del_items
(
trans
,
extent_root
,
path
,
path
->
slots
[
0
],
ret
=
btrfs_del_items
(
trans
,
extent_root
,
path
,
path
->
slots
[
0
],
num_to_del
);
num_to_del
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
extent_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
btrfs_release_path
(
path
);
btrfs_release_path
(
path
);
...
@@ -7053,7 +7054,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
...
@@ -7053,7 +7054,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
if
(
is_data
)
{
if
(
is_data
)
{
ret
=
btrfs_del_csums
(
trans
,
root
,
bytenr
,
num_bytes
);
ret
=
btrfs_del_csums
(
trans
,
root
,
bytenr
,
num_bytes
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
extent_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
}
}
...
@@ -7061,13 +7062,13 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
...
@@ -7061,13 +7062,13 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
ret
=
add_to_free_space_tree
(
trans
,
root
->
fs_info
,
bytenr
,
ret
=
add_to_free_space_tree
(
trans
,
root
->
fs_info
,
bytenr
,
num_bytes
);
num_bytes
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
extent_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
ret
=
update_block_group
(
trans
,
root
,
bytenr
,
num_bytes
,
0
);
ret
=
update_block_group
(
trans
,
root
,
bytenr
,
num_bytes
,
0
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
extent_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
}
}
...
@@ -7216,7 +7217,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root,
...
@@ -7216,7 +7217,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root,
int
ret
;
int
ret
;
struct
btrfs_fs_info
*
fs_info
=
root
->
fs_info
;
struct
btrfs_fs_info
*
fs_info
=
root
->
fs_info
;
if
(
btrfs_
test_is_dummy_root
(
root
))
if
(
btrfs_
is_testing
(
fs_info
))
return
0
;
return
0
;
add_pinned_bytes
(
root
->
fs_info
,
num_bytes
,
owner
,
root_objectid
);
add_pinned_bytes
(
root
->
fs_info
,
num_bytes
,
owner
,
root_objectid
);
...
@@ -7851,8 +7852,7 @@ static noinline int find_free_extent(struct btrfs_root *orig_root,
...
@@ -7851,8 +7852,7 @@ static noinline int find_free_extent(struct btrfs_root *orig_root,
* can do more things.
* can do more things.
*/
*/
if
(
ret
<
0
&&
ret
!=
-
ENOSPC
)
if
(
ret
<
0
&&
ret
!=
-
ENOSPC
)
btrfs_abort_transaction
(
trans
,
btrfs_abort_transaction
(
trans
,
ret
);
root
,
ret
);
else
else
ret
=
0
;
ret
=
0
;
if
(
!
exist
)
if
(
!
exist
)
...
@@ -7906,8 +7906,8 @@ static void dump_space_info(struct btrfs_space_info *info, u64 bytes,
...
@@ -7906,8 +7906,8 @@ static void dump_space_info(struct btrfs_space_info *info, u64 bytes,
printk
(
KERN_INFO
"BTRFS: space_info %llu has %llu free, is %sfull
\n
"
,
printk
(
KERN_INFO
"BTRFS: space_info %llu has %llu free, is %sfull
\n
"
,
info
->
flags
,
info
->
flags
,
info
->
total_bytes
-
info
->
bytes_used
-
info
->
bytes_pinned
-
info
->
total_bytes
-
info
->
bytes_used
-
info
->
bytes_pinned
-
info
->
bytes_reserved
-
info
->
bytes_readonly
,
info
->
bytes_reserved
-
info
->
bytes_readonly
-
(
info
->
full
)
?
""
:
"not "
);
info
->
bytes_may_use
,
(
info
->
full
)
?
""
:
"not "
);
printk
(
KERN_INFO
"BTRFS: space_info total=%llu, used=%llu, pinned=%llu, "
printk
(
KERN_INFO
"BTRFS: space_info total=%llu, used=%llu, pinned=%llu, "
"reserved=%llu, may_use=%llu, readonly=%llu
\n
"
,
"reserved=%llu, may_use=%llu, readonly=%llu
\n
"
,
info
->
total_bytes
,
info
->
bytes_used
,
info
->
bytes_pinned
,
info
->
total_bytes
,
info
->
bytes_used
,
info
->
bytes_pinned
,
...
@@ -7961,7 +7961,7 @@ int btrfs_reserve_extent(struct btrfs_root *root,
...
@@ -7961,7 +7961,7 @@ int btrfs_reserve_extent(struct btrfs_root *root,
if
(
num_bytes
==
min_alloc_size
)
if
(
num_bytes
==
min_alloc_size
)
final_tried
=
true
;
final_tried
=
true
;
goto
again
;
goto
again
;
}
else
if
(
btrfs_test_opt
(
root
,
ENOSPC_DEBUG
))
{
}
else
if
(
btrfs_test_opt
(
root
->
fs_info
,
ENOSPC_DEBUG
))
{
struct
btrfs_space_info
*
sinfo
;
struct
btrfs_space_info
*
sinfo
;
sinfo
=
__find_space_info
(
root
->
fs_info
,
flags
);
sinfo
=
__find_space_info
(
root
->
fs_info
,
flags
);
...
@@ -7992,7 +7992,7 @@ static int __btrfs_free_reserved_extent(struct btrfs_root *root,
...
@@ -7992,7 +7992,7 @@ static int __btrfs_free_reserved_extent(struct btrfs_root *root,
if
(
pin
)
if
(
pin
)
pin_down_extent
(
root
,
cache
,
start
,
len
,
1
);
pin_down_extent
(
root
,
cache
,
start
,
len
,
1
);
else
{
else
{
if
(
btrfs_test_opt
(
root
,
DISCARD
))
if
(
btrfs_test_opt
(
root
->
fs_info
,
DISCARD
))
ret
=
btrfs_discard_extent
(
root
,
start
,
len
,
NULL
);
ret
=
btrfs_discard_extent
(
root
,
start
,
len
,
NULL
);
btrfs_add_free_space
(
cache
,
start
,
len
);
btrfs_add_free_space
(
cache
,
start
,
len
);
btrfs_update_reserved_bytes
(
cache
,
len
,
RESERVE_FREE
,
delalloc
);
btrfs_update_reserved_bytes
(
cache
,
len
,
RESERVE_FREE
,
delalloc
);
...
@@ -8300,7 +8300,7 @@ use_block_rsv(struct btrfs_trans_handle *trans,
...
@@ -8300,7 +8300,7 @@ use_block_rsv(struct btrfs_trans_handle *trans,
goto
again
;
goto
again
;
}
}
if
(
btrfs_test_opt
(
root
,
ENOSPC_DEBUG
))
{
if
(
btrfs_test_opt
(
root
->
fs_info
,
ENOSPC_DEBUG
))
{
static
DEFINE_RATELIMIT_STATE
(
_rs
,
static
DEFINE_RATELIMIT_STATE
(
_rs
,
DEFAULT_RATELIMIT_INTERVAL
*
10
,
DEFAULT_RATELIMIT_INTERVAL
*
10
,
/*DEFAULT_RATELIMIT_BURST*/
1
);
/*DEFAULT_RATELIMIT_BURST*/
1
);
...
@@ -8354,13 +8354,15 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
...
@@ -8354,13 +8354,15 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
bool
skinny_metadata
=
btrfs_fs_incompat
(
root
->
fs_info
,
bool
skinny_metadata
=
btrfs_fs_incompat
(
root
->
fs_info
,
SKINNY_METADATA
);
SKINNY_METADATA
);
if
(
btrfs_test_is_dummy_root
(
root
))
{
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
if
(
btrfs_is_testing
(
root
->
fs_info
))
{
buf
=
btrfs_init_new_buffer
(
trans
,
root
,
root
->
alloc_bytenr
,
buf
=
btrfs_init_new_buffer
(
trans
,
root
,
root
->
alloc_bytenr
,
level
);
level
);
if
(
!
IS_ERR
(
buf
))
if
(
!
IS_ERR
(
buf
))
root
->
alloc_bytenr
+=
blocksize
;
root
->
alloc_bytenr
+=
blocksize
;
return
buf
;
return
buf
;
}
}
#endif
block_rsv
=
use_block_rsv
(
trans
,
root
,
blocksize
);
block_rsv
=
use_block_rsv
(
trans
,
root
,
blocksize
);
if
(
IS_ERR
(
block_rsv
))
if
(
IS_ERR
(
block_rsv
))
...
@@ -8540,7 +8542,8 @@ static int record_one_subtree_extent(struct btrfs_trans_handle *trans,
...
@@ -8540,7 +8542,8 @@ static int record_one_subtree_extent(struct btrfs_trans_handle *trans,
delayed_refs
=
&
trans
->
transaction
->
delayed_refs
;
delayed_refs
=
&
trans
->
transaction
->
delayed_refs
;
spin_lock
(
&
delayed_refs
->
lock
);
spin_lock
(
&
delayed_refs
->
lock
);
if
(
btrfs_qgroup_insert_dirty_extent
(
delayed_refs
,
qrecord
))
if
(
btrfs_qgroup_insert_dirty_extent
(
trans
->
fs_info
,
delayed_refs
,
qrecord
))
kfree
(
qrecord
);
kfree
(
qrecord
);
spin_unlock
(
&
delayed_refs
->
lock
);
spin_unlock
(
&
delayed_refs
->
lock
);
...
@@ -9325,7 +9328,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
...
@@ -9325,7 +9328,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
&
root
->
root_key
,
&
root
->
root_key
,
root_item
);
root_item
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
tree_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
err
=
ret
;
err
=
ret
;
goto
out_end_trans
;
goto
out_end_trans
;
}
}
...
@@ -9352,7 +9355,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
...
@@ -9352,7 +9355,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
ret
=
btrfs_del_root
(
trans
,
tree_root
,
&
root
->
root_key
);
ret
=
btrfs_del_root
(
trans
,
tree_root
,
&
root
->
root_key
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
tree_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out_end_trans
;
goto
out_end_trans
;
}
}
...
@@ -9360,7 +9363,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
...
@@ -9360,7 +9363,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
ret
=
btrfs_find_root
(
tree_root
,
&
root
->
root_key
,
path
,
ret
=
btrfs_find_root
(
tree_root
,
&
root
->
root_key
,
path
,
NULL
,
NULL
);
NULL
,
NULL
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
btrfs_abort_transaction
(
trans
,
tree_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
err
=
ret
;
err
=
ret
;
goto
out_end_trans
;
goto
out_end_trans
;
}
else
if
(
ret
>
0
)
{
}
else
if
(
ret
>
0
)
{
...
@@ -9731,7 +9734,7 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
...
@@ -9731,7 +9734,7 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
int
full
=
0
;
int
full
=
0
;
int
ret
=
0
;
int
ret
=
0
;
debug
=
btrfs_test_opt
(
root
,
ENOSPC_DEBUG
);
debug
=
btrfs_test_opt
(
root
->
fs_info
,
ENOSPC_DEBUG
);
block_group
=
btrfs_lookup_block_group
(
root
->
fs_info
,
bytenr
);
block_group
=
btrfs_lookup_block_group
(
root
->
fs_info
,
bytenr
);
...
@@ -9887,7 +9890,22 @@ static int find_first_block_group(struct btrfs_root *root,
...
@@ -9887,7 +9890,22 @@ static int find_first_block_group(struct btrfs_root *root,
if
(
found_key
.
objectid
>=
key
->
objectid
&&
if
(
found_key
.
objectid
>=
key
->
objectid
&&
found_key
.
type
==
BTRFS_BLOCK_GROUP_ITEM_KEY
)
{
found_key
.
type
==
BTRFS_BLOCK_GROUP_ITEM_KEY
)
{
ret
=
0
;
struct
extent_map_tree
*
em_tree
;
struct
extent_map
*
em
;
em_tree
=
&
root
->
fs_info
->
mapping_tree
.
map_tree
;
read_lock
(
&
em_tree
->
lock
);
em
=
lookup_extent_mapping
(
em_tree
,
found_key
.
objectid
,
found_key
.
offset
);
read_unlock
(
&
em_tree
->
lock
);
if
(
!
em
)
{
btrfs_err
(
root
->
fs_info
,
"logical %llu len %llu found bg but no related chunk"
,
found_key
.
objectid
,
found_key
.
offset
);
ret
=
-
ENOENT
;
}
else
{
ret
=
0
;
}
goto
out
;
goto
out
;
}
}
path
->
slots
[
0
]
++
;
path
->
slots
[
0
]
++
;
...
@@ -10129,10 +10147,10 @@ int btrfs_read_block_groups(struct btrfs_root *root)
...
@@ -10129,10 +10147,10 @@ int btrfs_read_block_groups(struct btrfs_root *root)
path
->
reada
=
READA_FORWARD
;
path
->
reada
=
READA_FORWARD
;
cache_gen
=
btrfs_super_cache_generation
(
root
->
fs_info
->
super_copy
);
cache_gen
=
btrfs_super_cache_generation
(
root
->
fs_info
->
super_copy
);
if
(
btrfs_test_opt
(
root
,
SPACE_CACHE
)
&&
if
(
btrfs_test_opt
(
root
->
fs_info
,
SPACE_CACHE
)
&&
btrfs_super_generation
(
root
->
fs_info
->
super_copy
)
!=
cache_gen
)
btrfs_super_generation
(
root
->
fs_info
->
super_copy
)
!=
cache_gen
)
need_clear
=
1
;
need_clear
=
1
;
if
(
btrfs_test_opt
(
root
,
CLEAR_CACHE
))
if
(
btrfs_test_opt
(
root
->
fs_info
,
CLEAR_CACHE
))
need_clear
=
1
;
need_clear
=
1
;
while
(
1
)
{
while
(
1
)
{
...
@@ -10163,7 +10181,7 @@ int btrfs_read_block_groups(struct btrfs_root *root)
...
@@ -10163,7 +10181,7 @@ int btrfs_read_block_groups(struct btrfs_root *root)
* b) Setting 'dirty flag' makes sure that we flush
* b) Setting 'dirty flag' makes sure that we flush
* the new space cache info onto disk.
* the new space cache info onto disk.
*/
*/
if
(
btrfs_test_opt
(
root
,
SPACE_CACHE
))
if
(
btrfs_test_opt
(
root
->
fs_info
,
SPACE_CACHE
))
cache
->
disk_cache_state
=
BTRFS_DC_CLEAR
;
cache
->
disk_cache_state
=
BTRFS_DC_CLEAR
;
}
}
...
@@ -10305,11 +10323,11 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans,
...
@@ -10305,11 +10323,11 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans,
ret
=
btrfs_insert_item
(
trans
,
extent_root
,
&
key
,
&
item
,
ret
=
btrfs_insert_item
(
trans
,
extent_root
,
&
key
,
&
item
,
sizeof
(
item
));
sizeof
(
item
));
if
(
ret
)
if
(
ret
)
btrfs_abort_transaction
(
trans
,
extent_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
ret
=
btrfs_finish_chunk_alloc
(
trans
,
extent_root
,
ret
=
btrfs_finish_chunk_alloc
(
trans
,
extent_root
,
key
.
objectid
,
key
.
offset
);
key
.
objectid
,
key
.
offset
);
if
(
ret
)
if
(
ret
)
btrfs_abort_transaction
(
trans
,
extent_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
add_block_group_free_space
(
trans
,
root
->
fs_info
,
block_group
);
add_block_group_free_space
(
trans
,
root
->
fs_info
,
block_group
);
/* already aborted the transaction if it failed. */
/* already aborted the transaction if it failed. */
next:
next:
...
@@ -10622,7 +10640,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
...
@@ -10622,7 +10640,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
spin_lock
(
&
block_group
->
space_info
->
lock
);
spin_lock
(
&
block_group
->
space_info
->
lock
);
list_del_init
(
&
block_group
->
ro_list
);
list_del_init
(
&
block_group
->
ro_list
);
if
(
btrfs_test_opt
(
root
,
ENOSPC_DEBUG
))
{
if
(
btrfs_test_opt
(
root
->
fs_info
,
ENOSPC_DEBUG
))
{
WARN_ON
(
block_group
->
space_info
->
total_bytes
WARN_ON
(
block_group
->
space_info
->
total_bytes
<
block_group
->
key
.
offset
);
<
block_group
->
key
.
offset
);
WARN_ON
(
block_group
->
space_info
->
bytes_readonly
WARN_ON
(
block_group
->
space_info
->
bytes_readonly
...
@@ -10890,7 +10908,7 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
...
@@ -10890,7 +10908,7 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
spin_unlock
(
&
space_info
->
lock
);
spin_unlock
(
&
space_info
->
lock
);
/* DISCARD can flip during remount */
/* DISCARD can flip during remount */
trimming
=
btrfs_test_opt
(
root
,
DISCARD
);
trimming
=
btrfs_test_opt
(
root
->
fs_info
,
DISCARD
);
/* Implicit trim during transaction commit. */
/* Implicit trim during transaction commit. */
if
(
trimming
)
if
(
trimming
)
...
...
fs/btrfs/extent_io.c
浏览文件 @
023a824f
...
@@ -163,13 +163,13 @@ int __init extent_io_init(void)
...
@@ -163,13 +163,13 @@ int __init extent_io_init(void)
{
{
extent_state_cache
=
kmem_cache_create
(
"btrfs_extent_state"
,
extent_state_cache
=
kmem_cache_create
(
"btrfs_extent_state"
,
sizeof
(
struct
extent_state
),
0
,
sizeof
(
struct
extent_state
),
0
,
SLAB_
RECLAIM_ACCOUNT
|
SLAB_
MEM_SPREAD
,
NULL
);
SLAB_MEM_SPREAD
,
NULL
);
if
(
!
extent_state_cache
)
if
(
!
extent_state_cache
)
return
-
ENOMEM
;
return
-
ENOMEM
;
extent_buffer_cache
=
kmem_cache_create
(
"btrfs_extent_buffer"
,
extent_buffer_cache
=
kmem_cache_create
(
"btrfs_extent_buffer"
,
sizeof
(
struct
extent_buffer
),
0
,
sizeof
(
struct
extent_buffer
),
0
,
SLAB_
RECLAIM_ACCOUNT
|
SLAB_
MEM_SPREAD
,
NULL
);
SLAB_MEM_SPREAD
,
NULL
);
if
(
!
extent_buffer_cache
)
if
(
!
extent_buffer_cache
)
goto
free_state_cache
;
goto
free_state_cache
;
...
@@ -2756,7 +2756,6 @@ static int merge_bio(int rw, struct extent_io_tree *tree, struct page *page,
...
@@ -2756,7 +2756,6 @@ static int merge_bio(int rw, struct extent_io_tree *tree, struct page *page,
if
(
tree
->
ops
&&
tree
->
ops
->
merge_bio_hook
)
if
(
tree
->
ops
&&
tree
->
ops
->
merge_bio_hook
)
ret
=
tree
->
ops
->
merge_bio_hook
(
rw
,
page
,
offset
,
size
,
bio
,
ret
=
tree
->
ops
->
merge_bio_hook
(
rw
,
page
,
offset
,
size
,
bio
,
bio_flags
);
bio_flags
);
BUG_ON
(
ret
<
0
);
return
ret
;
return
ret
;
}
}
...
@@ -2879,6 +2878,7 @@ __get_extent_map(struct inode *inode, struct page *page, size_t pg_offset,
...
@@ -2879,6 +2878,7 @@ __get_extent_map(struct inode *inode, struct page *page, size_t pg_offset,
* into the tree that are removed when the IO is done (by the end_io
* into the tree that are removed when the IO is done (by the end_io
* handlers)
* handlers)
* XXX JDM: This needs looking at to ensure proper page locking
* XXX JDM: This needs looking at to ensure proper page locking
* return 0 on success, otherwise return error
*/
*/
static
int
__do_readpage
(
struct
extent_io_tree
*
tree
,
static
int
__do_readpage
(
struct
extent_io_tree
*
tree
,
struct
page
*
page
,
struct
page
*
page
,
...
@@ -2900,7 +2900,7 @@ static int __do_readpage(struct extent_io_tree *tree,
...
@@ -2900,7 +2900,7 @@ static int __do_readpage(struct extent_io_tree *tree,
sector_t
sector
;
sector_t
sector
;
struct
extent_map
*
em
;
struct
extent_map
*
em
;
struct
block_device
*
bdev
;
struct
block_device
*
bdev
;
int
ret
;
int
ret
=
0
;
int
nr
=
0
;
int
nr
=
0
;
size_t
pg_offset
=
0
;
size_t
pg_offset
=
0
;
size_t
iosize
;
size_t
iosize
;
...
@@ -3081,6 +3081,7 @@ static int __do_readpage(struct extent_io_tree *tree,
...
@@ -3081,6 +3081,7 @@ static int __do_readpage(struct extent_io_tree *tree,
}
else
{
}
else
{
SetPageError
(
page
);
SetPageError
(
page
);
unlock_extent
(
tree
,
cur
,
cur
+
iosize
-
1
);
unlock_extent
(
tree
,
cur
,
cur
+
iosize
-
1
);
goto
out
;
}
}
cur
=
cur
+
iosize
;
cur
=
cur
+
iosize
;
pg_offset
+=
iosize
;
pg_offset
+=
iosize
;
...
@@ -3091,7 +3092,7 @@ static int __do_readpage(struct extent_io_tree *tree,
...
@@ -3091,7 +3092,7 @@ static int __do_readpage(struct extent_io_tree *tree,
SetPageUptodate
(
page
);
SetPageUptodate
(
page
);
unlock_page
(
page
);
unlock_page
(
page
);
}
}
return
0
;
return
ret
;
}
}
static
inline
void
__do_contiguous_readpages
(
struct
extent_io_tree
*
tree
,
static
inline
void
__do_contiguous_readpages
(
struct
extent_io_tree
*
tree
,
...
@@ -5231,14 +5232,31 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
...
@@ -5231,14 +5232,31 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
atomic_set
(
&
eb
->
io_pages
,
num_reads
);
atomic_set
(
&
eb
->
io_pages
,
num_reads
);
for
(
i
=
start_i
;
i
<
num_pages
;
i
++
)
{
for
(
i
=
start_i
;
i
<
num_pages
;
i
++
)
{
page
=
eb
->
pages
[
i
];
page
=
eb
->
pages
[
i
];
if
(
!
PageUptodate
(
page
))
{
if
(
!
PageUptodate
(
page
))
{
if
(
ret
)
{
atomic_dec
(
&
eb
->
io_pages
);
unlock_page
(
page
);
continue
;
}
ClearPageError
(
page
);
ClearPageError
(
page
);
err
=
__extent_read_full_page
(
tree
,
page
,
err
=
__extent_read_full_page
(
tree
,
page
,
get_extent
,
&
bio
,
get_extent
,
&
bio
,
mirror_num
,
&
bio_flags
,
mirror_num
,
&
bio_flags
,
READ
|
REQ_META
);
READ
|
REQ_META
);
if
(
err
)
if
(
err
)
{
ret
=
err
;
ret
=
err
;
/*
* We use &bio in above __extent_read_full_page,
* so we ensure that if it returns error, the
* current page fails to add itself to bio and
* it's been unlocked.
*
* We must dec io_pages by ourselves.
*/
atomic_dec
(
&
eb
->
io_pages
);
}
}
else
{
}
else
{
unlock_page
(
page
);
unlock_page
(
page
);
}
}
...
...
fs/btrfs/extent_map.c
浏览文件 @
023a824f
...
@@ -13,7 +13,7 @@ int __init extent_map_init(void)
...
@@ -13,7 +13,7 @@ int __init extent_map_init(void)
{
{
extent_map_cache
=
kmem_cache_create
(
"btrfs_extent_map"
,
extent_map_cache
=
kmem_cache_create
(
"btrfs_extent_map"
,
sizeof
(
struct
extent_map
),
0
,
sizeof
(
struct
extent_map
),
0
,
SLAB_
RECLAIM_ACCOUNT
|
SLAB_
MEM_SPREAD
,
NULL
);
SLAB_MEM_SPREAD
,
NULL
);
if
(
!
extent_map_cache
)
if
(
!
extent_map_cache
)
return
-
ENOMEM
;
return
-
ENOMEM
;
return
0
;
return
0
;
...
...
fs/btrfs/file-item.c
浏览文件 @
023a824f
...
@@ -27,9 +27,8 @@
...
@@ -27,9 +27,8 @@
#include "print-tree.h"
#include "print-tree.h"
#include "compression.h"
#include "compression.h"
#define __MAX_CSUM_ITEMS(r, size) ((unsigned long)(((BTRFS_LEAF_DATA_SIZE(r) - \
#define __MAX_CSUM_ITEMS(r, size) \
sizeof(struct btrfs_item) * 2) / \
((unsigned long)(((BTRFS_MAX_ITEM_SIZE(r) * 2) / size) - 1))
size) - 1))
#define MAX_CSUM_ITEMS(r, size) (min_t(u32, __MAX_CSUM_ITEMS(r, size), \
#define MAX_CSUM_ITEMS(r, size) (min_t(u32, __MAX_CSUM_ITEMS(r, size), \
PAGE_SIZE))
PAGE_SIZE))
...
@@ -250,7 +249,7 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root,
...
@@ -250,7 +249,7 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root,
offset
+
root
->
sectorsize
-
1
,
offset
+
root
->
sectorsize
-
1
,
EXTENT_NODATASUM
);
EXTENT_NODATASUM
);
}
else
{
}
else
{
btrfs_info
(
BTRFS_I
(
inode
)
->
root
->
fs_info
,
btrfs_info
_rl
(
BTRFS_I
(
inode
)
->
root
->
fs_info
,
"no csum found for inode %llu start %llu"
,
"no csum found for inode %llu start %llu"
,
btrfs_ino
(
inode
),
offset
);
btrfs_ino
(
inode
),
offset
);
}
}
...
@@ -699,7 +698,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
...
@@ -699,7 +698,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
*/
*/
ret
=
btrfs_split_item
(
trans
,
root
,
path
,
&
key
,
offset
);
ret
=
btrfs_split_item
(
trans
,
root
,
path
,
&
key
,
offset
);
if
(
ret
&&
ret
!=
-
EAGAIN
)
{
if
(
ret
&&
ret
!=
-
EAGAIN
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
...
...
fs/btrfs/file.c
浏览文件 @
023a824f
...
@@ -132,7 +132,7 @@ static int __btrfs_add_inode_defrag(struct inode *inode,
...
@@ -132,7 +132,7 @@ static int __btrfs_add_inode_defrag(struct inode *inode,
static
inline
int
__need_auto_defrag
(
struct
btrfs_root
*
root
)
static
inline
int
__need_auto_defrag
(
struct
btrfs_root
*
root
)
{
{
if
(
!
btrfs_test_opt
(
root
,
AUTO_DEFRAG
))
if
(
!
btrfs_test_opt
(
root
->
fs_info
,
AUTO_DEFRAG
))
return
0
;
return
0
;
if
(
btrfs_fs_closing
(
root
->
fs_info
))
if
(
btrfs_fs_closing
(
root
->
fs_info
))
...
@@ -950,7 +950,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
...
@@ -950,7 +950,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
ret
=
btrfs_del_items
(
trans
,
root
,
path
,
del_slot
,
ret
=
btrfs_del_items
(
trans
,
root
,
path
,
del_slot
,
del_nr
);
del_nr
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
break
;
break
;
}
}
...
@@ -974,7 +974,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
...
@@ -974,7 +974,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
path
->
slots
[
0
]
=
del_slot
;
path
->
slots
[
0
]
=
del_slot
;
ret
=
btrfs_del_items
(
trans
,
root
,
path
,
del_slot
,
del_nr
);
ret
=
btrfs_del_items
(
trans
,
root
,
path
,
del_slot
,
del_nr
);
if
(
ret
)
if
(
ret
)
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
}
}
leaf
=
path
->
nodes
[
0
];
leaf
=
path
->
nodes
[
0
];
...
@@ -1190,7 +1190,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
...
@@ -1190,7 +1190,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
goto
again
;
goto
again
;
}
}
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
...
@@ -1278,7 +1278,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
...
@@ -1278,7 +1278,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
ret
=
btrfs_del_items
(
trans
,
root
,
path
,
del_slot
,
del_nr
);
ret
=
btrfs_del_items
(
trans
,
root
,
path
,
del_slot
,
del_nr
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
}
}
...
@@ -2975,7 +2975,7 @@ int btrfs_auto_defrag_init(void)
...
@@ -2975,7 +2975,7 @@ int btrfs_auto_defrag_init(void)
{
{
btrfs_inode_defrag_cachep
=
kmem_cache_create
(
"btrfs_inode_defrag"
,
btrfs_inode_defrag_cachep
=
kmem_cache_create
(
"btrfs_inode_defrag"
,
sizeof
(
struct
inode_defrag
),
0
,
sizeof
(
struct
inode_defrag
),
0
,
SLAB_
RECLAIM_ACCOUNT
|
SLAB_
MEM_SPREAD
,
SLAB_MEM_SPREAD
,
NULL
);
NULL
);
if
(
!
btrfs_inode_defrag_cachep
)
if
(
!
btrfs_inode_defrag_cachep
)
return
-
ENOMEM
;
return
-
ENOMEM
;
...
...
fs/btrfs/free-space-cache.c
浏览文件 @
023a824f
...
@@ -280,7 +280,7 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root,
...
@@ -280,7 +280,7 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root,
if
(
locked
)
if
(
locked
)
mutex_unlock
(
&
trans
->
transaction
->
cache_write_mutex
);
mutex_unlock
(
&
trans
->
transaction
->
cache_write_mutex
);
if
(
ret
)
if
(
ret
)
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
return
ret
;
return
ret
;
}
}
...
@@ -3026,7 +3026,7 @@ int btrfs_find_space_cluster(struct btrfs_root *root,
...
@@ -3026,7 +3026,7 @@ int btrfs_find_space_cluster(struct btrfs_root *root,
* For metadata, allow allocates with smaller extents. For
* For metadata, allow allocates with smaller extents. For
* data, keep it dense.
* data, keep it dense.
*/
*/
if
(
btrfs_test_opt
(
root
,
SSD_SPREAD
))
{
if
(
btrfs_test_opt
(
root
->
fs_info
,
SSD_SPREAD
))
{
cont1_bytes
=
min_bytes
=
bytes
+
empty_size
;
cont1_bytes
=
min_bytes
=
bytes
+
empty_size
;
}
else
if
(
block_group
->
flags
&
BTRFS_BLOCK_GROUP_METADATA
)
{
}
else
if
(
block_group
->
flags
&
BTRFS_BLOCK_GROUP_METADATA
)
{
cont1_bytes
=
bytes
;
cont1_bytes
=
bytes
;
...
@@ -3470,7 +3470,7 @@ int load_free_ino_cache(struct btrfs_fs_info *fs_info, struct btrfs_root *root)
...
@@ -3470,7 +3470,7 @@ int load_free_ino_cache(struct btrfs_fs_info *fs_info, struct btrfs_root *root)
int
ret
=
0
;
int
ret
=
0
;
u64
root_gen
=
btrfs_root_generation
(
&
root
->
root_item
);
u64
root_gen
=
btrfs_root_generation
(
&
root
->
root_item
);
if
(
!
btrfs_test_opt
(
root
,
INODE_MAP_CACHE
))
if
(
!
btrfs_test_opt
(
root
->
fs_info
,
INODE_MAP_CACHE
))
return
0
;
return
0
;
/*
/*
...
@@ -3514,7 +3514,7 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root,
...
@@ -3514,7 +3514,7 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root,
struct
btrfs_io_ctl
io_ctl
;
struct
btrfs_io_ctl
io_ctl
;
bool
release_metadata
=
true
;
bool
release_metadata
=
true
;
if
(
!
btrfs_test_opt
(
root
,
INODE_MAP_CACHE
))
if
(
!
btrfs_test_opt
(
root
->
fs_info
,
INODE_MAP_CACHE
))
return
0
;
return
0
;
memset
(
&
io_ctl
,
0
,
sizeof
(
io_ctl
));
memset
(
&
io_ctl
,
0
,
sizeof
(
io_ctl
));
...
...
fs/btrfs/free-space-tree.c
浏览文件 @
023a824f
...
@@ -305,7 +305,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
...
@@ -305,7 +305,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
out:
out:
kvfree
(
bitmap
);
kvfree
(
bitmap
);
if
(
ret
)
if
(
ret
)
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
return
ret
;
return
ret
;
}
}
...
@@ -454,7 +454,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
...
@@ -454,7 +454,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
out:
out:
kvfree
(
bitmap
);
kvfree
(
bitmap
);
if
(
ret
)
if
(
ret
)
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
return
ret
;
return
ret
;
}
}
...
@@ -851,7 +851,7 @@ int remove_from_free_space_tree(struct btrfs_trans_handle *trans,
...
@@ -851,7 +851,7 @@ int remove_from_free_space_tree(struct btrfs_trans_handle *trans,
out:
out:
btrfs_free_path
(
path
);
btrfs_free_path
(
path
);
if
(
ret
)
if
(
ret
)
btrfs_abort_transaction
(
trans
,
fs_info
->
free_space_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
return
ret
;
return
ret
;
}
}
...
@@ -1047,7 +1047,7 @@ int add_to_free_space_tree(struct btrfs_trans_handle *trans,
...
@@ -1047,7 +1047,7 @@ int add_to_free_space_tree(struct btrfs_trans_handle *trans,
out:
out:
btrfs_free_path
(
path
);
btrfs_free_path
(
path
);
if
(
ret
)
if
(
ret
)
btrfs_abort_transaction
(
trans
,
fs_info
->
free_space_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
return
ret
;
return
ret
;
}
}
...
@@ -1193,7 +1193,7 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info)
...
@@ -1193,7 +1193,7 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info)
abort:
abort:
fs_info
->
creating_free_space_tree
=
0
;
fs_info
->
creating_free_space_tree
=
0
;
btrfs_abort_transaction
(
trans
,
tree_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
btrfs_end_transaction
(
trans
,
tree_root
);
btrfs_end_transaction
(
trans
,
tree_root
);
return
ret
;
return
ret
;
}
}
...
@@ -1280,7 +1280,7 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info)
...
@@ -1280,7 +1280,7 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info)
return
0
;
return
0
;
abort:
abort:
btrfs_abort_transaction
(
trans
,
tree_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
btrfs_end_transaction
(
trans
,
tree_root
);
btrfs_end_transaction
(
trans
,
tree_root
);
return
ret
;
return
ret
;
}
}
...
@@ -1333,7 +1333,7 @@ int add_block_group_free_space(struct btrfs_trans_handle *trans,
...
@@ -1333,7 +1333,7 @@ int add_block_group_free_space(struct btrfs_trans_handle *trans,
btrfs_free_path
(
path
);
btrfs_free_path
(
path
);
mutex_unlock
(
&
block_group
->
free_space_lock
);
mutex_unlock
(
&
block_group
->
free_space_lock
);
if
(
ret
)
if
(
ret
)
btrfs_abort_transaction
(
trans
,
fs_info
->
free_space_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
return
ret
;
return
ret
;
}
}
...
@@ -1410,7 +1410,7 @@ int remove_block_group_free_space(struct btrfs_trans_handle *trans,
...
@@ -1410,7 +1410,7 @@ int remove_block_group_free_space(struct btrfs_trans_handle *trans,
out:
out:
btrfs_free_path
(
path
);
btrfs_free_path
(
path
);
if
(
ret
)
if
(
ret
)
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
return
ret
;
return
ret
;
}
}
...
...
fs/btrfs/inode-map.c
浏览文件 @
023a824f
...
@@ -38,7 +38,7 @@ static int caching_kthread(void *data)
...
@@ -38,7 +38,7 @@ static int caching_kthread(void *data)
int
slot
;
int
slot
;
int
ret
;
int
ret
;
if
(
!
btrfs_test_opt
(
root
,
INODE_MAP_CACHE
))
if
(
!
btrfs_test_opt
(
root
->
fs_info
,
INODE_MAP_CACHE
))
return
0
;
return
0
;
path
=
btrfs_alloc_path
();
path
=
btrfs_alloc_path
();
...
@@ -141,7 +141,7 @@ static void start_caching(struct btrfs_root *root)
...
@@ -141,7 +141,7 @@ static void start_caching(struct btrfs_root *root)
int
ret
;
int
ret
;
u64
objectid
;
u64
objectid
;
if
(
!
btrfs_test_opt
(
root
,
INODE_MAP_CACHE
))
if
(
!
btrfs_test_opt
(
root
->
fs_info
,
INODE_MAP_CACHE
))
return
;
return
;
spin_lock
(
&
root
->
ino_cache_lock
);
spin_lock
(
&
root
->
ino_cache_lock
);
...
@@ -185,7 +185,7 @@ static void start_caching(struct btrfs_root *root)
...
@@ -185,7 +185,7 @@ static void start_caching(struct btrfs_root *root)
int
btrfs_find_free_ino
(
struct
btrfs_root
*
root
,
u64
*
objectid
)
int
btrfs_find_free_ino
(
struct
btrfs_root
*
root
,
u64
*
objectid
)
{
{
if
(
!
btrfs_test_opt
(
root
,
INODE_MAP_CACHE
))
if
(
!
btrfs_test_opt
(
root
->
fs_info
,
INODE_MAP_CACHE
))
return
btrfs_find_free_objectid
(
root
,
objectid
);
return
btrfs_find_free_objectid
(
root
,
objectid
);
again:
again:
...
@@ -211,7 +211,7 @@ void btrfs_return_ino(struct btrfs_root *root, u64 objectid)
...
@@ -211,7 +211,7 @@ void btrfs_return_ino(struct btrfs_root *root, u64 objectid)
{
{
struct
btrfs_free_space_ctl
*
pinned
=
root
->
free_ino_pinned
;
struct
btrfs_free_space_ctl
*
pinned
=
root
->
free_ino_pinned
;
if
(
!
btrfs_test_opt
(
root
,
INODE_MAP_CACHE
))
if
(
!
btrfs_test_opt
(
root
->
fs_info
,
INODE_MAP_CACHE
))
return
;
return
;
again:
again:
if
(
root
->
ino_cache_state
==
BTRFS_CACHE_FINISHED
)
{
if
(
root
->
ino_cache_state
==
BTRFS_CACHE_FINISHED
)
{
...
@@ -251,7 +251,7 @@ void btrfs_unpin_free_ino(struct btrfs_root *root)
...
@@ -251,7 +251,7 @@ void btrfs_unpin_free_ino(struct btrfs_root *root)
struct
rb_node
*
n
;
struct
rb_node
*
n
;
u64
count
;
u64
count
;
if
(
!
btrfs_test_opt
(
root
,
INODE_MAP_CACHE
))
if
(
!
btrfs_test_opt
(
root
->
fs_info
,
INODE_MAP_CACHE
))
return
;
return
;
while
(
1
)
{
while
(
1
)
{
...
@@ -412,7 +412,7 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
...
@@ -412,7 +412,7 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
if
(
btrfs_root_refs
(
&
root
->
root_item
)
==
0
)
if
(
btrfs_root_refs
(
&
root
->
root_item
)
==
0
)
return
0
;
return
0
;
if
(
!
btrfs_test_opt
(
root
,
INODE_MAP_CACHE
))
if
(
!
btrfs_test_opt
(
root
->
fs_info
,
INODE_MAP_CACHE
))
return
0
;
return
0
;
path
=
btrfs_alloc_path
();
path
=
btrfs_alloc_path
();
...
@@ -458,7 +458,7 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
...
@@ -458,7 +458,7 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
BTRFS_I
(
inode
)
->
generation
=
0
;
BTRFS_I
(
inode
)
->
generation
=
0
;
ret
=
btrfs_update_inode
(
trans
,
root
,
inode
);
ret
=
btrfs_update_inode
(
trans
,
root
,
inode
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out_put
;
goto
out_put
;
}
}
...
@@ -466,7 +466,7 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
...
@@ -466,7 +466,7 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
ret
=
btrfs_truncate_free_space_cache
(
root
,
trans
,
NULL
,
inode
);
ret
=
btrfs_truncate_free_space_cache
(
root
,
trans
,
NULL
,
inode
);
if
(
ret
)
{
if
(
ret
)
{
if
(
ret
!=
-
ENOSPC
)
if
(
ret
!=
-
ENOSPC
)
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out_put
;
goto
out_put
;
}
}
}
}
...
...
fs/btrfs/inode.c
浏览文件 @
023a824f
此差异已折叠。
点击以展开。
fs/btrfs/ioctl.c
浏览文件 @
023a824f
...
@@ -561,7 +561,7 @@ static noinline int create_subvol(struct inode *dir,
...
@@ -561,7 +561,7 @@ static noinline int create_subvol(struct inode *dir,
new_root
=
btrfs_read_fs_root_no_name
(
root
->
fs_info
,
&
key
);
new_root
=
btrfs_read_fs_root_no_name
(
root
->
fs_info
,
&
key
);
if
(
IS_ERR
(
new_root
))
{
if
(
IS_ERR
(
new_root
))
{
ret
=
PTR_ERR
(
new_root
);
ret
=
PTR_ERR
(
new_root
);
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
...
@@ -570,7 +570,7 @@ static noinline int create_subvol(struct inode *dir,
...
@@ -570,7 +570,7 @@ static noinline int create_subvol(struct inode *dir,
ret
=
btrfs_create_subvol_root
(
trans
,
new_root
,
root
,
new_dirid
);
ret
=
btrfs_create_subvol_root
(
trans
,
new_root
,
root
,
new_dirid
);
if
(
ret
)
{
if
(
ret
)
{
/* We potentially lose an unused inode item here */
/* We potentially lose an unused inode item here */
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
...
@@ -583,7 +583,7 @@ static noinline int create_subvol(struct inode *dir,
...
@@ -583,7 +583,7 @@ static noinline int create_subvol(struct inode *dir,
*/
*/
ret
=
btrfs_set_inode_index
(
dir
,
&
index
);
ret
=
btrfs_set_inode_index
(
dir
,
&
index
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
...
@@ -591,7 +591,7 @@ static noinline int create_subvol(struct inode *dir,
...
@@ -591,7 +591,7 @@ static noinline int create_subvol(struct inode *dir,
name
,
namelen
,
dir
,
&
key
,
name
,
namelen
,
dir
,
&
key
,
BTRFS_FT_DIR
,
index
);
BTRFS_FT_DIR
,
index
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
...
@@ -608,7 +608,7 @@ static noinline int create_subvol(struct inode *dir,
...
@@ -608,7 +608,7 @@ static noinline int create_subvol(struct inode *dir,
root_item
->
uuid
,
BTRFS_UUID_KEY_SUBVOL
,
root_item
->
uuid
,
BTRFS_UUID_KEY_SUBVOL
,
objectid
);
objectid
);
if
(
ret
)
if
(
ret
)
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
fail:
fail:
kfree
(
root_item
);
kfree
(
root_item
);
...
@@ -1948,8 +1948,7 @@ static noinline int key_in_sk(struct btrfs_key *key,
...
@@ -1948,8 +1948,7 @@ static noinline int key_in_sk(struct btrfs_key *key,
return
1
;
return
1
;
}
}
static
noinline
int
copy_to_sk
(
struct
btrfs_root
*
root
,
static
noinline
int
copy_to_sk
(
struct
btrfs_path
*
path
,
struct
btrfs_path
*
path
,
struct
btrfs_key
*
key
,
struct
btrfs_key
*
key
,
struct
btrfs_ioctl_search_key
*
sk
,
struct
btrfs_ioctl_search_key
*
sk
,
size_t
*
buf_size
,
size_t
*
buf_size
,
...
@@ -2120,7 +2119,7 @@ static noinline int search_ioctl(struct inode *inode,
...
@@ -2120,7 +2119,7 @@ static noinline int search_ioctl(struct inode *inode,
ret
=
0
;
ret
=
0
;
goto
err
;
goto
err
;
}
}
ret
=
copy_to_sk
(
root
,
path
,
&
key
,
sk
,
buf_size
,
ubuf
,
ret
=
copy_to_sk
(
path
,
&
key
,
sk
,
buf_size
,
ubuf
,
&
sk_offset
,
&
num_found
);
&
sk_offset
,
&
num_found
);
btrfs_release_path
(
path
);
btrfs_release_path
(
path
);
if
(
ret
)
if
(
ret
)
...
@@ -2406,7 +2405,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
...
@@ -2406,7 +2405,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
* rmdir(2).
* rmdir(2).
*/
*/
err
=
-
EPERM
;
err
=
-
EPERM
;
if
(
!
btrfs_test_opt
(
root
,
USER_SUBVOL_RM_ALLOWED
))
if
(
!
btrfs_test_opt
(
root
->
fs_info
,
USER_SUBVOL_RM_ALLOWED
))
goto
out_dput
;
goto
out_dput
;
/*
/*
...
@@ -2489,7 +2488,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
...
@@ -2489,7 +2488,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
dentry
->
d_name
.
len
);
dentry
->
d_name
.
len
);
if
(
ret
)
{
if
(
ret
)
{
err
=
ret
;
err
=
ret
;
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out_end_trans
;
goto
out_end_trans
;
}
}
...
@@ -2505,7 +2504,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
...
@@ -2505,7 +2504,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
root
->
fs_info
->
tree_root
,
root
->
fs_info
->
tree_root
,
dest
->
root_key
.
objectid
);
dest
->
root_key
.
objectid
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
err
=
ret
;
err
=
ret
;
goto
out_end_trans
;
goto
out_end_trans
;
}
}
...
@@ -2515,7 +2514,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
...
@@ -2515,7 +2514,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
dest
->
root_item
.
uuid
,
BTRFS_UUID_KEY_SUBVOL
,
dest
->
root_item
.
uuid
,
BTRFS_UUID_KEY_SUBVOL
,
dest
->
root_key
.
objectid
);
dest
->
root_key
.
objectid
);
if
(
ret
&&
ret
!=
-
ENOENT
)
{
if
(
ret
&&
ret
!=
-
ENOENT
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
err
=
ret
;
err
=
ret
;
goto
out_end_trans
;
goto
out_end_trans
;
}
}
...
@@ -2525,7 +2524,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
...
@@ -2525,7 +2524,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
BTRFS_UUID_KEY_RECEIVED_SUBVOL
,
BTRFS_UUID_KEY_RECEIVED_SUBVOL
,
dest
->
root_key
.
objectid
);
dest
->
root_key
.
objectid
);
if
(
ret
&&
ret
!=
-
ENOENT
)
{
if
(
ret
&&
ret
!=
-
ENOENT
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
err
=
ret
;
err
=
ret
;
goto
out_end_trans
;
goto
out_end_trans
;
}
}
...
@@ -3292,7 +3291,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
...
@@ -3292,7 +3291,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
ret
=
btrfs_update_inode
(
trans
,
root
,
inode
);
ret
=
btrfs_update_inode
(
trans
,
root
,
inode
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
btrfs_end_transaction
(
trans
,
root
);
btrfs_end_transaction
(
trans
,
root
);
goto
out
;
goto
out
;
}
}
...
@@ -3694,7 +3693,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
...
@@ -3694,7 +3693,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
if
(
ret
)
{
if
(
ret
)
{
if
(
ret
!=
-
EOPNOTSUPP
)
if
(
ret
!=
-
EOPNOTSUPP
)
btrfs_abort_transaction
(
trans
,
btrfs_abort_transaction
(
trans
,
root
,
ret
);
ret
);
btrfs_end_transaction
(
trans
,
root
);
btrfs_end_transaction
(
trans
,
root
);
goto
out
;
goto
out
;
}
}
...
@@ -3702,8 +3701,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
...
@@ -3702,8 +3701,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
ret
=
btrfs_insert_empty_item
(
trans
,
root
,
path
,
ret
=
btrfs_insert_empty_item
(
trans
,
root
,
path
,
&
new_key
,
size
);
&
new_key
,
size
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
root
,
btrfs_abort_transaction
(
trans
,
ret
);
ret
);
btrfs_end_transaction
(
trans
,
root
);
btrfs_end_transaction
(
trans
,
root
);
goto
out
;
goto
out
;
}
}
...
@@ -3735,7 +3733,6 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
...
@@ -3735,7 +3733,6 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
new_key
.
offset
-
datao
);
new_key
.
offset
-
datao
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
btrfs_abort_transaction
(
trans
,
root
,
ret
);
ret
);
btrfs_end_transaction
(
trans
,
btrfs_end_transaction
(
trans
,
root
);
root
);
...
@@ -3772,7 +3769,6 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
...
@@ -3772,7 +3769,6 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
if
(
ret
)
{
if
(
ret
)
{
if
(
ret
!=
-
EOPNOTSUPP
)
if
(
ret
!=
-
EOPNOTSUPP
)
btrfs_abort_transaction
(
trans
,
btrfs_abort_transaction
(
trans
,
root
,
ret
);
ret
);
btrfs_end_transaction
(
trans
,
root
);
btrfs_end_transaction
(
trans
,
root
);
goto
out
;
goto
out
;
...
@@ -3828,7 +3824,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
...
@@ -3828,7 +3824,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
last_dest_end
,
destoff
+
len
,
1
);
last_dest_end
,
destoff
+
len
,
1
);
if
(
ret
)
{
if
(
ret
)
{
if
(
ret
!=
-
EOPNOTSUPP
)
if
(
ret
!=
-
EOPNOTSUPP
)
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
btrfs_end_transaction
(
trans
,
root
);
btrfs_end_transaction
(
trans
,
root
);
goto
out
;
goto
out
;
}
}
...
@@ -5164,13 +5160,13 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file,
...
@@ -5164,13 +5160,13 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file,
BTRFS_UUID_KEY_RECEIVED_SUBVOL
,
BTRFS_UUID_KEY_RECEIVED_SUBVOL
,
root
->
root_key
.
objectid
);
root
->
root_key
.
objectid
);
if
(
ret
<
0
&&
ret
!=
-
EEXIST
)
{
if
(
ret
<
0
&&
ret
!=
-
EEXIST
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
}
}
ret
=
btrfs_commit_transaction
(
trans
,
root
);
ret
=
btrfs_commit_transaction
(
trans
,
root
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
...
...
fs/btrfs/ordered-data.c
浏览文件 @
023a824f
...
@@ -1122,7 +1122,7 @@ int __init ordered_data_init(void)
...
@@ -1122,7 +1122,7 @@ int __init ordered_data_init(void)
{
{
btrfs_ordered_extent_cache
=
kmem_cache_create
(
"btrfs_ordered_extent"
,
btrfs_ordered_extent_cache
=
kmem_cache_create
(
"btrfs_ordered_extent"
,
sizeof
(
struct
btrfs_ordered_extent
),
0
,
sizeof
(
struct
btrfs_ordered_extent
),
0
,
SLAB_
RECLAIM_ACCOUNT
|
SLAB_
MEM_SPREAD
,
SLAB_MEM_SPREAD
,
NULL
);
NULL
);
if
(
!
btrfs_ordered_extent_cache
)
if
(
!
btrfs_ordered_extent_cache
)
return
-
ENOMEM
;
return
-
ENOMEM
;
...
...
fs/btrfs/props.c
浏览文件 @
023a824f
...
@@ -350,6 +350,7 @@ int btrfs_subvol_inherit_props(struct btrfs_trans_handle *trans,
...
@@ -350,6 +350,7 @@ int btrfs_subvol_inherit_props(struct btrfs_trans_handle *trans,
struct
btrfs_root
*
root
,
struct
btrfs_root
*
root
,
struct
btrfs_root
*
parent_root
)
struct
btrfs_root
*
parent_root
)
{
{
struct
super_block
*
sb
=
root
->
fs_info
->
sb
;
struct
btrfs_key
key
;
struct
btrfs_key
key
;
struct
inode
*
parent_inode
,
*
child_inode
;
struct
inode
*
parent_inode
,
*
child_inode
;
int
ret
;
int
ret
;
...
@@ -358,12 +359,11 @@ int btrfs_subvol_inherit_props(struct btrfs_trans_handle *trans,
...
@@ -358,12 +359,11 @@ int btrfs_subvol_inherit_props(struct btrfs_trans_handle *trans,
key
.
type
=
BTRFS_INODE_ITEM_KEY
;
key
.
type
=
BTRFS_INODE_ITEM_KEY
;
key
.
offset
=
0
;
key
.
offset
=
0
;
parent_inode
=
btrfs_iget
(
parent_root
->
fs_info
->
sb
,
&
key
,
parent_inode
=
btrfs_iget
(
sb
,
&
key
,
parent_root
,
NULL
);
parent_root
,
NULL
);
if
(
IS_ERR
(
parent_inode
))
if
(
IS_ERR
(
parent_inode
))
return
PTR_ERR
(
parent_inode
);
return
PTR_ERR
(
parent_inode
);
child_inode
=
btrfs_iget
(
root
->
fs_info
->
sb
,
&
key
,
root
,
NULL
);
child_inode
=
btrfs_iget
(
sb
,
&
key
,
root
,
NULL
);
if
(
IS_ERR
(
child_inode
))
{
if
(
IS_ERR
(
child_inode
))
{
iput
(
parent_inode
);
iput
(
parent_inode
);
return
PTR_ERR
(
child_inode
);
return
PTR_ERR
(
child_inode
);
...
...
fs/btrfs/qgroup.c
浏览文件 @
023a824f
...
@@ -571,7 +571,7 @@ static int add_qgroup_item(struct btrfs_trans_handle *trans,
...
@@ -571,7 +571,7 @@ static int add_qgroup_item(struct btrfs_trans_handle *trans,
struct
extent_buffer
*
leaf
;
struct
extent_buffer
*
leaf
;
struct
btrfs_key
key
;
struct
btrfs_key
key
;
if
(
btrfs_
test_is_dummy_root
(
quota_root
))
if
(
btrfs_
is_testing
(
quota_root
->
fs_info
))
return
0
;
return
0
;
path
=
btrfs_alloc_path
();
path
=
btrfs_alloc_path
();
...
@@ -728,7 +728,7 @@ static int update_qgroup_info_item(struct btrfs_trans_handle *trans,
...
@@ -728,7 +728,7 @@ static int update_qgroup_info_item(struct btrfs_trans_handle *trans,
int
ret
;
int
ret
;
int
slot
;
int
slot
;
if
(
btrfs_
test_is_dummy_root
(
root
))
if
(
btrfs_
is_testing
(
root
->
fs_info
))
return
0
;
return
0
;
key
.
objectid
=
0
;
key
.
objectid
=
0
;
...
@@ -1453,9 +1453,10 @@ int btrfs_qgroup_prepare_account_extents(struct btrfs_trans_handle *trans,
...
@@ -1453,9 +1453,10 @@ int btrfs_qgroup_prepare_account_extents(struct btrfs_trans_handle *trans,
return
ret
;
return
ret
;
}
}
struct
btrfs_qgroup_extent_record
struct
btrfs_qgroup_extent_record
*
*
btrfs_qgroup_insert_dirty_extent
(
struct
btrfs_delayed_ref_root
*
delayed_refs
,
btrfs_qgroup_insert_dirty_extent
(
struct
btrfs_fs_info
*
fs_info
,
struct
btrfs_qgroup_extent_record
*
record
)
struct
btrfs_delayed_ref_root
*
delayed_refs
,
struct
btrfs_qgroup_extent_record
*
record
)
{
{
struct
rb_node
**
p
=
&
delayed_refs
->
dirty_extent_root
.
rb_node
;
struct
rb_node
**
p
=
&
delayed_refs
->
dirty_extent_root
.
rb_node
;
struct
rb_node
*
parent_node
=
NULL
;
struct
rb_node
*
parent_node
=
NULL
;
...
@@ -1463,7 +1464,7 @@ struct btrfs_qgroup_extent_record
...
@@ -1463,7 +1464,7 @@ struct btrfs_qgroup_extent_record
u64
bytenr
=
record
->
bytenr
;
u64
bytenr
=
record
->
bytenr
;
assert_spin_locked
(
&
delayed_refs
->
lock
);
assert_spin_locked
(
&
delayed_refs
->
lock
);
trace_btrfs_qgroup_insert_dirty_extent
(
record
);
trace_btrfs_qgroup_insert_dirty_extent
(
fs_info
,
record
);
while
(
*
p
)
{
while
(
*
p
)
{
parent_node
=
*
p
;
parent_node
=
*
p
;
...
@@ -1595,8 +1596,8 @@ static int qgroup_update_counters(struct btrfs_fs_info *fs_info,
...
@@ -1595,8 +1596,8 @@ static int qgroup_update_counters(struct btrfs_fs_info *fs_info,
cur_old_count
=
btrfs_qgroup_get_old_refcnt
(
qg
,
seq
);
cur_old_count
=
btrfs_qgroup_get_old_refcnt
(
qg
,
seq
);
cur_new_count
=
btrfs_qgroup_get_new_refcnt
(
qg
,
seq
);
cur_new_count
=
btrfs_qgroup_get_new_refcnt
(
qg
,
seq
);
trace_qgroup_update_counters
(
qg
->
qgroupid
,
cur_old_count
,
trace_qgroup_update_counters
(
fs_info
,
qg
->
qgroupid
,
cur_new_count
);
cur_
old_count
,
cur_
new_count
);
/* Rfer update part */
/* Rfer update part */
if
(
cur_old_count
==
0
&&
cur_new_count
>
0
)
{
if
(
cur_old_count
==
0
&&
cur_new_count
>
0
)
{
...
@@ -1687,8 +1688,8 @@ btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans,
...
@@ -1687,8 +1688,8 @@ btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans,
goto
out_free
;
goto
out_free
;
BUG_ON
(
!
fs_info
->
quota_root
);
BUG_ON
(
!
fs_info
->
quota_root
);
trace_btrfs_qgroup_account_extent
(
bytenr
,
num_bytes
,
nr_old_root
s
,
trace_btrfs_qgroup_account_extent
(
fs_info
,
bytenr
,
num_byte
s
,
nr_new_roots
);
nr_
old_roots
,
nr_
new_roots
);
qgroups
=
ulist_alloc
(
GFP_NOFS
);
qgroups
=
ulist_alloc
(
GFP_NOFS
);
if
(
!
qgroups
)
{
if
(
!
qgroups
)
{
...
@@ -1759,7 +1760,7 @@ int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans,
...
@@ -1759,7 +1760,7 @@ int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans,
record
=
rb_entry
(
node
,
struct
btrfs_qgroup_extent_record
,
record
=
rb_entry
(
node
,
struct
btrfs_qgroup_extent_record
,
node
);
node
);
trace_btrfs_qgroup_account_extents
(
record
);
trace_btrfs_qgroup_account_extents
(
fs_info
,
record
);
if
(
!
ret
)
{
if
(
!
ret
)
{
/*
/*
...
@@ -2195,7 +2196,7 @@ void assert_qgroups_uptodate(struct btrfs_trans_handle *trans)
...
@@ -2195,7 +2196,7 @@ void assert_qgroups_uptodate(struct btrfs_trans_handle *trans)
{
{
if
(
list_empty
(
&
trans
->
qgroup_ref_list
)
&&
!
trans
->
delayed_ref_elem
.
seq
)
if
(
list_empty
(
&
trans
->
qgroup_ref_list
)
&&
!
trans
->
delayed_ref_elem
.
seq
)
return
;
return
;
btrfs_err
(
trans
->
root
->
fs_info
,
btrfs_err
(
trans
->
fs_info
,
"qgroups not uptodate in trans handle %p: list is%s empty, "
"qgroups not uptodate in trans handle %p: list is%s empty, "
"seq is %#x.%x"
,
"seq is %#x.%x"
,
trans
,
list_empty
(
&
trans
->
qgroup_ref_list
)
?
""
:
" not"
,
trans
,
list_empty
(
&
trans
->
qgroup_ref_list
)
?
""
:
" not"
,
...
...
fs/btrfs/qgroup.h
浏览文件 @
023a824f
...
@@ -63,9 +63,10 @@ void btrfs_free_qgroup_config(struct btrfs_fs_info *fs_info);
...
@@ -63,9 +63,10 @@ void btrfs_free_qgroup_config(struct btrfs_fs_info *fs_info);
struct
btrfs_delayed_extent_op
;
struct
btrfs_delayed_extent_op
;
int
btrfs_qgroup_prepare_account_extents
(
struct
btrfs_trans_handle
*
trans
,
int
btrfs_qgroup_prepare_account_extents
(
struct
btrfs_trans_handle
*
trans
,
struct
btrfs_fs_info
*
fs_info
);
struct
btrfs_fs_info
*
fs_info
);
struct
btrfs_qgroup_extent_record
struct
btrfs_qgroup_extent_record
*
*
btrfs_qgroup_insert_dirty_extent
(
struct
btrfs_delayed_ref_root
*
delayed_refs
,
btrfs_qgroup_insert_dirty_extent
(
struct
btrfs_fs_info
*
fs_info
,
struct
btrfs_qgroup_extent_record
*
record
);
struct
btrfs_delayed_ref_root
*
delayed_refs
,
struct
btrfs_qgroup_extent_record
*
record
);
int
int
btrfs_qgroup_account_extent
(
struct
btrfs_trans_handle
*
trans
,
btrfs_qgroup_account_extent
(
struct
btrfs_trans_handle
*
trans
,
struct
btrfs_fs_info
*
fs_info
,
struct
btrfs_fs_info
*
fs_info
,
...
@@ -88,7 +89,7 @@ static inline void btrfs_qgroup_free_delayed_ref(struct btrfs_fs_info *fs_info,
...
@@ -88,7 +89,7 @@ static inline void btrfs_qgroup_free_delayed_ref(struct btrfs_fs_info *fs_info,
u64
ref_root
,
u64
num_bytes
)
u64
ref_root
,
u64
num_bytes
)
{
{
btrfs_qgroup_free_refroot
(
fs_info
,
ref_root
,
num_bytes
);
btrfs_qgroup_free_refroot
(
fs_info
,
ref_root
,
num_bytes
);
trace_btrfs_qgroup_free_delayed_ref
(
ref_root
,
num_bytes
);
trace_btrfs_qgroup_free_delayed_ref
(
fs_info
,
ref_root
,
num_bytes
);
}
}
void
assert_qgroups_uptodate
(
struct
btrfs_trans_handle
*
trans
);
void
assert_qgroups_uptodate
(
struct
btrfs_trans_handle
*
trans
);
...
...
fs/btrfs/relocation.c
浏览文件 @
023a824f
...
@@ -235,12 +235,12 @@ static void backref_cache_cleanup(struct backref_cache *cache)
...
@@ -235,12 +235,12 @@ static void backref_cache_cleanup(struct backref_cache *cache)
cache
->
last_trans
=
0
;
cache
->
last_trans
=
0
;
for
(
i
=
0
;
i
<
BTRFS_MAX_LEVEL
;
i
++
)
for
(
i
=
0
;
i
<
BTRFS_MAX_LEVEL
;
i
++
)
BUG_ON
(
!
list_empty
(
&
cache
->
pending
[
i
]));
ASSERT
(
list_empty
(
&
cache
->
pending
[
i
]));
BUG_ON
(
!
list_empty
(
&
cache
->
changed
));
ASSERT
(
list_empty
(
&
cache
->
changed
));
BUG_ON
(
!
list_empty
(
&
cache
->
detached
));
ASSERT
(
list_empty
(
&
cache
->
detached
));
BUG_ON
(
!
RB_EMPTY_ROOT
(
&
cache
->
rb_root
));
ASSERT
(
RB_EMPTY_ROOT
(
&
cache
->
rb_root
));
BUG_ON
(
cache
->
nr_nodes
);
ASSERT
(
!
cache
->
nr_nodes
);
BUG_ON
(
cache
->
nr_edges
);
ASSERT
(
!
cache
->
nr_edges
);
}
}
static
struct
backref_node
*
alloc_backref_node
(
struct
backref_cache
*
cache
)
static
struct
backref_node
*
alloc_backref_node
(
struct
backref_cache
*
cache
)
...
@@ -1171,8 +1171,12 @@ struct backref_node *build_backref_tree(struct reloc_control *rc,
...
@@ -1171,8 +1171,12 @@ struct backref_node *build_backref_tree(struct reloc_control *rc,
lower
=
list_entry
(
useless
.
next
,
lower
=
list_entry
(
useless
.
next
,
struct
backref_node
,
list
);
struct
backref_node
,
list
);
list_del_init
(
&
lower
->
list
);
list_del_init
(
&
lower
->
list
);
if
(
lower
==
node
)
node
=
NULL
;
free_backref_node
(
cache
,
lower
);
free_backref_node
(
cache
,
lower
);
}
}
free_backref_node
(
cache
,
node
);
return
ERR_PTR
(
err
);
return
ERR_PTR
(
err
);
}
}
ASSERT
(
!
node
||
!
node
->
detached
);
ASSERT
(
!
node
||
!
node
->
detached
);
...
@@ -1719,7 +1723,7 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
...
@@ -1719,7 +1723,7 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
btrfs_header_owner
(
leaf
),
btrfs_header_owner
(
leaf
),
key
.
objectid
,
key
.
offset
);
key
.
objectid
,
key
.
offset
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
break
;
break
;
}
}
...
@@ -1727,7 +1731,7 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
...
@@ -1727,7 +1731,7 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
parent
,
btrfs_header_owner
(
leaf
),
parent
,
btrfs_header_owner
(
leaf
),
key
.
objectid
,
key
.
offset
);
key
.
objectid
,
key
.
offset
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
break
;
break
;
}
}
}
}
...
...
fs/btrfs/root-tree.c
浏览文件 @
023a824f
...
@@ -150,7 +150,7 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
...
@@ -150,7 +150,7 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
ret
=
btrfs_search_slot
(
trans
,
root
,
key
,
path
,
0
,
1
);
ret
=
btrfs_search_slot
(
trans
,
root
,
key
,
path
,
0
,
1
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
...
@@ -176,20 +176,20 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
...
@@ -176,20 +176,20 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
ret
=
btrfs_search_slot
(
trans
,
root
,
key
,
path
,
ret
=
btrfs_search_slot
(
trans
,
root
,
key
,
path
,
-
1
,
1
);
-
1
,
1
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
ret
=
btrfs_del_item
(
trans
,
root
,
path
);
ret
=
btrfs_del_item
(
trans
,
root
,
path
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
btrfs_release_path
(
path
);
btrfs_release_path
(
path
);
ret
=
btrfs_insert_empty_item
(
trans
,
root
,
path
,
ret
=
btrfs_insert_empty_item
(
trans
,
root
,
path
,
key
,
sizeof
(
*
item
));
key
,
sizeof
(
*
item
));
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
l
=
path
->
nodes
[
0
];
l
=
path
->
nodes
[
0
];
...
@@ -448,7 +448,7 @@ int btrfs_add_root_ref(struct btrfs_trans_handle *trans,
...
@@ -448,7 +448,7 @@ int btrfs_add_root_ref(struct btrfs_trans_handle *trans,
ret
=
btrfs_insert_empty_item
(
trans
,
tree_root
,
path
,
&
key
,
ret
=
btrfs_insert_empty_item
(
trans
,
tree_root
,
path
,
&
key
,
sizeof
(
*
ref
)
+
name_len
);
sizeof
(
*
ref
)
+
name_len
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
tree_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
btrfs_free_path
(
path
);
btrfs_free_path
(
path
);
return
ret
;
return
ret
;
}
}
...
...
fs/btrfs/scrub.c
浏览文件 @
023a824f
...
@@ -3781,27 +3781,27 @@ static noinline_for_stack int scrub_workers_get(struct btrfs_fs_info *fs_info,
...
@@ -3781,27 +3781,27 @@ static noinline_for_stack int scrub_workers_get(struct btrfs_fs_info *fs_info,
if
(
fs_info
->
scrub_workers_refcnt
==
0
)
{
if
(
fs_info
->
scrub_workers_refcnt
==
0
)
{
if
(
is_dev_replace
)
if
(
is_dev_replace
)
fs_info
->
scrub_workers
=
fs_info
->
scrub_workers
=
btrfs_alloc_workqueue
(
"scrub"
,
flags
,
btrfs_alloc_workqueue
(
fs_info
,
"scrub"
,
flags
,
1
,
4
);
1
,
4
);
else
else
fs_info
->
scrub_workers
=
fs_info
->
scrub_workers
=
btrfs_alloc_workqueue
(
"scrub"
,
flags
,
btrfs_alloc_workqueue
(
fs_info
,
"scrub"
,
flags
,
max_active
,
4
);
max_active
,
4
);
if
(
!
fs_info
->
scrub_workers
)
if
(
!
fs_info
->
scrub_workers
)
goto
fail_scrub_workers
;
goto
fail_scrub_workers
;
fs_info
->
scrub_wr_completion_workers
=
fs_info
->
scrub_wr_completion_workers
=
btrfs_alloc_workqueue
(
"scrubwrc"
,
flags
,
btrfs_alloc_workqueue
(
fs_info
,
"scrubwrc"
,
flags
,
max_active
,
2
);
max_active
,
2
);
if
(
!
fs_info
->
scrub_wr_completion_workers
)
if
(
!
fs_info
->
scrub_wr_completion_workers
)
goto
fail_scrub_wr_completion_workers
;
goto
fail_scrub_wr_completion_workers
;
fs_info
->
scrub_nocow_workers
=
fs_info
->
scrub_nocow_workers
=
btrfs_alloc_workqueue
(
"scrubnc"
,
flags
,
1
,
0
);
btrfs_alloc_workqueue
(
fs_info
,
"scrubnc"
,
flags
,
1
,
0
);
if
(
!
fs_info
->
scrub_nocow_workers
)
if
(
!
fs_info
->
scrub_nocow_workers
)
goto
fail_scrub_nocow_workers
;
goto
fail_scrub_nocow_workers
;
fs_info
->
scrub_parity_workers
=
fs_info
->
scrub_parity_workers
=
btrfs_alloc_workqueue
(
"scrubparity"
,
flags
,
btrfs_alloc_workqueue
(
fs_info
,
"scrubparity"
,
flags
,
max_active
,
2
);
max_active
,
2
);
if
(
!
fs_info
->
scrub_parity_workers
)
if
(
!
fs_info
->
scrub_parity_workers
)
goto
fail_scrub_parity_workers
;
goto
fail_scrub_parity_workers
;
...
@@ -3856,7 +3856,7 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
...
@@ -3856,7 +3856,7 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
if
(
fs_info
->
chunk_root
->
sectorsize
!=
PAGE_SIZE
)
{
if
(
fs_info
->
chunk_root
->
sectorsize
!=
PAGE_SIZE
)
{
/* not supported for data w/o checksums */
/* not supported for data w/o checksums */
btrfs_err
(
fs_info
,
btrfs_err
_rl
(
fs_info
,
"scrub: size assumption sectorsize != PAGE_SIZE "
"scrub: size assumption sectorsize != PAGE_SIZE "
"(%d != %lu) fails"
,
"(%d != %lu) fails"
,
fs_info
->
chunk_root
->
sectorsize
,
PAGE_SIZE
);
fs_info
->
chunk_root
->
sectorsize
,
PAGE_SIZE
);
...
...
fs/btrfs/super.c
浏览文件 @
023a824f
...
@@ -184,6 +184,22 @@ static const char * const logtypes[] = {
...
@@ -184,6 +184,22 @@ static const char * const logtypes[] = {
"debug"
,
"debug"
,
};
};
/*
* Use one ratelimit state per log level so that a flood of less important
* messages doesn't cause more important ones to be dropped.
*/
static
struct
ratelimit_state
printk_limits
[]
=
{
RATELIMIT_STATE_INIT
(
printk_limits
[
0
],
DEFAULT_RATELIMIT_INTERVAL
,
100
),
RATELIMIT_STATE_INIT
(
printk_limits
[
1
],
DEFAULT_RATELIMIT_INTERVAL
,
100
),
RATELIMIT_STATE_INIT
(
printk_limits
[
2
],
DEFAULT_RATELIMIT_INTERVAL
,
100
),
RATELIMIT_STATE_INIT
(
printk_limits
[
3
],
DEFAULT_RATELIMIT_INTERVAL
,
100
),
RATELIMIT_STATE_INIT
(
printk_limits
[
4
],
DEFAULT_RATELIMIT_INTERVAL
,
100
),
RATELIMIT_STATE_INIT
(
printk_limits
[
5
],
DEFAULT_RATELIMIT_INTERVAL
,
100
),
RATELIMIT_STATE_INIT
(
printk_limits
[
6
],
DEFAULT_RATELIMIT_INTERVAL
,
100
),
RATELIMIT_STATE_INIT
(
printk_limits
[
7
],
DEFAULT_RATELIMIT_INTERVAL
,
100
),
};
void
btrfs_printk
(
const
struct
btrfs_fs_info
*
fs_info
,
const
char
*
fmt
,
...)
void
btrfs_printk
(
const
struct
btrfs_fs_info
*
fs_info
,
const
char
*
fmt
,
...)
{
{
struct
super_block
*
sb
=
fs_info
->
sb
;
struct
super_block
*
sb
=
fs_info
->
sb
;
...
@@ -192,6 +208,7 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
...
@@ -192,6 +208,7 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
va_list
args
;
va_list
args
;
const
char
*
type
=
logtypes
[
4
];
const
char
*
type
=
logtypes
[
4
];
int
kern_level
;
int
kern_level
;
struct
ratelimit_state
*
ratelimit
;
va_start
(
args
,
fmt
);
va_start
(
args
,
fmt
);
...
@@ -202,13 +219,18 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
...
@@ -202,13 +219,18 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
lvl
[
size
]
=
'\0'
;
lvl
[
size
]
=
'\0'
;
fmt
+=
size
;
fmt
+=
size
;
type
=
logtypes
[
kern_level
-
'0'
];
type
=
logtypes
[
kern_level
-
'0'
];
}
else
ratelimit
=
&
printk_limits
[
kern_level
-
'0'
];
}
else
{
*
lvl
=
'\0'
;
*
lvl
=
'\0'
;
/* Default to debug output */
ratelimit
=
&
printk_limits
[
7
];
}
vaf
.
fmt
=
fmt
;
vaf
.
fmt
=
fmt
;
vaf
.
va
=
&
args
;
vaf
.
va
=
&
args
;
printk
(
"%sBTRFS %s (device %s): %pV
\n
"
,
lvl
,
type
,
sb
->
s_id
,
&
vaf
);
if
(
__ratelimit
(
ratelimit
))
printk
(
"%sBTRFS %s (device %s): %pV
\n
"
,
lvl
,
type
,
sb
->
s_id
,
&
vaf
);
va_end
(
args
);
va_end
(
args
);
}
}
...
@@ -229,9 +251,11 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
...
@@ -229,9 +251,11 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
*/
*/
__cold
__cold
void
__btrfs_abort_transaction
(
struct
btrfs_trans_handle
*
trans
,
void
__btrfs_abort_transaction
(
struct
btrfs_trans_handle
*
trans
,
struct
btrfs_root
*
root
,
const
char
*
function
,
const
char
*
function
,
unsigned
int
line
,
int
errno
)
unsigned
int
line
,
int
errno
)
{
{
struct
btrfs_fs_info
*
fs_info
=
trans
->
fs_info
;
trans
->
aborted
=
errno
;
trans
->
aborted
=
errno
;
/* Nothing used. The other threads that have joined this
/* Nothing used. The other threads that have joined this
* transaction may be able to continue. */
* transaction may be able to continue. */
...
@@ -239,16 +263,16 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
...
@@ -239,16 +263,16 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
const
char
*
errstr
;
const
char
*
errstr
;
errstr
=
btrfs_decode_error
(
errno
);
errstr
=
btrfs_decode_error
(
errno
);
btrfs_warn
(
root
->
fs_info
,
btrfs_warn
(
fs_info
,
"%s:%d: Aborting unused transaction(%s)."
,
"%s:%d: Aborting unused transaction(%s)."
,
function
,
line
,
errstr
);
function
,
line
,
errstr
);
return
;
return
;
}
}
ACCESS_ONCE
(
trans
->
transaction
->
aborted
)
=
errno
;
ACCESS_ONCE
(
trans
->
transaction
->
aborted
)
=
errno
;
/* Wake up anybody who may be waiting on this transaction */
/* Wake up anybody who may be waiting on this transaction */
wake_up
(
&
root
->
fs_info
->
transaction_wait
);
wake_up
(
&
fs_info
->
transaction_wait
);
wake_up
(
&
root
->
fs_info
->
transaction_blocked_wait
);
wake_up
(
&
fs_info
->
transaction_blocked_wait
);
__btrfs_handle_fs_error
(
root
->
fs_info
,
function
,
line
,
errno
,
NULL
);
__btrfs_handle_fs_error
(
fs_info
,
function
,
line
,
errno
,
NULL
);
}
}
/*
/*
* __btrfs_panic decodes unexpected, fatal errors from the caller,
* __btrfs_panic decodes unexpected, fatal errors from the caller,
...
@@ -432,12 +456,12 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
...
@@ -432,12 +456,12 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
*/
*/
break
;
break
;
case
Opt_nodatasum
:
case
Opt_nodatasum
:
btrfs_set_and_info
(
root
,
NODATASUM
,
btrfs_set_and_info
(
info
,
NODATASUM
,
"setting nodatasum"
);
"setting nodatasum"
);
break
;
break
;
case
Opt_datasum
:
case
Opt_datasum
:
if
(
btrfs_test_opt
(
root
,
NODATASUM
))
{
if
(
btrfs_test_opt
(
info
,
NODATASUM
))
{
if
(
btrfs_test_opt
(
root
,
NODATACOW
))
if
(
btrfs_test_opt
(
info
,
NODATACOW
))
btrfs_info
(
root
->
fs_info
,
"setting datasum, datacow enabled"
);
btrfs_info
(
root
->
fs_info
,
"setting datasum, datacow enabled"
);
else
else
btrfs_info
(
root
->
fs_info
,
"setting datasum"
);
btrfs_info
(
root
->
fs_info
,
"setting datasum"
);
...
@@ -446,9 +470,9 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
...
@@ -446,9 +470,9 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
btrfs_clear_opt
(
info
->
mount_opt
,
NODATASUM
);
btrfs_clear_opt
(
info
->
mount_opt
,
NODATASUM
);
break
;
break
;
case
Opt_nodatacow
:
case
Opt_nodatacow
:
if
(
!
btrfs_test_opt
(
root
,
NODATACOW
))
{
if
(
!
btrfs_test_opt
(
info
,
NODATACOW
))
{
if
(
!
btrfs_test_opt
(
root
,
COMPRESS
)
||
if
(
!
btrfs_test_opt
(
info
,
COMPRESS
)
||
!
btrfs_test_opt
(
root
,
FORCE_COMPRESS
))
{
!
btrfs_test_opt
(
info
,
FORCE_COMPRESS
))
{
btrfs_info
(
root
->
fs_info
,
btrfs_info
(
root
->
fs_info
,
"setting nodatacow, compression disabled"
);
"setting nodatacow, compression disabled"
);
}
else
{
}
else
{
...
@@ -461,7 +485,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
...
@@ -461,7 +485,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
btrfs_set_opt
(
info
->
mount_opt
,
NODATASUM
);
btrfs_set_opt
(
info
->
mount_opt
,
NODATASUM
);
break
;
break
;
case
Opt_datacow
:
case
Opt_datacow
:
btrfs_clear_and_info
(
root
,
NODATACOW
,
btrfs_clear_and_info
(
info
,
NODATACOW
,
"setting datacow"
);
"setting datacow"
);
break
;
break
;
case
Opt_compress_force
:
case
Opt_compress_force
:
...
@@ -470,10 +494,11 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
...
@@ -470,10 +494,11 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
/* Fallthrough */
/* Fallthrough */
case
Opt_compress
:
case
Opt_compress
:
case
Opt_compress_type
:
case
Opt_compress_type
:
saved_compress_type
=
btrfs_test_opt
(
root
,
COMPRESS
)
?
saved_compress_type
=
btrfs_test_opt
(
info
,
COMPRESS
)
?
info
->
compress_type
:
BTRFS_COMPRESS_NONE
;
info
->
compress_type
:
BTRFS_COMPRESS_NONE
;
saved_compress_force
=
saved_compress_force
=
btrfs_test_opt
(
root
,
FORCE_COMPRESS
);
btrfs_test_opt
(
info
,
FORCE_COMPRESS
);
if
(
token
==
Opt_compress
||
if
(
token
==
Opt_compress
||
token
==
Opt_compress_force
||
token
==
Opt_compress_force
||
strcmp
(
args
[
0
].
from
,
"zlib"
)
==
0
)
{
strcmp
(
args
[
0
].
from
,
"zlib"
)
==
0
)
{
...
@@ -513,10 +538,10 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
...
@@ -513,10 +538,10 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
*/
*/
btrfs_clear_opt
(
info
->
mount_opt
,
FORCE_COMPRESS
);
btrfs_clear_opt
(
info
->
mount_opt
,
FORCE_COMPRESS
);
}
}
if
((
btrfs_test_opt
(
root
,
COMPRESS
)
&&
if
((
btrfs_test_opt
(
info
,
COMPRESS
)
&&
(
info
->
compress_type
!=
saved_compress_type
||
(
info
->
compress_type
!=
saved_compress_type
||
compress_force
!=
saved_compress_force
))
||
compress_force
!=
saved_compress_force
))
||
(
!
btrfs_test_opt
(
root
,
COMPRESS
)
&&
(
!
btrfs_test_opt
(
info
,
COMPRESS
)
&&
no_compress
==
1
))
{
no_compress
==
1
))
{
btrfs_info
(
root
->
fs_info
,
btrfs_info
(
root
->
fs_info
,
"%s %s compression"
,
"%s %s compression"
,
...
@@ -526,25 +551,25 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
...
@@ -526,25 +551,25 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
compress_force
=
false
;
compress_force
=
false
;
break
;
break
;
case
Opt_ssd
:
case
Opt_ssd
:
btrfs_set_and_info
(
root
,
SSD
,
btrfs_set_and_info
(
info
,
SSD
,
"use ssd allocation scheme"
);
"use ssd allocation scheme"
);
break
;
break
;
case
Opt_ssd_spread
:
case
Opt_ssd_spread
:
btrfs_set_and_info
(
root
,
SSD_SPREAD
,
btrfs_set_and_info
(
info
,
SSD_SPREAD
,
"use spread ssd allocation scheme"
);
"use spread ssd allocation scheme"
);
btrfs_set_opt
(
info
->
mount_opt
,
SSD
);
btrfs_set_opt
(
info
->
mount_opt
,
SSD
);
break
;
break
;
case
Opt_nossd
:
case
Opt_nossd
:
btrfs_set_and_info
(
root
,
NOSSD
,
btrfs_set_and_info
(
info
,
NOSSD
,
"not using ssd allocation scheme"
);
"not using ssd allocation scheme"
);
btrfs_clear_opt
(
info
->
mount_opt
,
SSD
);
btrfs_clear_opt
(
info
->
mount_opt
,
SSD
);
break
;
break
;
case
Opt_barrier
:
case
Opt_barrier
:
btrfs_clear_and_info
(
root
,
NOBARRIER
,
btrfs_clear_and_info
(
info
,
NOBARRIER
,
"turning on barriers"
);
"turning on barriers"
);
break
;
break
;
case
Opt_nobarrier
:
case
Opt_nobarrier
:
btrfs_set_and_info
(
root
,
NOBARRIER
,
btrfs_set_and_info
(
info
,
NOBARRIER
,
"turning off barriers"
);
"turning off barriers"
);
break
;
break
;
case
Opt_thread_pool
:
case
Opt_thread_pool
:
...
@@ -604,24 +629,24 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
...
@@ -604,24 +629,24 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
root
->
fs_info
->
sb
->
s_flags
&=
~
MS_POSIXACL
;
root
->
fs_info
->
sb
->
s_flags
&=
~
MS_POSIXACL
;
break
;
break
;
case
Opt_notreelog
:
case
Opt_notreelog
:
btrfs_set_and_info
(
root
,
NOTREELOG
,
btrfs_set_and_info
(
info
,
NOTREELOG
,
"disabling tree log"
);
"disabling tree log"
);
break
;
break
;
case
Opt_treelog
:
case
Opt_treelog
:
btrfs_clear_and_info
(
root
,
NOTREELOG
,
btrfs_clear_and_info
(
info
,
NOTREELOG
,
"enabling tree log"
);
"enabling tree log"
);
break
;
break
;
case
Opt_norecovery
:
case
Opt_norecovery
:
case
Opt_nologreplay
:
case
Opt_nologreplay
:
btrfs_set_and_info
(
root
,
NOLOGREPLAY
,
btrfs_set_and_info
(
info
,
NOLOGREPLAY
,
"disabling log replay at mount time"
);
"disabling log replay at mount time"
);
break
;
break
;
case
Opt_flushoncommit
:
case
Opt_flushoncommit
:
btrfs_set_and_info
(
root
,
FLUSHONCOMMIT
,
btrfs_set_and_info
(
info
,
FLUSHONCOMMIT
,
"turning on flush-on-commit"
);
"turning on flush-on-commit"
);
break
;
break
;
case
Opt_noflushoncommit
:
case
Opt_noflushoncommit
:
btrfs_clear_and_info
(
root
,
FLUSHONCOMMIT
,
btrfs_clear_and_info
(
info
,
FLUSHONCOMMIT
,
"turning off flush-on-commit"
);
"turning off flush-on-commit"
);
break
;
break
;
case
Opt_ratio
:
case
Opt_ratio
:
...
@@ -638,11 +663,11 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
...
@@ -638,11 +663,11 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
}
}
break
;
break
;
case
Opt_discard
:
case
Opt_discard
:
btrfs_set_and_info
(
root
,
DISCARD
,
btrfs_set_and_info
(
info
,
DISCARD
,
"turning on discard"
);
"turning on discard"
);
break
;
break
;
case
Opt_nodiscard
:
case
Opt_nodiscard
:
btrfs_clear_and_info
(
root
,
DISCARD
,
btrfs_clear_and_info
(
info
,
DISCARD
,
"turning off discard"
);
"turning off discard"
);
break
;
break
;
case
Opt_space_cache
:
case
Opt_space_cache
:
...
@@ -651,12 +676,13 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
...
@@ -651,12 +676,13 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
strcmp
(
args
[
0
].
from
,
"v1"
)
==
0
)
{
strcmp
(
args
[
0
].
from
,
"v1"
)
==
0
)
{
btrfs_clear_opt
(
root
->
fs_info
->
mount_opt
,
btrfs_clear_opt
(
root
->
fs_info
->
mount_opt
,
FREE_SPACE_TREE
);
FREE_SPACE_TREE
);
btrfs_set_and_info
(
root
,
SPACE_CACHE
,
btrfs_set_and_info
(
info
,
SPACE_CACHE
,
"enabling disk space caching"
);
"enabling disk space caching"
);
}
else
if
(
strcmp
(
args
[
0
].
from
,
"v2"
)
==
0
)
{
}
else
if
(
strcmp
(
args
[
0
].
from
,
"v2"
)
==
0
)
{
btrfs_clear_opt
(
root
->
fs_info
->
mount_opt
,
btrfs_clear_opt
(
root
->
fs_info
->
mount_opt
,
SPACE_CACHE
);
SPACE_CACHE
);
btrfs_set_and_info
(
root
,
FREE_SPACE_TREE
,
btrfs_set_and_info
(
info
,
FREE_SPACE_TREE
,
"enabling free space tree"
);
"enabling free space tree"
);
}
else
{
}
else
{
ret
=
-
EINVAL
;
ret
=
-
EINVAL
;
...
@@ -667,12 +693,14 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
...
@@ -667,12 +693,14 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
btrfs_set_opt
(
info
->
mount_opt
,
RESCAN_UUID_TREE
);
btrfs_set_opt
(
info
->
mount_opt
,
RESCAN_UUID_TREE
);
break
;
break
;
case
Opt_no_space_cache
:
case
Opt_no_space_cache
:
if
(
btrfs_test_opt
(
root
,
SPACE_CACHE
))
{
if
(
btrfs_test_opt
(
info
,
SPACE_CACHE
))
{
btrfs_clear_and_info
(
root
,
SPACE_CACHE
,
btrfs_clear_and_info
(
info
,
SPACE_CACHE
,
"disabling disk space caching"
);
"disabling disk space caching"
);
}
}
if
(
btrfs_test_opt
(
root
,
FREE_SPACE_TREE
))
{
if
(
btrfs_test_opt
(
info
,
FREE_SPACE_TREE
))
{
btrfs_clear_and_info
(
root
,
FREE_SPACE_TREE
,
btrfs_clear_and_info
(
info
,
FREE_SPACE_TREE
,
"disabling free space tree"
);
"disabling free space tree"
);
}
}
break
;
break
;
...
@@ -685,7 +713,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
...
@@ -685,7 +713,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
"disabling inode map caching"
);
"disabling inode map caching"
);
break
;
break
;
case
Opt_clear_cache
:
case
Opt_clear_cache
:
btrfs_set_and_info
(
root
,
CLEAR_CACHE
,
btrfs_set_and_info
(
info
,
CLEAR_CACHE
,
"force clearing of disk cache"
);
"force clearing of disk cache"
);
break
;
break
;
case
Opt_user_subvol_rm_allowed
:
case
Opt_user_subvol_rm_allowed
:
...
@@ -698,11 +726,11 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
...
@@ -698,11 +726,11 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
btrfs_clear_opt
(
info
->
mount_opt
,
ENOSPC_DEBUG
);
btrfs_clear_opt
(
info
->
mount_opt
,
ENOSPC_DEBUG
);
break
;
break
;
case
Opt_defrag
:
case
Opt_defrag
:
btrfs_set_and_info
(
root
,
AUTO_DEFRAG
,
btrfs_set_and_info
(
info
,
AUTO_DEFRAG
,
"enabling auto defrag"
);
"enabling auto defrag"
);
break
;
break
;
case
Opt_nodefrag
:
case
Opt_nodefrag
:
btrfs_clear_and_info
(
root
,
AUTO_DEFRAG
,
btrfs_clear_and_info
(
info
,
AUTO_DEFRAG
,
"disabling auto defrag"
);
"disabling auto defrag"
);
break
;
break
;
case
Opt_recovery
:
case
Opt_recovery
:
...
@@ -810,22 +838,22 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
...
@@ -810,22 +838,22 @@ int btrfs_parse_options(struct btrfs_root *root, char *options,
/*
/*
* Extra check for current option against current flag
* Extra check for current option against current flag
*/
*/
if
(
btrfs_test_opt
(
root
,
NOLOGREPLAY
)
&&
!
(
new_flags
&
MS_RDONLY
))
{
if
(
btrfs_test_opt
(
info
,
NOLOGREPLAY
)
&&
!
(
new_flags
&
MS_RDONLY
))
{
btrfs_err
(
root
->
fs_info
,
btrfs_err
(
root
->
fs_info
,
"nologreplay must be used with ro mount option"
);
"nologreplay must be used with ro mount option"
);
ret
=
-
EINVAL
;
ret
=
-
EINVAL
;
}
}
out:
out:
if
(
btrfs_fs_compat_ro
(
root
->
fs_info
,
FREE_SPACE_TREE
)
&&
if
(
btrfs_fs_compat_ro
(
root
->
fs_info
,
FREE_SPACE_TREE
)
&&
!
btrfs_test_opt
(
root
,
FREE_SPACE_TREE
)
&&
!
btrfs_test_opt
(
info
,
FREE_SPACE_TREE
)
&&
!
btrfs_test_opt
(
root
,
CLEAR_CACHE
))
{
!
btrfs_test_opt
(
info
,
CLEAR_CACHE
))
{
btrfs_err
(
root
->
fs_info
,
"cannot disable free space tree"
);
btrfs_err
(
root
->
fs_info
,
"cannot disable free space tree"
);
ret
=
-
EINVAL
;
ret
=
-
EINVAL
;
}
}
if
(
!
ret
&&
btrfs_test_opt
(
root
,
SPACE_CACHE
))
if
(
!
ret
&&
btrfs_test_opt
(
info
,
SPACE_CACHE
))
btrfs_info
(
root
->
fs_info
,
"disk space caching is enabled"
);
btrfs_info
(
root
->
fs_info
,
"disk space caching is enabled"
);
if
(
!
ret
&&
btrfs_test_opt
(
root
,
FREE_SPACE_TREE
))
if
(
!
ret
&&
btrfs_test_opt
(
info
,
FREE_SPACE_TREE
))
btrfs_info
(
root
->
fs_info
,
"using free space tree"
);
btrfs_info
(
root
->
fs_info
,
"using free space tree"
);
kfree
(
orig
);
kfree
(
orig
);
return
ret
;
return
ret
;
...
@@ -1149,7 +1177,7 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
...
@@ -1149,7 +1177,7 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
struct
btrfs_fs_info
*
fs_info
=
btrfs_sb
(
sb
);
struct
btrfs_fs_info
*
fs_info
=
btrfs_sb
(
sb
);
struct
btrfs_root
*
root
=
fs_info
->
tree_root
;
struct
btrfs_root
*
root
=
fs_info
->
tree_root
;
trace_btrfs_sync_fs
(
wait
);
trace_btrfs_sync_fs
(
fs_info
,
wait
);
if
(
!
wait
)
{
if
(
!
wait
)
{
filemap_flush
(
fs_info
->
btree_inode
->
i_mapping
);
filemap_flush
(
fs_info
->
btree_inode
->
i_mapping
);
...
@@ -1192,13 +1220,13 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
...
@@ -1192,13 +1220,13 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
struct
btrfs_root
*
root
=
info
->
tree_root
;
struct
btrfs_root
*
root
=
info
->
tree_root
;
char
*
compress_type
;
char
*
compress_type
;
if
(
btrfs_test_opt
(
root
,
DEGRADED
))
if
(
btrfs_test_opt
(
info
,
DEGRADED
))
seq_puts
(
seq
,
",degraded"
);
seq_puts
(
seq
,
",degraded"
);
if
(
btrfs_test_opt
(
root
,
NODATASUM
))
if
(
btrfs_test_opt
(
info
,
NODATASUM
))
seq_puts
(
seq
,
",nodatasum"
);
seq_puts
(
seq
,
",nodatasum"
);
if
(
btrfs_test_opt
(
root
,
NODATACOW
))
if
(
btrfs_test_opt
(
info
,
NODATACOW
))
seq_puts
(
seq
,
",nodatacow"
);
seq_puts
(
seq
,
",nodatacow"
);
if
(
btrfs_test_opt
(
root
,
NOBARRIER
))
if
(
btrfs_test_opt
(
info
,
NOBARRIER
))
seq_puts
(
seq
,
",nobarrier"
);
seq_puts
(
seq
,
",nobarrier"
);
if
(
info
->
max_inline
!=
BTRFS_DEFAULT_MAX_INLINE
)
if
(
info
->
max_inline
!=
BTRFS_DEFAULT_MAX_INLINE
)
seq_printf
(
seq
,
",max_inline=%llu"
,
info
->
max_inline
);
seq_printf
(
seq
,
",max_inline=%llu"
,
info
->
max_inline
);
...
@@ -1207,56 +1235,56 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
...
@@ -1207,56 +1235,56 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
if
(
info
->
thread_pool_size
!=
min_t
(
unsigned
long
,
if
(
info
->
thread_pool_size
!=
min_t
(
unsigned
long
,
num_online_cpus
()
+
2
,
8
))
num_online_cpus
()
+
2
,
8
))
seq_printf
(
seq
,
",thread_pool=%d"
,
info
->
thread_pool_size
);
seq_printf
(
seq
,
",thread_pool=%d"
,
info
->
thread_pool_size
);
if
(
btrfs_test_opt
(
root
,
COMPRESS
))
{
if
(
btrfs_test_opt
(
info
,
COMPRESS
))
{
if
(
info
->
compress_type
==
BTRFS_COMPRESS_ZLIB
)
if
(
info
->
compress_type
==
BTRFS_COMPRESS_ZLIB
)
compress_type
=
"zlib"
;
compress_type
=
"zlib"
;
else
else
compress_type
=
"lzo"
;
compress_type
=
"lzo"
;
if
(
btrfs_test_opt
(
root
,
FORCE_COMPRESS
))
if
(
btrfs_test_opt
(
info
,
FORCE_COMPRESS
))
seq_printf
(
seq
,
",compress-force=%s"
,
compress_type
);
seq_printf
(
seq
,
",compress-force=%s"
,
compress_type
);
else
else
seq_printf
(
seq
,
",compress=%s"
,
compress_type
);
seq_printf
(
seq
,
",compress=%s"
,
compress_type
);
}
}
if
(
btrfs_test_opt
(
root
,
NOSSD
))
if
(
btrfs_test_opt
(
info
,
NOSSD
))
seq_puts
(
seq
,
",nossd"
);
seq_puts
(
seq
,
",nossd"
);
if
(
btrfs_test_opt
(
root
,
SSD_SPREAD
))
if
(
btrfs_test_opt
(
info
,
SSD_SPREAD
))
seq_puts
(
seq
,
",ssd_spread"
);
seq_puts
(
seq
,
",ssd_spread"
);
else
if
(
btrfs_test_opt
(
root
,
SSD
))
else
if
(
btrfs_test_opt
(
info
,
SSD
))
seq_puts
(
seq
,
",ssd"
);
seq_puts
(
seq
,
",ssd"
);
if
(
btrfs_test_opt
(
root
,
NOTREELOG
))
if
(
btrfs_test_opt
(
info
,
NOTREELOG
))
seq_puts
(
seq
,
",notreelog"
);
seq_puts
(
seq
,
",notreelog"
);
if
(
btrfs_test_opt
(
root
,
NOLOGREPLAY
))
if
(
btrfs_test_opt
(
info
,
NOLOGREPLAY
))
seq_puts
(
seq
,
",nologreplay"
);
seq_puts
(
seq
,
",nologreplay"
);
if
(
btrfs_test_opt
(
root
,
FLUSHONCOMMIT
))
if
(
btrfs_test_opt
(
info
,
FLUSHONCOMMIT
))
seq_puts
(
seq
,
",flushoncommit"
);
seq_puts
(
seq
,
",flushoncommit"
);
if
(
btrfs_test_opt
(
root
,
DISCARD
))
if
(
btrfs_test_opt
(
info
,
DISCARD
))
seq_puts
(
seq
,
",discard"
);
seq_puts
(
seq
,
",discard"
);
if
(
!
(
root
->
fs_info
->
sb
->
s_flags
&
MS_POSIXACL
))
if
(
!
(
root
->
fs_info
->
sb
->
s_flags
&
MS_POSIXACL
))
seq_puts
(
seq
,
",noacl"
);
seq_puts
(
seq
,
",noacl"
);
if
(
btrfs_test_opt
(
root
,
SPACE_CACHE
))
if
(
btrfs_test_opt
(
info
,
SPACE_CACHE
))
seq_puts
(
seq
,
",space_cache"
);
seq_puts
(
seq
,
",space_cache"
);
else
if
(
btrfs_test_opt
(
root
,
FREE_SPACE_TREE
))
else
if
(
btrfs_test_opt
(
info
,
FREE_SPACE_TREE
))
seq_puts
(
seq
,
",space_cache=v2"
);
seq_puts
(
seq
,
",space_cache=v2"
);
else
else
seq_puts
(
seq
,
",nospace_cache"
);
seq_puts
(
seq
,
",nospace_cache"
);
if
(
btrfs_test_opt
(
root
,
RESCAN_UUID_TREE
))
if
(
btrfs_test_opt
(
info
,
RESCAN_UUID_TREE
))
seq_puts
(
seq
,
",rescan_uuid_tree"
);
seq_puts
(
seq
,
",rescan_uuid_tree"
);
if
(
btrfs_test_opt
(
root
,
CLEAR_CACHE
))
if
(
btrfs_test_opt
(
info
,
CLEAR_CACHE
))
seq_puts
(
seq
,
",clear_cache"
);
seq_puts
(
seq
,
",clear_cache"
);
if
(
btrfs_test_opt
(
root
,
USER_SUBVOL_RM_ALLOWED
))
if
(
btrfs_test_opt
(
info
,
USER_SUBVOL_RM_ALLOWED
))
seq_puts
(
seq
,
",user_subvol_rm_allowed"
);
seq_puts
(
seq
,
",user_subvol_rm_allowed"
);
if
(
btrfs_test_opt
(
root
,
ENOSPC_DEBUG
))
if
(
btrfs_test_opt
(
info
,
ENOSPC_DEBUG
))
seq_puts
(
seq
,
",enospc_debug"
);
seq_puts
(
seq
,
",enospc_debug"
);
if
(
btrfs_test_opt
(
root
,
AUTO_DEFRAG
))
if
(
btrfs_test_opt
(
info
,
AUTO_DEFRAG
))
seq_puts
(
seq
,
",autodefrag"
);
seq_puts
(
seq
,
",autodefrag"
);
if
(
btrfs_test_opt
(
root
,
INODE_MAP_CACHE
))
if
(
btrfs_test_opt
(
info
,
INODE_MAP_CACHE
))
seq_puts
(
seq
,
",inode_cache"
);
seq_puts
(
seq
,
",inode_cache"
);
if
(
btrfs_test_opt
(
root
,
SKIP_BALANCE
))
if
(
btrfs_test_opt
(
info
,
SKIP_BALANCE
))
seq_puts
(
seq
,
",skip_balance"
);
seq_puts
(
seq
,
",skip_balance"
);
#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
if
(
btrfs_test_opt
(
root
,
CHECK_INTEGRITY_INCLUDING_EXTENT_DATA
))
if
(
btrfs_test_opt
(
info
,
CHECK_INTEGRITY_INCLUDING_EXTENT_DATA
))
seq_puts
(
seq
,
",check_int_data"
);
seq_puts
(
seq
,
",check_int_data"
);
else
if
(
btrfs_test_opt
(
root
,
CHECK_INTEGRITY
))
else
if
(
btrfs_test_opt
(
info
,
CHECK_INTEGRITY
))
seq_puts
(
seq
,
",check_int"
);
seq_puts
(
seq
,
",check_int"
);
if
(
info
->
check_integrity_print_mask
)
if
(
info
->
check_integrity_print_mask
)
seq_printf
(
seq
,
",check_int_print_mask=%d"
,
seq_printf
(
seq
,
",check_int_print_mask=%d"
,
...
@@ -1265,14 +1293,14 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
...
@@ -1265,14 +1293,14 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
if
(
info
->
metadata_ratio
)
if
(
info
->
metadata_ratio
)
seq_printf
(
seq
,
",metadata_ratio=%d"
,
seq_printf
(
seq
,
",metadata_ratio=%d"
,
info
->
metadata_ratio
);
info
->
metadata_ratio
);
if
(
btrfs_test_opt
(
root
,
PANIC_ON_FATAL_ERROR
))
if
(
btrfs_test_opt
(
info
,
PANIC_ON_FATAL_ERROR
))
seq_puts
(
seq
,
",fatal_errors=panic"
);
seq_puts
(
seq
,
",fatal_errors=panic"
);
if
(
info
->
commit_interval
!=
BTRFS_DEFAULT_COMMIT_INTERVAL
)
if
(
info
->
commit_interval
!=
BTRFS_DEFAULT_COMMIT_INTERVAL
)
seq_printf
(
seq
,
",commit=%d"
,
info
->
commit_interval
);
seq_printf
(
seq
,
",commit=%d"
,
info
->
commit_interval
);
#ifdef CONFIG_BTRFS_DEBUG
#ifdef CONFIG_BTRFS_DEBUG
if
(
btrfs_test_opt
(
root
,
FRAGMENT_DATA
))
if
(
btrfs_test_opt
(
info
,
FRAGMENT_DATA
))
seq_puts
(
seq
,
",fragment=data"
);
seq_puts
(
seq
,
",fragment=data"
);
if
(
btrfs_test_opt
(
root
,
FRAGMENT_METADATA
))
if
(
btrfs_test_opt
(
info
,
FRAGMENT_METADATA
))
seq_puts
(
seq
,
",fragment=metadata"
);
seq_puts
(
seq
,
",fragment=metadata"
);
#endif
#endif
seq_printf
(
seq
,
",subvolid=%llu"
,
seq_printf
(
seq
,
",subvolid=%llu"
,
...
@@ -2030,9 +2058,6 @@ static int btrfs_calc_avail_data_space(struct btrfs_root *root, u64 *free_bytes)
...
@@ -2030,9 +2058,6 @@ static int btrfs_calc_avail_data_space(struct btrfs_root *root, u64 *free_bytes)
* chunk).
* chunk).
*
*
* If metadata is exhausted, f_bavail will be 0.
* If metadata is exhausted, f_bavail will be 0.
*
* FIXME: not accurate for mixed block groups, total and free/used are ok,
* available appears slightly larger.
*/
*/
static
int
btrfs_statfs
(
struct
dentry
*
dentry
,
struct
kstatfs
*
buf
)
static
int
btrfs_statfs
(
struct
dentry
*
dentry
,
struct
kstatfs
*
buf
)
{
{
...
@@ -2319,49 +2344,6 @@ static void btrfs_print_mod_info(void)
...
@@ -2319,49 +2344,6 @@ static void btrfs_print_mod_info(void)
btrfs_crc32c_impl
());
btrfs_crc32c_impl
());
}
}
static
int
btrfs_run_sanity_tests
(
void
)
{
int
ret
,
i
;
u32
sectorsize
,
nodesize
;
u32
test_sectorsize
[]
=
{
PAGE_SIZE
,
};
ret
=
btrfs_init_test_fs
();
if
(
ret
)
return
ret
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
test_sectorsize
);
i
++
)
{
sectorsize
=
test_sectorsize
[
i
];
for
(
nodesize
=
sectorsize
;
nodesize
<=
BTRFS_MAX_METADATA_BLOCKSIZE
;
nodesize
<<=
1
)
{
pr_info
(
"BTRFS: selftest: sectorsize: %u nodesize: %u
\n
"
,
sectorsize
,
nodesize
);
ret
=
btrfs_test_free_space_cache
(
sectorsize
,
nodesize
);
if
(
ret
)
goto
out
;
ret
=
btrfs_test_extent_buffer_operations
(
sectorsize
,
nodesize
);
if
(
ret
)
goto
out
;
ret
=
btrfs_test_extent_io
(
sectorsize
,
nodesize
);
if
(
ret
)
goto
out
;
ret
=
btrfs_test_inodes
(
sectorsize
,
nodesize
);
if
(
ret
)
goto
out
;
ret
=
btrfs_test_qgroups
(
sectorsize
,
nodesize
);
if
(
ret
)
goto
out
;
ret
=
btrfs_test_free_space_tree
(
sectorsize
,
nodesize
);
if
(
ret
)
goto
out
;
}
}
out:
btrfs_destroy_test_fs
();
return
ret
;
}
static
int
__init
init_btrfs_fs
(
void
)
static
int
__init
init_btrfs_fs
(
void
)
{
{
int
err
;
int
err
;
...
...
fs/btrfs/sysfs.c
浏览文件 @
023a824f
...
@@ -326,6 +326,7 @@ SPACE_INFO_ATTR(bytes_used);
...
@@ -326,6 +326,7 @@ SPACE_INFO_ATTR(bytes_used);
SPACE_INFO_ATTR
(
bytes_pinned
);
SPACE_INFO_ATTR
(
bytes_pinned
);
SPACE_INFO_ATTR
(
bytes_reserved
);
SPACE_INFO_ATTR
(
bytes_reserved
);
SPACE_INFO_ATTR
(
bytes_may_use
);
SPACE_INFO_ATTR
(
bytes_may_use
);
SPACE_INFO_ATTR
(
bytes_readonly
);
SPACE_INFO_ATTR
(
disk_used
);
SPACE_INFO_ATTR
(
disk_used
);
SPACE_INFO_ATTR
(
disk_total
);
SPACE_INFO_ATTR
(
disk_total
);
BTRFS_ATTR
(
total_bytes_pinned
,
btrfs_space_info_show_total_bytes_pinned
);
BTRFS_ATTR
(
total_bytes_pinned
,
btrfs_space_info_show_total_bytes_pinned
);
...
@@ -337,6 +338,7 @@ static struct attribute *space_info_attrs[] = {
...
@@ -337,6 +338,7 @@ static struct attribute *space_info_attrs[] = {
BTRFS_ATTR_PTR
(
bytes_pinned
),
BTRFS_ATTR_PTR
(
bytes_pinned
),
BTRFS_ATTR_PTR
(
bytes_reserved
),
BTRFS_ATTR_PTR
(
bytes_reserved
),
BTRFS_ATTR_PTR
(
bytes_may_use
),
BTRFS_ATTR_PTR
(
bytes_may_use
),
BTRFS_ATTR_PTR
(
bytes_readonly
),
BTRFS_ATTR_PTR
(
disk_used
),
BTRFS_ATTR_PTR
(
disk_used
),
BTRFS_ATTR_PTR
(
disk_total
),
BTRFS_ATTR_PTR
(
disk_total
),
BTRFS_ATTR_PTR
(
total_bytes_pinned
),
BTRFS_ATTR_PTR
(
total_bytes_pinned
),
...
...
fs/btrfs/tests/btrfs-tests.c
浏览文件 @
023a824f
...
@@ -54,7 +54,7 @@ struct inode *btrfs_new_test_inode(void)
...
@@ -54,7 +54,7 @@ struct inode *btrfs_new_test_inode(void)
return
new_inode
(
test_mnt
->
mnt_sb
);
return
new_inode
(
test_mnt
->
mnt_sb
);
}
}
int
btrfs_init_test_fs
(
void
)
static
int
btrfs_init_test_fs
(
void
)
{
{
int
ret
;
int
ret
;
...
@@ -73,7 +73,7 @@ int btrfs_init_test_fs(void)
...
@@ -73,7 +73,7 @@ int btrfs_init_test_fs(void)
return
0
;
return
0
;
}
}
void
btrfs_destroy_test_fs
(
void
)
static
void
btrfs_destroy_test_fs
(
void
)
{
{
kern_unmount
(
test_mnt
);
kern_unmount
(
test_mnt
);
unregister_filesystem
(
&
test_type
);
unregister_filesystem
(
&
test_type
);
...
@@ -128,14 +128,27 @@ struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(void)
...
@@ -128,14 +128,27 @@ struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(void)
extent_io_tree_init
(
&
fs_info
->
freed_extents
[
0
],
NULL
);
extent_io_tree_init
(
&
fs_info
->
freed_extents
[
0
],
NULL
);
extent_io_tree_init
(
&
fs_info
->
freed_extents
[
1
],
NULL
);
extent_io_tree_init
(
&
fs_info
->
freed_extents
[
1
],
NULL
);
fs_info
->
pinned_extents
=
&
fs_info
->
freed_extents
[
0
];
fs_info
->
pinned_extents
=
&
fs_info
->
freed_extents
[
0
];
set_bit
(
BTRFS_FS_STATE_DUMMY_FS_INFO
,
&
fs_info
->
fs_state
);
test_mnt
->
mnt_sb
->
s_fs_info
=
fs_info
;
return
fs_info
;
return
fs_info
;
}
}
static
void
btrfs_free_dummy_fs_info
(
struct
btrfs_fs_info
*
fs_info
)
void
btrfs_free_dummy_fs_info
(
struct
btrfs_fs_info
*
fs_info
)
{
{
struct
radix_tree_iter
iter
;
struct
radix_tree_iter
iter
;
void
**
slot
;
void
**
slot
;
if
(
!
fs_info
)
return
;
if
(
WARN_ON
(
!
test_bit
(
BTRFS_FS_STATE_DUMMY_FS_INFO
,
&
fs_info
->
fs_state
)))
return
;
test_mnt
->
mnt_sb
->
s_fs_info
=
NULL
;
spin_lock
(
&
fs_info
->
buffer_lock
);
spin_lock
(
&
fs_info
->
buffer_lock
);
radix_tree_for_each_slot
(
slot
,
&
fs_info
->
buffer_radix
,
&
iter
,
0
)
{
radix_tree_for_each_slot
(
slot
,
&
fs_info
->
buffer_radix
,
&
iter
,
0
)
{
struct
extent_buffer
*
eb
;
struct
extent_buffer
*
eb
;
...
@@ -167,10 +180,11 @@ void btrfs_free_dummy_root(struct btrfs_root *root)
...
@@ -167,10 +180,11 @@ void btrfs_free_dummy_root(struct btrfs_root *root)
{
{
if
(
!
root
)
if
(
!
root
)
return
;
return
;
/* Will be freed by btrfs_free_fs_roots */
if
(
WARN_ON
(
test_bit
(
BTRFS_ROOT_IN_RADIX
,
&
root
->
state
)))
return
;
if
(
root
->
node
)
if
(
root
->
node
)
free_extent_buffer
(
root
->
node
);
free_extent_buffer
(
root
->
node
);
if
(
root
->
fs_info
)
btrfs_free_dummy_fs_info
(
root
->
fs_info
);
kfree
(
root
);
kfree
(
root
);
}
}
...
@@ -220,3 +234,46 @@ void btrfs_init_dummy_trans(struct btrfs_trans_handle *trans)
...
@@ -220,3 +234,46 @@ void btrfs_init_dummy_trans(struct btrfs_trans_handle *trans)
INIT_LIST_HEAD
(
&
trans
->
qgroup_ref_list
);
INIT_LIST_HEAD
(
&
trans
->
qgroup_ref_list
);
trans
->
type
=
__TRANS_DUMMY
;
trans
->
type
=
__TRANS_DUMMY
;
}
}
int
btrfs_run_sanity_tests
(
void
)
{
int
ret
,
i
;
u32
sectorsize
,
nodesize
;
u32
test_sectorsize
[]
=
{
PAGE_SIZE
,
};
ret
=
btrfs_init_test_fs
();
if
(
ret
)
return
ret
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
test_sectorsize
);
i
++
)
{
sectorsize
=
test_sectorsize
[
i
];
for
(
nodesize
=
sectorsize
;
nodesize
<=
BTRFS_MAX_METADATA_BLOCKSIZE
;
nodesize
<<=
1
)
{
pr_info
(
"BTRFS: selftest: sectorsize: %u nodesize: %u
\n
"
,
sectorsize
,
nodesize
);
ret
=
btrfs_test_free_space_cache
(
sectorsize
,
nodesize
);
if
(
ret
)
goto
out
;
ret
=
btrfs_test_extent_buffer_operations
(
sectorsize
,
nodesize
);
if
(
ret
)
goto
out
;
ret
=
btrfs_test_extent_io
(
sectorsize
,
nodesize
);
if
(
ret
)
goto
out
;
ret
=
btrfs_test_inodes
(
sectorsize
,
nodesize
);
if
(
ret
)
goto
out
;
ret
=
btrfs_test_qgroups
(
sectorsize
,
nodesize
);
if
(
ret
)
goto
out
;
ret
=
btrfs_test_free_space_tree
(
sectorsize
,
nodesize
);
if
(
ret
)
goto
out
;
}
}
out:
btrfs_destroy_test_fs
();
return
ret
;
}
fs/btrfs/tests/btrfs-tests.h
浏览文件 @
023a824f
...
@@ -20,57 +20,29 @@
...
@@ -20,57 +20,29 @@
#define __BTRFS_TESTS
#define __BTRFS_TESTS
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
int
btrfs_run_sanity_tests
(
void
);
#define test_msg(fmt, ...) pr_info("BTRFS: selftest: " fmt, ##__VA_ARGS__)
#define test_msg(fmt, ...) pr_info("BTRFS: selftest: " fmt, ##__VA_ARGS__)
struct
btrfs_root
;
struct
btrfs_root
;
struct
btrfs_trans_handle
;
struct
btrfs_trans_handle
;
int
btrfs_test_free_space_cache
(
u32
sectorsize
,
u32
nodesize
);
int
btrfs_test_extent_buffer_operations
(
u32
sectorsize
,
u32
nodesize
);
int
btrfs_test_extent_buffer_operations
(
u32
sectorsize
,
u32
nodesize
);
int
btrfs_test_free_space_cache
(
u32
sectorsize
,
u32
nodesize
);
int
btrfs_test_extent_io
(
u32
sectorsize
,
u32
nodesize
);
int
btrfs_test_extent_io
(
u32
sectorsize
,
u32
nodesize
);
int
btrfs_test_inodes
(
u32
sectorsize
,
u32
nodesize
);
int
btrfs_test_inodes
(
u32
sectorsize
,
u32
nodesize
);
int
btrfs_test_qgroups
(
u32
sectorsize
,
u32
nodesize
);
int
btrfs_test_qgroups
(
u32
sectorsize
,
u32
nodesize
);
int
btrfs_test_free_space_tree
(
u32
sectorsize
,
u32
nodesize
);
int
btrfs_test_free_space_tree
(
u32
sectorsize
,
u32
nodesize
);
int
btrfs_init_test_fs
(
void
);
void
btrfs_destroy_test_fs
(
void
);
struct
inode
*
btrfs_new_test_inode
(
void
);
struct
inode
*
btrfs_new_test_inode
(
void
);
struct
btrfs_fs_info
*
btrfs_alloc_dummy_fs_info
(
void
);
struct
btrfs_fs_info
*
btrfs_alloc_dummy_fs_info
(
void
);
void
btrfs_free_dummy_fs_info
(
struct
btrfs_fs_info
*
fs_info
);
void
btrfs_free_dummy_root
(
struct
btrfs_root
*
root
);
void
btrfs_free_dummy_root
(
struct
btrfs_root
*
root
);
struct
btrfs_block_group_cache
*
struct
btrfs_block_group_cache
*
btrfs_alloc_dummy_block_group
(
unsigned
long
length
,
u32
sectorsize
);
btrfs_alloc_dummy_block_group
(
unsigned
long
length
,
u32
sectorsize
);
void
btrfs_free_dummy_block_group
(
struct
btrfs_block_group_cache
*
cache
);
void
btrfs_free_dummy_block_group
(
struct
btrfs_block_group_cache
*
cache
);
void
btrfs_init_dummy_trans
(
struct
btrfs_trans_handle
*
trans
);
void
btrfs_init_dummy_trans
(
struct
btrfs_trans_handle
*
trans
);
#else
#else
static
inline
int
btrfs_test_free_space_cache
(
u32
sectorsize
,
u32
nodesize
)
static
inline
int
btrfs_run_sanity_tests
(
void
)
{
return
0
;
}
static
inline
int
btrfs_test_extent_buffer_operations
(
u32
sectorsize
,
u32
nodesize
)
{
return
0
;
}
static
inline
int
btrfs_init_test_fs
(
void
)
{
return
0
;
}
static
inline
void
btrfs_destroy_test_fs
(
void
)
{
}
static
inline
int
btrfs_test_extent_io
(
u32
sectorsize
,
u32
nodesize
)
{
return
0
;
}
static
inline
int
btrfs_test_inodes
(
u32
sectorsize
,
u32
nodesize
)
{
return
0
;
}
static
inline
int
btrfs_test_qgroups
(
u32
sectorsize
,
u32
nodesize
)
{
return
0
;
}
static
inline
int
btrfs_test_free_space_tree
(
u32
sectorsize
,
u32
nodesize
)
{
{
return
0
;
return
0
;
}
}
...
...
fs/btrfs/tests/extent-buffer-tests.c
浏览文件 @
023a824f
...
@@ -24,8 +24,9 @@
...
@@ -24,8 +24,9 @@
static
int
test_btrfs_split_item
(
u32
sectorsize
,
u32
nodesize
)
static
int
test_btrfs_split_item
(
u32
sectorsize
,
u32
nodesize
)
{
{
struct
btrfs_path
*
path
;
struct
btrfs_fs_info
*
fs_info
;
struct
btrfs_root
*
root
;
struct
btrfs_path
*
path
=
NULL
;
struct
btrfs_root
*
root
=
NULL
;
struct
extent_buffer
*
eb
;
struct
extent_buffer
*
eb
;
struct
btrfs_item
*
item
;
struct
btrfs_item
*
item
;
char
*
value
=
"mary had a little lamb"
;
char
*
value
=
"mary had a little lamb"
;
...
@@ -40,17 +41,24 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
...
@@ -40,17 +41,24 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
test_msg
(
"Running btrfs_split_item tests
\n
"
);
test_msg
(
"Running btrfs_split_item tests
\n
"
);
root
=
btrfs_alloc_dummy_root
(
sectorsize
,
nodesize
);
fs_info
=
btrfs_alloc_dummy_fs_info
();
if
(
!
fs_info
)
{
test_msg
(
"Could not allocate fs_info
\n
"
);
return
-
ENOMEM
;
}
root
=
btrfs_alloc_dummy_root
(
fs_info
,
sectorsize
,
nodesize
);
if
(
IS_ERR
(
root
))
{
if
(
IS_ERR
(
root
))
{
test_msg
(
"Could not allocate root
\n
"
);
test_msg
(
"Could not allocate root
\n
"
);
return
PTR_ERR
(
root
);
ret
=
PTR_ERR
(
root
);
goto
out
;
}
}
path
=
btrfs_alloc_path
();
path
=
btrfs_alloc_path
();
if
(
!
path
)
{
if
(
!
path
)
{
test_msg
(
"Could not allocate path
\n
"
);
test_msg
(
"Could not allocate path
\n
"
);
kfree
(
root
)
;
ret
=
-
ENOMEM
;
return
-
ENOMEM
;
goto
out
;
}
}
path
->
nodes
[
0
]
=
eb
=
alloc_dummy_extent_buffer
(
NULL
,
nodesize
,
path
->
nodes
[
0
]
=
eb
=
alloc_dummy_extent_buffer
(
NULL
,
nodesize
,
...
@@ -219,7 +227,8 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
...
@@ -219,7 +227,8 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
}
}
out:
out:
btrfs_free_path
(
path
);
btrfs_free_path
(
path
);
kfree
(
root
);
btrfs_free_dummy_root
(
root
);
btrfs_free_dummy_fs_info
(
fs_info
);
return
ret
;
return
ret
;
}
}
...
...
fs/btrfs/tests/free-space-tests.c
浏览文件 @
023a824f
...
@@ -837,6 +837,7 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache,
...
@@ -837,6 +837,7 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache,
int
btrfs_test_free_space_cache
(
u32
sectorsize
,
u32
nodesize
)
int
btrfs_test_free_space_cache
(
u32
sectorsize
,
u32
nodesize
)
{
{
struct
btrfs_fs_info
*
fs_info
;
struct
btrfs_block_group_cache
*
cache
;
struct
btrfs_block_group_cache
*
cache
;
struct
btrfs_root
*
root
=
NULL
;
struct
btrfs_root
*
root
=
NULL
;
int
ret
=
-
ENOMEM
;
int
ret
=
-
ENOMEM
;
...
@@ -855,15 +856,17 @@ int btrfs_test_free_space_cache(u32 sectorsize, u32 nodesize)
...
@@ -855,15 +856,17 @@ int btrfs_test_free_space_cache(u32 sectorsize, u32 nodesize)
return
0
;
return
0
;
}
}
root
=
btrfs_alloc_dummy_root
(
sectorsize
,
nodesize
);
fs_info
=
btrfs_alloc_dummy_fs_info
(
);
if
(
IS_ERR
(
root
)
)
{
if
(
!
fs_info
)
{
ret
=
PTR_ERR
(
root
)
;
ret
=
-
ENOMEM
;
goto
out
;
goto
out
;
}
}
root
->
fs_info
=
btrfs_alloc_dummy_fs_info
();
root
=
btrfs_alloc_dummy_root
(
fs_info
,
sectorsize
,
nodesize
);
if
(
!
root
->
fs_info
)
if
(
IS_ERR
(
root
))
{
ret
=
PTR_ERR
(
root
);
goto
out
;
goto
out
;
}
root
->
fs_info
->
extent_root
=
root
;
root
->
fs_info
->
extent_root
=
root
;
cache
->
fs_info
=
root
->
fs_info
;
cache
->
fs_info
=
root
->
fs_info
;
...
@@ -882,6 +885,7 @@ int btrfs_test_free_space_cache(u32 sectorsize, u32 nodesize)
...
@@ -882,6 +885,7 @@ int btrfs_test_free_space_cache(u32 sectorsize, u32 nodesize)
out:
out:
btrfs_free_dummy_block_group
(
cache
);
btrfs_free_dummy_block_group
(
cache
);
btrfs_free_dummy_root
(
root
);
btrfs_free_dummy_root
(
root
);
btrfs_free_dummy_fs_info
(
fs_info
);
test_msg
(
"Free space cache tests finished
\n
"
);
test_msg
(
"Free space cache tests finished
\n
"
);
return
ret
;
return
ret
;
}
}
fs/btrfs/tests/free-space-tree-tests.c
浏览文件 @
023a824f
...
@@ -443,23 +443,24 @@ typedef int (*test_func_t)(struct btrfs_trans_handle *,
...
@@ -443,23 +443,24 @@ typedef int (*test_func_t)(struct btrfs_trans_handle *,
static
int
run_test
(
test_func_t
test_func
,
int
bitmaps
,
static
int
run_test
(
test_func_t
test_func
,
int
bitmaps
,
u32
sectorsize
,
u32
nodesize
)
u32
sectorsize
,
u32
nodesize
)
{
{
struct
btrfs_fs_info
*
fs_info
;
struct
btrfs_root
*
root
=
NULL
;
struct
btrfs_root
*
root
=
NULL
;
struct
btrfs_block_group_cache
*
cache
=
NULL
;
struct
btrfs_block_group_cache
*
cache
=
NULL
;
struct
btrfs_trans_handle
trans
;
struct
btrfs_trans_handle
trans
;
struct
btrfs_path
*
path
=
NULL
;
struct
btrfs_path
*
path
=
NULL
;
int
ret
;
int
ret
;
root
=
btrfs_alloc_dummy_root
(
sectorsize
,
nodesize
);
fs_info
=
btrfs_alloc_dummy_fs_info
(
);
if
(
IS_ERR
(
root
)
)
{
if
(
!
fs_info
)
{
test_msg
(
"Couldn't allocate dummy
root
\n
"
);
test_msg
(
"Couldn't allocate dummy
fs info
\n
"
);
ret
=
PTR_ERR
(
root
)
;
ret
=
-
ENOMEM
;
goto
out
;
goto
out
;
}
}
root
->
fs_info
=
btrfs_alloc_dummy_fs_info
(
);
root
=
btrfs_alloc_dummy_root
(
fs_info
,
sectorsize
,
nodesize
);
if
(
!
root
->
fs_info
)
{
if
(
IS_ERR
(
root
)
)
{
test_msg
(
"Couldn't allocate dummy
fs info
\n
"
);
test_msg
(
"Couldn't allocate dummy
root
\n
"
);
ret
=
-
ENOMEM
;
ret
=
PTR_ERR
(
root
)
;
goto
out
;
goto
out
;
}
}
...
@@ -534,6 +535,7 @@ static int run_test(test_func_t test_func, int bitmaps,
...
@@ -534,6 +535,7 @@ static int run_test(test_func_t test_func, int bitmaps,
btrfs_free_path
(
path
);
btrfs_free_path
(
path
);
btrfs_free_dummy_block_group
(
cache
);
btrfs_free_dummy_block_group
(
cache
);
btrfs_free_dummy_root
(
root
);
btrfs_free_dummy_root
(
root
);
btrfs_free_dummy_fs_info
(
fs_info
);
return
ret
;
return
ret
;
}
}
...
...
fs/btrfs/tests/inode-tests.c
浏览文件 @
023a824f
...
@@ -230,6 +230,7 @@ static unsigned long vacancy_only = 0;
...
@@ -230,6 +230,7 @@ static unsigned long vacancy_only = 0;
static
noinline
int
test_btrfs_get_extent
(
u32
sectorsize
,
u32
nodesize
)
static
noinline
int
test_btrfs_get_extent
(
u32
sectorsize
,
u32
nodesize
)
{
{
struct
btrfs_fs_info
*
fs_info
=
NULL
;
struct
inode
*
inode
=
NULL
;
struct
inode
*
inode
=
NULL
;
struct
btrfs_root
*
root
=
NULL
;
struct
btrfs_root
*
root
=
NULL
;
struct
extent_map
*
em
=
NULL
;
struct
extent_map
*
em
=
NULL
;
...
@@ -248,19 +249,15 @@ static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
...
@@ -248,19 +249,15 @@ static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
BTRFS_I
(
inode
)
->
location
.
objectid
=
BTRFS_FIRST_FREE_OBJECTID
;
BTRFS_I
(
inode
)
->
location
.
objectid
=
BTRFS_FIRST_FREE_OBJECTID
;
BTRFS_I
(
inode
)
->
location
.
offset
=
0
;
BTRFS_I
(
inode
)
->
location
.
offset
=
0
;
root
=
btrfs_alloc_dummy_root
(
sectorsize
,
nodesize
);
fs_info
=
btrfs_alloc_dummy_fs_info
(
);
if
(
IS_ERR
(
root
)
)
{
if
(
!
fs_info
)
{
test_msg
(
"Couldn't allocate
root
\n
"
);
test_msg
(
"Couldn't allocate
dummy fs info
\n
"
);
goto
out
;
goto
out
;
}
}
/*
root
=
btrfs_alloc_dummy_root
(
fs_info
,
sectorsize
,
nodesize
);
* We do this since btrfs_get_extent wants to assign em->bdev to
if
(
IS_ERR
(
root
))
{
* root->fs_info->fs_devices->latest_bdev.
test_msg
(
"Couldn't allocate root
\n
"
);
*/
root
->
fs_info
=
btrfs_alloc_dummy_fs_info
();
if
(
!
root
->
fs_info
)
{
test_msg
(
"Couldn't allocate dummy fs info
\n
"
);
goto
out
;
goto
out
;
}
}
...
@@ -835,11 +832,13 @@ static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
...
@@ -835,11 +832,13 @@ static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
free_extent_map
(
em
);
free_extent_map
(
em
);
iput
(
inode
);
iput
(
inode
);
btrfs_free_dummy_root
(
root
);
btrfs_free_dummy_root
(
root
);
btrfs_free_dummy_fs_info
(
fs_info
);
return
ret
;
return
ret
;
}
}
static
int
test_hole_first
(
u32
sectorsize
,
u32
nodesize
)
static
int
test_hole_first
(
u32
sectorsize
,
u32
nodesize
)
{
{
struct
btrfs_fs_info
*
fs_info
=
NULL
;
struct
inode
*
inode
=
NULL
;
struct
inode
*
inode
=
NULL
;
struct
btrfs_root
*
root
=
NULL
;
struct
btrfs_root
*
root
=
NULL
;
struct
extent_map
*
em
=
NULL
;
struct
extent_map
*
em
=
NULL
;
...
@@ -855,15 +854,15 @@ static int test_hole_first(u32 sectorsize, u32 nodesize)
...
@@ -855,15 +854,15 @@ static int test_hole_first(u32 sectorsize, u32 nodesize)
BTRFS_I
(
inode
)
->
location
.
objectid
=
BTRFS_FIRST_FREE_OBJECTID
;
BTRFS_I
(
inode
)
->
location
.
objectid
=
BTRFS_FIRST_FREE_OBJECTID
;
BTRFS_I
(
inode
)
->
location
.
offset
=
0
;
BTRFS_I
(
inode
)
->
location
.
offset
=
0
;
root
=
btrfs_alloc_dummy_root
(
sectorsize
,
nodesize
);
fs_info
=
btrfs_alloc_dummy_fs_info
(
);
if
(
IS_ERR
(
root
)
)
{
if
(
!
fs_info
)
{
test_msg
(
"Couldn't allocate
root
\n
"
);
test_msg
(
"Couldn't allocate
dummy fs info
\n
"
);
goto
out
;
goto
out
;
}
}
root
->
fs_info
=
btrfs_alloc_dummy_fs_info
(
);
root
=
btrfs_alloc_dummy_root
(
fs_info
,
sectorsize
,
nodesize
);
if
(
!
root
->
fs_info
)
{
if
(
IS_ERR
(
root
)
)
{
test_msg
(
"Couldn't allocate
dummy fs info
\n
"
);
test_msg
(
"Couldn't allocate
root
\n
"
);
goto
out
;
goto
out
;
}
}
...
@@ -934,11 +933,13 @@ static int test_hole_first(u32 sectorsize, u32 nodesize)
...
@@ -934,11 +933,13 @@ static int test_hole_first(u32 sectorsize, u32 nodesize)
free_extent_map
(
em
);
free_extent_map
(
em
);
iput
(
inode
);
iput
(
inode
);
btrfs_free_dummy_root
(
root
);
btrfs_free_dummy_root
(
root
);
btrfs_free_dummy_fs_info
(
fs_info
);
return
ret
;
return
ret
;
}
}
static
int
test_extent_accounting
(
u32
sectorsize
,
u32
nodesize
)
static
int
test_extent_accounting
(
u32
sectorsize
,
u32
nodesize
)
{
{
struct
btrfs_fs_info
*
fs_info
=
NULL
;
struct
inode
*
inode
=
NULL
;
struct
inode
*
inode
=
NULL
;
struct
btrfs_root
*
root
=
NULL
;
struct
btrfs_root
*
root
=
NULL
;
int
ret
=
-
ENOMEM
;
int
ret
=
-
ENOMEM
;
...
@@ -949,15 +950,15 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
...
@@ -949,15 +950,15 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
return
ret
;
return
ret
;
}
}
root
=
btrfs_alloc_dummy_root
(
sectorsize
,
nodesize
);
fs_info
=
btrfs_alloc_dummy_fs_info
(
);
if
(
IS_ERR
(
root
)
)
{
if
(
!
fs_info
)
{
test_msg
(
"Couldn't allocate
root
\n
"
);
test_msg
(
"Couldn't allocate
dummy fs info
\n
"
);
goto
out
;
goto
out
;
}
}
root
->
fs_info
=
btrfs_alloc_dummy_fs_info
(
);
root
=
btrfs_alloc_dummy_root
(
fs_info
,
sectorsize
,
nodesize
);
if
(
!
root
->
fs_info
)
{
if
(
IS_ERR
(
root
)
)
{
test_msg
(
"Couldn't allocate
dummy fs info
\n
"
);
test_msg
(
"Couldn't allocate
root
\n
"
);
goto
out
;
goto
out
;
}
}
...
@@ -1132,6 +1133,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
...
@@ -1132,6 +1133,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
NULL
,
GFP_KERNEL
);
NULL
,
GFP_KERNEL
);
iput
(
inode
);
iput
(
inode
);
btrfs_free_dummy_root
(
root
);
btrfs_free_dummy_root
(
root
);
btrfs_free_dummy_fs_info
(
fs_info
);
return
ret
;
return
ret
;
}
}
...
...
fs/btrfs/tests/qgroup-tests.c
浏览文件 @
023a824f
...
@@ -453,22 +453,24 @@ static int test_multiple_refs(struct btrfs_root *root,
...
@@ -453,22 +453,24 @@ static int test_multiple_refs(struct btrfs_root *root,
int
btrfs_test_qgroups
(
u32
sectorsize
,
u32
nodesize
)
int
btrfs_test_qgroups
(
u32
sectorsize
,
u32
nodesize
)
{
{
struct
btrfs_fs_info
*
fs_info
=
NULL
;
struct
btrfs_root
*
root
;
struct
btrfs_root
*
root
;
struct
btrfs_root
*
tmp_root
;
struct
btrfs_root
*
tmp_root
;
int
ret
=
0
;
int
ret
=
0
;
root
=
btrfs_alloc_dummy_root
(
sectorsize
,
nodesize
);
fs_info
=
btrfs_alloc_dummy_fs_info
(
);
if
(
IS_ERR
(
root
)
)
{
if
(
!
fs_info
)
{
test_msg
(
"Couldn't allocate
root
\n
"
);
test_msg
(
"Couldn't allocate
dummy fs info
\n
"
);
return
PTR_ERR
(
root
)
;
return
-
ENOMEM
;
}
}
root
->
fs_info
=
btrfs_alloc_dummy_fs_info
(
);
root
=
btrfs_alloc_dummy_root
(
fs_info
,
sectorsize
,
nodesize
);
if
(
!
root
->
fs_info
)
{
if
(
IS_ERR
(
root
)
)
{
test_msg
(
"Couldn't allocate
dummy fs info
\n
"
);
test_msg
(
"Couldn't allocate
root
\n
"
);
ret
=
-
ENOMEM
;
ret
=
PTR_ERR
(
root
)
;
goto
out
;
goto
out
;
}
}
/* We are using this root as our extent root */
/* We are using this root as our extent root */
root
->
fs_info
->
extent_root
=
root
;
root
->
fs_info
->
extent_root
=
root
;
...
@@ -495,7 +497,7 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
...
@@ -495,7 +497,7 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
btrfs_set_header_nritems
(
root
->
node
,
0
);
btrfs_set_header_nritems
(
root
->
node
,
0
);
root
->
alloc_bytenr
+=
2
*
nodesize
;
root
->
alloc_bytenr
+=
2
*
nodesize
;
tmp_root
=
btrfs_alloc_dummy_root
(
sectorsize
,
nodesize
);
tmp_root
=
btrfs_alloc_dummy_root
(
fs_info
,
sectorsize
,
nodesize
);
if
(
IS_ERR
(
tmp_root
))
{
if
(
IS_ERR
(
tmp_root
))
{
test_msg
(
"Couldn't allocate a fs root
\n
"
);
test_msg
(
"Couldn't allocate a fs root
\n
"
);
ret
=
PTR_ERR
(
tmp_root
);
ret
=
PTR_ERR
(
tmp_root
);
...
@@ -510,7 +512,7 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
...
@@ -510,7 +512,7 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
goto
out
;
goto
out
;
}
}
tmp_root
=
btrfs_alloc_dummy_root
(
sectorsize
,
nodesize
);
tmp_root
=
btrfs_alloc_dummy_root
(
fs_info
,
sectorsize
,
nodesize
);
if
(
IS_ERR
(
tmp_root
))
{
if
(
IS_ERR
(
tmp_root
))
{
test_msg
(
"Couldn't allocate a fs root
\n
"
);
test_msg
(
"Couldn't allocate a fs root
\n
"
);
ret
=
PTR_ERR
(
tmp_root
);
ret
=
PTR_ERR
(
tmp_root
);
...
@@ -531,5 +533,6 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
...
@@ -531,5 +533,6 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
ret
=
test_multiple_refs
(
root
,
sectorsize
,
nodesize
);
ret
=
test_multiple_refs
(
root
,
sectorsize
,
nodesize
);
out:
out:
btrfs_free_dummy_root
(
root
);
btrfs_free_dummy_root
(
root
);
btrfs_free_dummy_fs_info
(
fs_info
);
return
ret
;
return
ret
;
}
}
fs/btrfs/transaction.c
浏览文件 @
023a824f
...
@@ -561,6 +561,7 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,
...
@@ -561,6 +561,7 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,
h
->
transaction
=
cur_trans
;
h
->
transaction
=
cur_trans
;
h
->
root
=
root
;
h
->
root
=
root
;
h
->
use_count
=
1
;
h
->
use_count
=
1
;
h
->
fs_info
=
root
->
fs_info
;
h
->
type
=
type
;
h
->
type
=
type
;
h
->
can_flush_pending_bgs
=
true
;
h
->
can_flush_pending_bgs
=
true
;
...
@@ -1491,7 +1492,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
...
@@ -1491,7 +1492,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
goto
dir_item_existed
;
goto
dir_item_existed
;
}
else
if
(
IS_ERR
(
dir_item
))
{
}
else
if
(
IS_ERR
(
dir_item
))
{
ret
=
PTR_ERR
(
dir_item
);
ret
=
PTR_ERR
(
dir_item
);
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
btrfs_release_path
(
path
);
btrfs_release_path
(
path
);
...
@@ -1504,7 +1505,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
...
@@ -1504,7 +1505,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
*/
*/
ret
=
btrfs_run_delayed_items
(
trans
,
root
);
ret
=
btrfs_run_delayed_items
(
trans
,
root
);
if
(
ret
)
{
/* Transaction aborted */
if
(
ret
)
{
/* Transaction aborted */
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
...
@@ -1543,7 +1544,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
...
@@ -1543,7 +1544,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
if
(
ret
)
{
if
(
ret
)
{
btrfs_tree_unlock
(
old
);
btrfs_tree_unlock
(
old
);
free_extent_buffer
(
old
);
free_extent_buffer
(
old
);
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
...
@@ -1554,7 +1555,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
...
@@ -1554,7 +1555,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
btrfs_tree_unlock
(
old
);
btrfs_tree_unlock
(
old
);
free_extent_buffer
(
old
);
free_extent_buffer
(
old
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
/* see comments in should_cow_block() */
/* see comments in should_cow_block() */
...
@@ -1568,7 +1569,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
...
@@ -1568,7 +1569,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
btrfs_tree_unlock
(
tmp
);
btrfs_tree_unlock
(
tmp
);
free_extent_buffer
(
tmp
);
free_extent_buffer
(
tmp
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
...
@@ -1580,7 +1581,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
...
@@ -1580,7 +1581,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
btrfs_ino
(
parent_inode
),
index
,
btrfs_ino
(
parent_inode
),
index
,
dentry
->
d_name
.
name
,
dentry
->
d_name
.
len
);
dentry
->
d_name
.
name
,
dentry
->
d_name
.
len
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
...
@@ -1588,19 +1589,19 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
...
@@ -1588,19 +1589,19 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
pending
->
snap
=
btrfs_read_fs_root_no_name
(
root
->
fs_info
,
&
key
);
pending
->
snap
=
btrfs_read_fs_root_no_name
(
root
->
fs_info
,
&
key
);
if
(
IS_ERR
(
pending
->
snap
))
{
if
(
IS_ERR
(
pending
->
snap
))
{
ret
=
PTR_ERR
(
pending
->
snap
);
ret
=
PTR_ERR
(
pending
->
snap
);
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
ret
=
btrfs_reloc_post_snapshot
(
trans
,
pending
);
ret
=
btrfs_reloc_post_snapshot
(
trans
,
pending
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
ret
=
btrfs_run_delayed_refs
(
trans
,
root
,
(
unsigned
long
)
-
1
);
ret
=
btrfs_run_delayed_refs
(
trans
,
root
,
(
unsigned
long
)
-
1
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
...
@@ -1622,7 +1623,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
...
@@ -1622,7 +1623,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
/* We have check then name at the beginning, so it is impossible. */
/* We have check then name at the beginning, so it is impossible. */
BUG_ON
(
ret
==
-
EEXIST
||
ret
==
-
EOVERFLOW
);
BUG_ON
(
ret
==
-
EEXIST
||
ret
==
-
EOVERFLOW
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
...
@@ -1632,13 +1633,13 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
...
@@ -1632,13 +1633,13 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
current_fs_time
(
parent_inode
->
i_sb
);
current_fs_time
(
parent_inode
->
i_sb
);
ret
=
btrfs_update_inode_fallback
(
trans
,
parent_root
,
parent_inode
);
ret
=
btrfs_update_inode_fallback
(
trans
,
parent_root
,
parent_inode
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
ret
=
btrfs_uuid_tree_add
(
trans
,
fs_info
->
uuid_root
,
new_uuid
.
b
,
ret
=
btrfs_uuid_tree_add
(
trans
,
fs_info
->
uuid_root
,
new_uuid
.
b
,
BTRFS_UUID_KEY_SUBVOL
,
objectid
);
BTRFS_UUID_KEY_SUBVOL
,
objectid
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
if
(
!
btrfs_is_empty_uuid
(
new_root_item
->
received_uuid
))
{
if
(
!
btrfs_is_empty_uuid
(
new_root_item
->
received_uuid
))
{
...
@@ -1647,14 +1648,14 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
...
@@ -1647,14 +1648,14 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
BTRFS_UUID_KEY_RECEIVED_SUBVOL
,
BTRFS_UUID_KEY_RECEIVED_SUBVOL
,
objectid
);
objectid
);
if
(
ret
&&
ret
!=
-
EEXIST
)
{
if
(
ret
&&
ret
!=
-
EEXIST
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
}
}
ret
=
btrfs_run_delayed_refs
(
trans
,
root
,
(
unsigned
long
)
-
1
);
ret
=
btrfs_run_delayed_refs
(
trans
,
root
,
(
unsigned
long
)
-
1
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
fail
;
goto
fail
;
}
}
...
@@ -1709,7 +1710,7 @@ static void update_super_roots(struct btrfs_root *root)
...
@@ -1709,7 +1710,7 @@ static void update_super_roots(struct btrfs_root *root)
super
->
root
=
root_item
->
bytenr
;
super
->
root
=
root_item
->
bytenr
;
super
->
generation
=
root_item
->
generation
;
super
->
generation
=
root_item
->
generation
;
super
->
root_level
=
root_item
->
level
;
super
->
root_level
=
root_item
->
level
;
if
(
btrfs_test_opt
(
root
,
SPACE_CACHE
))
if
(
btrfs_test_opt
(
root
->
fs_info
,
SPACE_CACHE
))
super
->
cache_generation
=
root_item
->
generation
;
super
->
cache_generation
=
root_item
->
generation
;
if
(
root
->
fs_info
->
update_uuid_tree_gen
)
if
(
root
->
fs_info
->
update_uuid_tree_gen
)
super
->
uuid_tree_generation
=
root_item
->
generation
;
super
->
uuid_tree_generation
=
root_item
->
generation
;
...
@@ -1850,7 +1851,7 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans,
...
@@ -1850,7 +1851,7 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans,
WARN_ON
(
trans
->
use_count
>
1
);
WARN_ON
(
trans
->
use_count
>
1
);
btrfs_abort_transaction
(
trans
,
root
,
err
);
btrfs_abort_transaction
(
trans
,
err
);
spin_lock
(
&
root
->
fs_info
->
trans_lock
);
spin_lock
(
&
root
->
fs_info
->
trans_lock
);
...
@@ -1895,14 +1896,14 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans,
...
@@ -1895,14 +1896,14 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans,
static
inline
int
btrfs_start_delalloc_flush
(
struct
btrfs_fs_info
*
fs_info
)
static
inline
int
btrfs_start_delalloc_flush
(
struct
btrfs_fs_info
*
fs_info
)
{
{
if
(
btrfs_test_opt
(
fs_info
->
tree_root
,
FLUSHONCOMMIT
))
if
(
btrfs_test_opt
(
fs_info
,
FLUSHONCOMMIT
))
return
btrfs_start_delalloc_roots
(
fs_info
,
1
,
-
1
);
return
btrfs_start_delalloc_roots
(
fs_info
,
1
,
-
1
);
return
0
;
return
0
;
}
}
static
inline
void
btrfs_wait_delalloc_flush
(
struct
btrfs_fs_info
*
fs_info
)
static
inline
void
btrfs_wait_delalloc_flush
(
struct
btrfs_fs_info
*
fs_info
)
{
{
if
(
btrfs_test_opt
(
fs_info
->
tree_root
,
FLUSHONCOMMIT
))
if
(
btrfs_test_opt
(
fs_info
,
FLUSHONCOMMIT
))
btrfs_wait_ordered_roots
(
fs_info
,
-
1
,
0
,
(
u64
)
-
1
);
btrfs_wait_ordered_roots
(
fs_info
,
-
1
,
0
,
(
u64
)
-
1
);
}
}
...
...
fs/btrfs/transaction.h
浏览文件 @
023a824f
...
@@ -128,6 +128,7 @@ struct btrfs_trans_handle {
...
@@ -128,6 +128,7 @@ struct btrfs_trans_handle {
* Subvolume quota depends on this
* Subvolume quota depends on this
*/
*/
struct
btrfs_root
*
root
;
struct
btrfs_root
*
root
;
struct
btrfs_fs_info
*
fs_info
;
struct
seq_list
delayed_ref_elem
;
struct
seq_list
delayed_ref_elem
;
struct
list_head
qgroup_ref_list
;
struct
list_head
qgroup_ref_list
;
struct
list_head
new_bgs
;
struct
list_head
new_bgs
;
...
...
fs/btrfs/tree-log.c
浏览文件 @
023a824f
...
@@ -2757,7 +2757,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
...
@@ -2757,7 +2757,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
while
(
1
)
{
while
(
1
)
{
int
batch
=
atomic_read
(
&
root
->
log_batch
);
int
batch
=
atomic_read
(
&
root
->
log_batch
);
/* when we're on an ssd, just kick the log commit out */
/* when we're on an ssd, just kick the log commit out */
if
(
!
btrfs_test_opt
(
root
,
SSD
)
&&
if
(
!
btrfs_test_opt
(
root
->
fs_info
,
SSD
)
&&
test_bit
(
BTRFS_ROOT_MULTI_LOG_TASKS
,
&
root
->
state
))
{
test_bit
(
BTRFS_ROOT_MULTI_LOG_TASKS
,
&
root
->
state
))
{
mutex_unlock
(
&
root
->
log_mutex
);
mutex_unlock
(
&
root
->
log_mutex
);
schedule_timeout_uninterruptible
(
1
);
schedule_timeout_uninterruptible
(
1
);
...
@@ -2788,7 +2788,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
...
@@ -2788,7 +2788,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
ret
=
btrfs_write_marked_extents
(
log
,
&
log
->
dirty_log_pages
,
mark
);
ret
=
btrfs_write_marked_extents
(
log
,
&
log
->
dirty_log_pages
,
mark
);
if
(
ret
)
{
if
(
ret
)
{
blk_finish_plug
(
&
plug
);
blk_finish_plug
(
&
plug
);
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
btrfs_free_logged_extents
(
log
,
log_transid
);
btrfs_free_logged_extents
(
log
,
log_transid
);
btrfs_set_log_full_commit
(
root
->
fs_info
,
trans
);
btrfs_set_log_full_commit
(
root
->
fs_info
,
trans
);
mutex_unlock
(
&
root
->
log_mutex
);
mutex_unlock
(
&
root
->
log_mutex
);
...
@@ -2838,7 +2838,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
...
@@ -2838,7 +2838,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
btrfs_set_log_full_commit
(
root
->
fs_info
,
trans
);
btrfs_set_log_full_commit
(
root
->
fs_info
,
trans
);
if
(
ret
!=
-
ENOSPC
)
{
if
(
ret
!=
-
ENOSPC
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
mutex_unlock
(
&
log_root_tree
->
log_mutex
);
mutex_unlock
(
&
log_root_tree
->
log_mutex
);
goto
out
;
goto
out
;
}
}
...
@@ -2898,7 +2898,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
...
@@ -2898,7 +2898,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
blk_finish_plug
(
&
plug
);
blk_finish_plug
(
&
plug
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_set_log_full_commit
(
root
->
fs_info
,
trans
);
btrfs_set_log_full_commit
(
root
->
fs_info
,
trans
);
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
btrfs_free_logged_extents
(
log
,
log_transid
);
btrfs_free_logged_extents
(
log
,
log_transid
);
mutex_unlock
(
&
log_root_tree
->
log_mutex
);
mutex_unlock
(
&
log_root_tree
->
log_mutex
);
goto
out_wake_log_root
;
goto
out_wake_log_root
;
...
@@ -2934,7 +2934,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
...
@@ -2934,7 +2934,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
ret
=
write_ctree_super
(
trans
,
root
->
fs_info
->
tree_root
,
1
);
ret
=
write_ctree_super
(
trans
,
root
->
fs_info
->
tree_root
,
1
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_set_log_full_commit
(
root
->
fs_info
,
trans
);
btrfs_set_log_full_commit
(
root
->
fs_info
,
trans
);
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out_wake_log_root
;
goto
out_wake_log_root
;
}
}
...
@@ -2991,7 +2991,7 @@ static void free_log_tree(struct btrfs_trans_handle *trans,
...
@@ -2991,7 +2991,7 @@ static void free_log_tree(struct btrfs_trans_handle *trans,
ret
=
walk_log_tree
(
trans
,
log
,
&
wc
);
ret
=
walk_log_tree
(
trans
,
log
,
&
wc
);
/* I don't think this can happen but just in case */
/* I don't think this can happen but just in case */
if
(
ret
)
if
(
ret
)
btrfs_abort_transaction
(
trans
,
log
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
while
(
1
)
{
while
(
1
)
{
ret
=
find_first_extent_bit
(
&
log
->
dirty_log_pages
,
ret
=
find_first_extent_bit
(
&
log
->
dirty_log_pages
,
...
@@ -3160,7 +3160,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
...
@@ -3160,7 +3160,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
btrfs_set_log_full_commit
(
root
->
fs_info
,
trans
);
btrfs_set_log_full_commit
(
root
->
fs_info
,
trans
);
ret
=
0
;
ret
=
0
;
}
else
if
(
ret
<
0
)
}
else
if
(
ret
<
0
)
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
btrfs_end_log_trans
(
root
);
btrfs_end_log_trans
(
root
);
...
@@ -3193,7 +3193,7 @@ int btrfs_del_inode_ref_in_log(struct btrfs_trans_handle *trans,
...
@@ -3193,7 +3193,7 @@ int btrfs_del_inode_ref_in_log(struct btrfs_trans_handle *trans,
btrfs_set_log_full_commit
(
root
->
fs_info
,
trans
);
btrfs_set_log_full_commit
(
root
->
fs_info
,
trans
);
ret
=
0
;
ret
=
0
;
}
else
if
(
ret
<
0
&&
ret
!=
-
ENOENT
)
}
else
if
(
ret
<
0
&&
ret
!=
-
ENOENT
)
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
btrfs_end_log_trans
(
root
);
btrfs_end_log_trans
(
root
);
return
ret
;
return
ret
;
...
@@ -4703,6 +4703,10 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
...
@@ -4703,6 +4703,10 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
ins_nr
=
0
;
ins_nr
=
0
;
ret
=
btrfs_search_forward
(
root
,
&
min_key
,
ret
=
btrfs_search_forward
(
root
,
&
min_key
,
path
,
trans
->
transid
);
path
,
trans
->
transid
);
if
(
ret
<
0
)
{
err
=
ret
;
goto
out_unlock
;
}
if
(
ret
!=
0
)
if
(
ret
!=
0
)
break
;
break
;
again:
again:
...
@@ -5301,7 +5305,7 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
...
@@ -5301,7 +5305,7 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
sb
=
inode
->
i_sb
;
sb
=
inode
->
i_sb
;
if
(
btrfs_test_opt
(
root
,
NOTREELOG
))
{
if
(
btrfs_test_opt
(
root
->
fs_info
,
NOTREELOG
))
{
ret
=
1
;
ret
=
1
;
goto
end_no_trans
;
goto
end_no_trans
;
}
}
...
...
fs/btrfs/volumes.c
浏览文件 @
023a824f
...
@@ -140,7 +140,6 @@ static int btrfs_relocate_sys_chunks(struct btrfs_root *root);
...
@@ -140,7 +140,6 @@ static int btrfs_relocate_sys_chunks(struct btrfs_root *root);
static
void
__btrfs_reset_dev_stats
(
struct
btrfs_device
*
dev
);
static
void
__btrfs_reset_dev_stats
(
struct
btrfs_device
*
dev
);
static
void
btrfs_dev_stat_print_on_error
(
struct
btrfs_device
*
dev
);
static
void
btrfs_dev_stat_print_on_error
(
struct
btrfs_device
*
dev
);
static
void
btrfs_dev_stat_print_on_load
(
struct
btrfs_device
*
device
);
static
void
btrfs_dev_stat_print_on_load
(
struct
btrfs_device
*
device
);
static
void
btrfs_close_one_device
(
struct
btrfs_device
*
device
);
DEFINE_MUTEX
(
uuid_mutex
);
DEFINE_MUTEX
(
uuid_mutex
);
static
LIST_HEAD
(
fs_uuids
);
static
LIST_HEAD
(
fs_uuids
);
...
@@ -853,6 +852,46 @@ static void free_device(struct rcu_head *head)
...
@@ -853,6 +852,46 @@ static void free_device(struct rcu_head *head)
schedule_work
(
&
device
->
rcu_work
);
schedule_work
(
&
device
->
rcu_work
);
}
}
static
void
btrfs_close_one_device
(
struct
btrfs_device
*
device
)
{
struct
btrfs_fs_devices
*
fs_devices
=
device
->
fs_devices
;
struct
btrfs_device
*
new_device
;
struct
rcu_string
*
name
;
if
(
device
->
bdev
)
fs_devices
->
open_devices
--
;
if
(
device
->
writeable
&&
device
->
devid
!=
BTRFS_DEV_REPLACE_DEVID
)
{
list_del_init
(
&
device
->
dev_alloc_list
);
fs_devices
->
rw_devices
--
;
}
if
(
device
->
missing
)
fs_devices
->
missing_devices
--
;
if
(
device
->
bdev
&&
device
->
writeable
)
{
sync_blockdev
(
device
->
bdev
);
invalidate_bdev
(
device
->
bdev
);
}
new_device
=
btrfs_alloc_device
(
NULL
,
&
device
->
devid
,
device
->
uuid
);
BUG_ON
(
IS_ERR
(
new_device
));
/* -ENOMEM */
/* Safe because we are under uuid_mutex */
if
(
device
->
name
)
{
name
=
rcu_string_strdup
(
device
->
name
->
str
,
GFP_NOFS
);
BUG_ON
(
!
name
);
/* -ENOMEM */
rcu_assign_pointer
(
new_device
->
name
,
name
);
}
list_replace_rcu
(
&
device
->
dev_list
,
&
new_device
->
dev_list
);
new_device
->
fs_devices
=
device
->
fs_devices
;
call_rcu
(
&
device
->
rcu
,
free_device
);
}
static
int
__btrfs_close_devices
(
struct
btrfs_fs_devices
*
fs_devices
)
static
int
__btrfs_close_devices
(
struct
btrfs_fs_devices
*
fs_devices
)
{
{
struct
btrfs_device
*
device
,
*
tmp
;
struct
btrfs_device
*
device
,
*
tmp
;
...
@@ -2399,14 +2438,14 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
...
@@ -2399,14 +2438,14 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
ret
=
init_first_rw_device
(
trans
,
root
,
device
);
ret
=
init_first_rw_device
(
trans
,
root
,
device
);
unlock_chunks
(
root
);
unlock_chunks
(
root
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
error_trans
;
goto
error_trans
;
}
}
}
}
ret
=
btrfs_add_device
(
trans
,
root
,
device
);
ret
=
btrfs_add_device
(
trans
,
root
,
device
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
error_trans
;
goto
error_trans
;
}
}
...
@@ -2415,7 +2454,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
...
@@ -2415,7 +2454,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
ret
=
btrfs_finish_sprout
(
trans
,
root
);
ret
=
btrfs_finish_sprout
(
trans
,
root
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
error_trans
;
goto
error_trans
;
}
}
...
@@ -2801,7 +2840,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
...
@@ -2801,7 +2840,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
&
dev_extent_len
);
&
dev_extent_len
);
if
(
ret
)
{
if
(
ret
)
{
mutex_unlock
(
&
fs_devices
->
device_list_mutex
);
mutex_unlock
(
&
fs_devices
->
device_list_mutex
);
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
...
@@ -2820,7 +2859,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
...
@@ -2820,7 +2859,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
ret
=
btrfs_update_device
(
trans
,
map
->
stripes
[
i
].
dev
);
ret
=
btrfs_update_device
(
trans
,
map
->
stripes
[
i
].
dev
);
if
(
ret
)
{
if
(
ret
)
{
mutex_unlock
(
&
fs_devices
->
device_list_mutex
);
mutex_unlock
(
&
fs_devices
->
device_list_mutex
);
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
}
}
...
@@ -2829,7 +2868,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
...
@@ -2829,7 +2868,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
ret
=
btrfs_free_chunk
(
trans
,
root
,
chunk_objectid
,
chunk_offset
);
ret
=
btrfs_free_chunk
(
trans
,
root
,
chunk_objectid
,
chunk_offset
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
...
@@ -2838,14 +2877,14 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
...
@@ -2838,14 +2877,14 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
if
(
map
->
type
&
BTRFS_BLOCK_GROUP_SYSTEM
)
{
if
(
map
->
type
&
BTRFS_BLOCK_GROUP_SYSTEM
)
{
ret
=
btrfs_del_sys_chunk
(
root
,
chunk_objectid
,
chunk_offset
);
ret
=
btrfs_del_sys_chunk
(
root
,
chunk_objectid
,
chunk_offset
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
r
oot
,
r
et
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
}
}
ret
=
btrfs_remove_block_group
(
trans
,
extent_root
,
chunk_offset
,
em
);
ret
=
btrfs_remove_block_group
(
trans
,
extent_root
,
chunk_offset
,
em
);
if
(
ret
)
{
if
(
ret
)
{
btrfs_abort_transaction
(
trans
,
extent_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
goto
out
;
goto
out
;
}
}
...
@@ -2902,7 +2941,7 @@ static int btrfs_relocate_chunk(struct btrfs_root *root, u64 chunk_offset)
...
@@ -2902,7 +2941,7 @@ static int btrfs_relocate_chunk(struct btrfs_root *root, u64 chunk_offset)
* chunk tree entries
* chunk tree entries
*/
*/
ret
=
btrfs_remove_chunk
(
trans
,
root
,
chunk_offset
);
ret
=
btrfs_remove_chunk
(
trans
,
root
,
chunk_offset
);
btrfs_end_transaction
(
trans
,
root
);
btrfs_end_transaction
(
trans
,
extent_
root
);
return
ret
;
return
ret
;
}
}
...
@@ -3421,7 +3460,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
...
@@ -3421,7 +3460,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
u64
size_to_free
;
u64
size_to_free
;
u64
chunk_type
;
u64
chunk_type
;
struct
btrfs_chunk
*
chunk
;
struct
btrfs_chunk
*
chunk
;
struct
btrfs_path
*
path
;
struct
btrfs_path
*
path
=
NULL
;
struct
btrfs_key
key
;
struct
btrfs_key
key
;
struct
btrfs_key
found_key
;
struct
btrfs_key
found_key
;
struct
btrfs_trans_handle
*
trans
;
struct
btrfs_trans_handle
*
trans
;
...
@@ -3455,13 +3494,33 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
...
@@ -3455,13 +3494,33 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
ret
=
btrfs_shrink_device
(
device
,
old_size
-
size_to_free
);
ret
=
btrfs_shrink_device
(
device
,
old_size
-
size_to_free
);
if
(
ret
==
-
ENOSPC
)
if
(
ret
==
-
ENOSPC
)
break
;
break
;
BUG_ON
(
ret
);
if
(
ret
)
{
/* btrfs_shrink_device never returns ret > 0 */
WARN_ON
(
ret
>
0
);
goto
error
;
}
trans
=
btrfs_start_transaction
(
dev_root
,
0
);
trans
=
btrfs_start_transaction
(
dev_root
,
0
);
BUG_ON
(
IS_ERR
(
trans
));
if
(
IS_ERR
(
trans
))
{
ret
=
PTR_ERR
(
trans
);
btrfs_info_in_rcu
(
fs_info
,
"resize: unable to start transaction after shrinking device %s (error %d), old size %llu, new size %llu"
,
rcu_str_deref
(
device
->
name
),
ret
,
old_size
,
old_size
-
size_to_free
);
goto
error
;
}
ret
=
btrfs_grow_device
(
trans
,
device
,
old_size
);
ret
=
btrfs_grow_device
(
trans
,
device
,
old_size
);
BUG_ON
(
ret
);
if
(
ret
)
{
btrfs_end_transaction
(
trans
,
dev_root
);
/* btrfs_grow_device never returns ret > 0 */
WARN_ON
(
ret
>
0
);
btrfs_info_in_rcu
(
fs_info
,
"resize: unable to grow device after shrinking device %s (error %d), old size %llu, new size %llu"
,
rcu_str_deref
(
device
->
name
),
ret
,
old_size
,
old_size
-
size_to_free
);
goto
error
;
}
btrfs_end_transaction
(
trans
,
dev_root
);
btrfs_end_transaction
(
trans
,
dev_root
);
}
}
...
@@ -3885,7 +3944,7 @@ int btrfs_resume_balance_async(struct btrfs_fs_info *fs_info)
...
@@ -3885,7 +3944,7 @@ int btrfs_resume_balance_async(struct btrfs_fs_info *fs_info)
}
}
spin_unlock
(
&
fs_info
->
balance_lock
);
spin_unlock
(
&
fs_info
->
balance_lock
);
if
(
btrfs_test_opt
(
fs_info
->
tree_root
,
SKIP_BALANCE
))
{
if
(
btrfs_test_opt
(
fs_info
,
SKIP_BALANCE
))
{
btrfs_info
(
fs_info
,
"force skipping balance"
);
btrfs_info
(
fs_info
,
"force skipping balance"
);
return
0
;
return
0
;
}
}
...
@@ -4240,7 +4299,7 @@ int btrfs_create_uuid_tree(struct btrfs_fs_info *fs_info)
...
@@ -4240,7 +4299,7 @@ int btrfs_create_uuid_tree(struct btrfs_fs_info *fs_info)
BTRFS_UUID_TREE_OBJECTID
);
BTRFS_UUID_TREE_OBJECTID
);
if
(
IS_ERR
(
uuid_root
))
{
if
(
IS_ERR
(
uuid_root
))
{
ret
=
PTR_ERR
(
uuid_root
);
ret
=
PTR_ERR
(
uuid_root
);
btrfs_abort_transaction
(
trans
,
tree_root
,
ret
);
btrfs_abort_transaction
(
trans
,
ret
);
btrfs_end_transaction
(
trans
,
tree_root
);
btrfs_end_transaction
(
trans
,
tree_root
);
return
ret
;
return
ret
;
}
}
...
@@ -4514,8 +4573,7 @@ static void check_raid56_incompat_flag(struct btrfs_fs_info *info, u64 type)
...
@@ -4514,8 +4573,7 @@ static void check_raid56_incompat_flag(struct btrfs_fs_info *info, u64 type)
btrfs_set_fs_incompat
(
info
,
RAID56
);
btrfs_set_fs_incompat
(
info
,
RAID56
);
}
}
#define BTRFS_MAX_DEVS(r) ((BTRFS_LEAF_DATA_SIZE(r) \
#define BTRFS_MAX_DEVS(r) ((BTRFS_MAX_ITEM_SIZE(r) \
- sizeof(struct btrfs_item) \
- sizeof(struct btrfs_chunk)) \
- sizeof(struct btrfs_chunk)) \
/ sizeof(struct btrfs_stripe) + 1)
/ sizeof(struct btrfs_stripe) + 1)
...
@@ -6396,7 +6454,8 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
...
@@ -6396,7 +6454,8 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
BTRFS_UUID_SIZE
);
BTRFS_UUID_SIZE
);
map
->
stripes
[
i
].
dev
=
btrfs_find_device
(
root
->
fs_info
,
devid
,
map
->
stripes
[
i
].
dev
=
btrfs_find_device
(
root
->
fs_info
,
devid
,
uuid
,
NULL
);
uuid
,
NULL
);
if
(
!
map
->
stripes
[
i
].
dev
&&
!
btrfs_test_opt
(
root
,
DEGRADED
))
{
if
(
!
map
->
stripes
[
i
].
dev
&&
!
btrfs_test_opt
(
root
->
fs_info
,
DEGRADED
))
{
free_extent_map
(
em
);
free_extent_map
(
em
);
return
-
EIO
;
return
-
EIO
;
}
}
...
@@ -6464,7 +6523,7 @@ static struct btrfs_fs_devices *open_seed_devices(struct btrfs_root *root,
...
@@ -6464,7 +6523,7 @@ static struct btrfs_fs_devices *open_seed_devices(struct btrfs_root *root,
fs_devices
=
find_fsid
(
fsid
);
fs_devices
=
find_fsid
(
fsid
);
if
(
!
fs_devices
)
{
if
(
!
fs_devices
)
{
if
(
!
btrfs_test_opt
(
root
,
DEGRADED
))
if
(
!
btrfs_test_opt
(
root
->
fs_info
,
DEGRADED
))
return
ERR_PTR
(
-
ENOENT
);
return
ERR_PTR
(
-
ENOENT
);
fs_devices
=
alloc_fs_devices
(
fsid
);
fs_devices
=
alloc_fs_devices
(
fsid
);
...
@@ -6526,7 +6585,7 @@ static int read_one_dev(struct btrfs_root *root,
...
@@ -6526,7 +6585,7 @@ static int read_one_dev(struct btrfs_root *root,
device
=
btrfs_find_device
(
root
->
fs_info
,
devid
,
dev_uuid
,
fs_uuid
);
device
=
btrfs_find_device
(
root
->
fs_info
,
devid
,
dev_uuid
,
fs_uuid
);
if
(
!
device
)
{
if
(
!
device
)
{
if
(
!
btrfs_test_opt
(
root
,
DEGRADED
))
if
(
!
btrfs_test_opt
(
root
->
fs_info
,
DEGRADED
))
return
-
EIO
;
return
-
EIO
;
device
=
add_missing_dev
(
root
,
fs_devices
,
devid
,
dev_uuid
);
device
=
add_missing_dev
(
root
,
fs_devices
,
devid
,
dev_uuid
);
...
@@ -6535,7 +6594,7 @@ static int read_one_dev(struct btrfs_root *root,
...
@@ -6535,7 +6594,7 @@ static int read_one_dev(struct btrfs_root *root,
btrfs_warn
(
root
->
fs_info
,
"devid %llu uuid %pU missing"
,
btrfs_warn
(
root
->
fs_info
,
"devid %llu uuid %pU missing"
,
devid
,
dev_uuid
);
devid
,
dev_uuid
);
}
else
{
}
else
{
if
(
!
device
->
bdev
&&
!
btrfs_test_opt
(
root
,
DEGRADED
))
if
(
!
device
->
bdev
&&
!
btrfs_test_opt
(
root
->
fs_info
,
DEGRADED
))
return
-
EIO
;
return
-
EIO
;
if
(
!
device
->
bdev
&&
!
device
->
missing
)
{
if
(
!
device
->
bdev
&&
!
device
->
missing
)
{
...
@@ -7138,38 +7197,3 @@ void btrfs_reset_fs_info_ptr(struct btrfs_fs_info *fs_info)
...
@@ -7138,38 +7197,3 @@ void btrfs_reset_fs_info_ptr(struct btrfs_fs_info *fs_info)
fs_devices
=
fs_devices
->
seed
;
fs_devices
=
fs_devices
->
seed
;
}
}
}
}
static
void
btrfs_close_one_device
(
struct
btrfs_device
*
device
)
{
struct
btrfs_fs_devices
*
fs_devices
=
device
->
fs_devices
;
struct
btrfs_device
*
new_device
;
struct
rcu_string
*
name
;
if
(
device
->
bdev
)
fs_devices
->
open_devices
--
;
if
(
device
->
writeable
&&
device
->
devid
!=
BTRFS_DEV_REPLACE_DEVID
)
{
list_del_init
(
&
device
->
dev_alloc_list
);
fs_devices
->
rw_devices
--
;
}
if
(
device
->
missing
)
fs_devices
->
missing_devices
--
;
new_device
=
btrfs_alloc_device
(
NULL
,
&
device
->
devid
,
device
->
uuid
);
BUG_ON
(
IS_ERR
(
new_device
));
/* -ENOMEM */
/* Safe because we are under uuid_mutex */
if
(
device
->
name
)
{
name
=
rcu_string_strdup
(
device
->
name
->
str
,
GFP_NOFS
);
BUG_ON
(
!
name
);
/* -ENOMEM */
rcu_assign_pointer
(
new_device
->
name
,
name
);
}
list_replace_rcu
(
&
device
->
dev_list
,
&
new_device
->
dev_list
);
new_device
->
fs_devices
=
device
->
fs_devices
;
call_rcu
(
&
device
->
rcu
,
free_device
);
}
include/trace/events/btrfs.h
浏览文件 @
023a824f
此差异已折叠。
点击以展开。
include/uapi/linux/btrfs.h
浏览文件 @
023a824f
...
@@ -798,7 +798,7 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code)
...
@@ -798,7 +798,7 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code)
#define BTRFS_IOC_INO_PATHS _IOWR(BTRFS_IOCTL_MAGIC, 35, \
#define BTRFS_IOC_INO_PATHS _IOWR(BTRFS_IOCTL_MAGIC, 35, \
struct btrfs_ioctl_ino_path_args)
struct btrfs_ioctl_ino_path_args)
#define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \
#define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \
struct btrfs_ioctl_
ino_path
_args)
struct btrfs_ioctl_
logical_ino
_args)
#define BTRFS_IOC_SET_RECEIVED_SUBVOL _IOWR(BTRFS_IOCTL_MAGIC, 37, \
#define BTRFS_IOC_SET_RECEIVED_SUBVOL _IOWR(BTRFS_IOCTL_MAGIC, 37, \
struct btrfs_ioctl_received_subvol_args)
struct btrfs_ioctl_received_subvol_args)
#define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args)
#define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录