Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xiphi1978
linux
提交
78fae27e
L
linux
项目概览
xiphi1978
/
linux
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
78fae27e
编写于
3月 25, 2007
作者:
C
Chris Mason
提交者:
David Woodhouse
3月 25, 2007
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Btrfs: leak fixes, pinning fixes
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
d561c025
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
23 deletion
+40
-23
fs/btrfs/extent-tree.c
fs/btrfs/extent-tree.c
+21
-9
fs/btrfs/super.c
fs/btrfs/super.c
+1
-0
fs/btrfs/transaction.c
fs/btrfs/transaction.c
+18
-14
未找到文件。
fs/btrfs/extent-tree.c
浏览文件 @
78fae27e
...
...
@@ -165,13 +165,23 @@ static int pin_down_block(struct btrfs_root *root, u64 blocknr, int tag)
{
int
err
;
struct
buffer_head
*
bh
=
sb_getblk
(
root
->
fs_info
->
sb
,
blocknr
);
struct
btrfs_header
*
header
;
BUG_ON
(
!
bh
);
header
=
btrfs_buffer_header
(
bh
);
if
(
btrfs_header_generation
(
header
)
==
root
->
fs_info
->
running_transaction
->
transid
)
{
return
0
;
}
err
=
radix_tree_insert
(
&
root
->
fs_info
->
pinned_radix
,
blocknr
,
bh
);
if
(
err
&&
err
!=
-
EEXIST
)
{
BUG
();
return
err
;
}
if
(
err
==
-
EEXIST
)
brelse
(
bh
);
radix_tree_tag_set
(
&
root
->
fs_info
->
pinned_radix
,
blocknr
,
tag
);
return
0
;
...
...
@@ -181,7 +191,7 @@ static int pin_down_block(struct btrfs_root *root, u64 blocknr, int tag)
* remove an extent from the root, returns 0 on success
*/
static
int
__free_extent
(
struct
btrfs_trans_handle
*
trans
,
struct
btrfs_root
*
root
,
u64
blocknr
,
u64
num_blocks
)
*
root
,
u64
blocknr
,
u64
num_blocks
,
int
pin
)
{
struct
btrfs_path
path
;
struct
btrfs_key
key
;
...
...
@@ -213,12 +223,18 @@ static int __free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
btrfs_set_extent_refs
(
ei
,
refs
);
if
(
refs
==
0
)
{
u64
super_blocks_used
;
if
(
pin
)
{
ret
=
pin_down_block
(
root
,
blocknr
,
CTREE_EXTENT_PINNED
);
BUG_ON
(
ret
);
}
super_blocks_used
=
btrfs_super_blocks_used
(
info
->
disk_super
);
btrfs_set_super_blocks_used
(
info
->
disk_super
,
super_blocks_used
-
num_blocks
);
ret
=
btrfs_del_item
(
trans
,
extent_root
,
&
path
);
if
(
extent_root
->
fs_info
->
last_insert
.
objectid
>
blocknr
)
if
(
extent_root
->
fs_info
->
last_insert
.
objectid
>
blocknr
)
extent_root
->
fs_info
->
last_insert
.
objectid
=
blocknr
;
if
(
ret
)
BUG
();
...
...
@@ -257,7 +273,7 @@ static int del_pending_extents(struct btrfs_trans_handle *trans, struct
radix_tree_tag_clear
(
radix
,
gang
[
i
]
->
b_blocknr
,
CTREE_EXTENT_PENDING_DEL
);
wret
=
__free_extent
(
trans
,
extent_root
,
gang
[
i
]
->
b_blocknr
,
1
);
gang
[
i
]
->
b_blocknr
,
1
,
0
);
if
(
wret
)
err
=
wret
;
}
...
...
@@ -281,11 +297,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
pin_down_block
(
root
,
blocknr
,
CTREE_EXTENT_PENDING_DEL
);
return
0
;
}
if
(
pin
)
{
ret
=
pin_down_block
(
root
,
blocknr
,
CTREE_EXTENT_PINNED
);
BUG_ON
(
ret
);
}
ret
=
__free_extent
(
trans
,
root
,
blocknr
,
num_blocks
);
ret
=
__free_extent
(
trans
,
root
,
blocknr
,
num_blocks
,
pin
);
pending_ret
=
del_pending_extents
(
trans
,
root
->
fs_info
->
extent_root
);
return
ret
?
ret
:
pending_ret
;
}
...
...
fs/btrfs/super.c
浏览文件 @
78fae27e
...
...
@@ -146,6 +146,7 @@ static void btrfs_read_locked_inode(struct inode *inode)
ret
=
btrfs_lookup_inode
(
NULL
,
root
,
&
path
,
inode
->
i_ino
,
0
);
if
(
ret
)
{
make_bad_inode
(
inode
);
btrfs_release_path
(
root
,
&
path
);
return
;
}
inode_item
=
btrfs_item_ptr
(
btrfs_buffer_leaf
(
path
.
nodes
[
0
]),
...
...
fs/btrfs/transaction.c
浏览文件 @
78fae27e
...
...
@@ -4,12 +4,15 @@
#include "disk-io.h"
#include "transaction.h"
static
int
total_trans
=
0
;
static
void
put_transaction
(
struct
btrfs_transaction
*
transaction
)
{
transaction
->
use_count
--
;
if
(
transaction
->
use_count
==
0
)
if
(
transaction
->
use_count
==
0
)
{
WARN_ON
(
total_trans
==
0
);
total_trans
--
;
kfree
(
transaction
);
}
}
static
int
join_transaction
(
struct
btrfs_root
*
root
)
...
...
@@ -18,6 +21,7 @@ static int join_transaction(struct btrfs_root *root)
cur_trans
=
root
->
fs_info
->
running_transaction
;
if
(
!
cur_trans
)
{
cur_trans
=
kmalloc
(
sizeof
(
*
cur_trans
),
GFP_NOFS
);
total_trans
++
;
BUG_ON
(
!
cur_trans
);
root
->
fs_info
->
running_transaction
=
cur_trans
;
cur_trans
->
num_writers
=
0
;
...
...
@@ -108,7 +112,6 @@ static int wait_for_commit(struct btrfs_root *root,
struct
btrfs_transaction
*
commit
)
{
DEFINE_WAIT
(
wait
);
commit
->
use_count
++
;
while
(
!
commit
->
commit_done
)
{
prepare_to_wait
(
&
commit
->
commit_wait
,
&
wait
,
TASK_UNINTERRUPTIBLE
);
...
...
@@ -126,7 +129,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
struct
btrfs_root
*
root
)
{
int
ret
=
0
;
struct
buffer_head
*
snap
=
root
->
commit_root
;
struct
buffer_head
*
snap
;
struct
btrfs_key
snap_key
;
struct
btrfs_transaction
*
cur_trans
;
DEFINE_WAIT
(
wait
);
...
...
@@ -153,15 +156,11 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
}
finish_wait
(
&
trans
->
transaction
->
writer_wait
,
&
wait
);
cur_trans
=
root
->
fs_info
->
running_transaction
;
root
->
fs_info
->
running_transaction
=
NULL
;
if
(
root
->
node
!=
root
->
commit_root
)
{
memcpy
(
&
snap_key
,
&
root
->
root_key
,
sizeof
(
snap_key
));
root
->
root_key
.
offset
++
;
}
mutex_unlock
(
&
root
->
fs_info
->
trans_mutex
);
if
(
btrfs_root_blocknr
(
&
root
->
root_item
)
!=
root
->
node
->
b_blocknr
)
{
btrfs_set_root_blocknr
(
&
root
->
root_item
,
root
->
node
->
b_blocknr
);
...
...
@@ -173,17 +172,24 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
ret
=
btrfs_commit_tree_roots
(
trans
,
root
);
BUG_ON
(
ret
);
cur_trans
=
root
->
fs_info
->
running_transaction
;
root
->
fs_info
->
running_transaction
=
NULL
;
mutex_unlock
(
&
root
->
fs_info
->
trans_mutex
);
ret
=
btrfs_write_and_wait_transaction
(
trans
,
root
);
BUG_ON
(
ret
);
write_ctree_super
(
trans
,
root
);
btrfs_finish_extent_commit
(
trans
,
root
->
fs_info
->
extent_root
);
btrfs_finish_extent_commit
(
trans
,
root
->
fs_info
->
tree_root
);
btrfs_finish_extent_commit
(
trans
,
root
);
mutex_lock
(
&
root
->
fs_info
->
trans_mutex
);
put_transaction
(
cur_trans
);
put_transaction
(
cur_trans
);
mutex_unlock
(
&
root
->
fs_info
->
trans_mutex
);
kfree
(
trans
);
if
(
root
->
node
!=
root
->
commit_root
)
{
trans
=
btrfs_start_transaction
(
root
,
1
);
snap
=
root
->
commit_root
;
root
->
commit_root
=
root
->
node
;
get_bh
(
root
->
node
);
ret
=
btrfs_drop_snapshot
(
trans
,
root
,
snap
);
...
...
@@ -191,10 +197,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
ret
=
btrfs_del_root
(
trans
,
root
->
fs_info
->
tree_root
,
&
snap_key
);
BUG_ON
(
ret
);
root
->
fs_info
->
generation
=
root
->
root_key
.
offset
+
1
;
ret
=
btrfs_end_transaction
(
trans
,
root
);
BUG_ON
(
ret
);
BUG_ON
(
ret
);
root
->
fs_info
->
generation
=
root
->
root_key
.
offset
+
1
;
ret
=
btrfs_end_transaction
(
trans
,
root
);
BUG_ON
(
ret
);
printk
(
"at free, total trans %d
\n
"
,
total_trans
);
}
return
ret
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录