* [PATCH 1/2] Btrfs: avoid memory leak of extent state in error handling routine
@ 2012-05-18 10:07 Liu Bo
2012-05-18 10:07 ` [PATCH 2/2] Btrfs: make sure that we've made everything in pinned tree clean Liu Bo
2012-05-18 10:07 ` [PATCH] Btrfs: destroy the items of the delayed inodes in error handling routine Liu Bo
0 siblings, 2 replies; 3+ messages in thread
From: Liu Bo @ 2012-05-18 10:07 UTC (permalink / raw)
To: linux-btrfs
We've forgotten to clear extent states in pinned tree, which will results in
space counter mismatch and memory leak:
WARNING: at fs/btrfs/extent-tree.c:7537 btrfs_free_block_groups+0x1f3/0x2e0 [btrfs]()
...
space_info 2 has 8380416 free, is not full
space_info total=12582912, used=4096, pinned=4096, reserved=0, may_use=0, readonly=4194304
btrfs state leak: start 29364224 end 29376511 state 1 in tree ffff880075f20090 refs 1
...
Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
---
fs/btrfs/disk-io.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index a7ffc88..046a737 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3595,6 +3595,8 @@ void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans,
btrfs_destroy_marked_extents(root, &cur_trans->dirty_pages,
EXTENT_DIRTY);
+ btrfs_destroy_pinned_extent(root,
+ root->fs_info->pinned_extents);
/*
memset(cur_trans, 0, sizeof(*cur_trans));
--
1.6.5.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] Btrfs: make sure that we've made everything in pinned tree clean
2012-05-18 10:07 [PATCH 1/2] Btrfs: avoid memory leak of extent state in error handling routine Liu Bo
@ 2012-05-18 10:07 ` Liu Bo
2012-05-18 10:07 ` [PATCH] Btrfs: destroy the items of the delayed inodes in error handling routine Liu Bo
1 sibling, 0 replies; 3+ messages in thread
From: Liu Bo @ 2012-05-18 10:07 UTC (permalink / raw)
To: linux-btrfs
Since we have two trees for recording pinned extents, we need to go through
both of them to make sure that we've done everything clean.
Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
---
fs/btrfs/disk-io.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 046a737..144f019 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3548,8 +3548,10 @@ static int btrfs_destroy_pinned_extent(struct btrfs_root *root,
u64 start;
u64 end;
int ret;
+ bool loop = true;
unpin = pinned_extents;
+again:
while (1) {
ret = find_first_extent_bit(unpin, 0, &start, &end,
EXTENT_DIRTY);
@@ -3567,6 +3569,15 @@ static int btrfs_destroy_pinned_extent(struct btrfs_root *root,
cond_resched();
}
+ if (loop) {
+ if (unpin == &root->fs_info->freed_extents[0])
+ unpin = &root->fs_info->freed_extents[1];
+ else
+ unpin = &root->fs_info->freed_extents[0];
+ loop = false;
+ goto again;
+ }
+
return 0;
}
--
1.6.5.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] Btrfs: destroy the items of the delayed inodes in error handling routine
2012-05-18 10:07 [PATCH 1/2] Btrfs: avoid memory leak of extent state in error handling routine Liu Bo
2012-05-18 10:07 ` [PATCH 2/2] Btrfs: make sure that we've made everything in pinned tree clean Liu Bo
@ 2012-05-18 10:07 ` Liu Bo
1 sibling, 0 replies; 3+ messages in thread
From: Liu Bo @ 2012-05-18 10:07 UTC (permalink / raw)
To: linux-btrfs
From: Miao Xie <miaox@cn.fujitsu.com>
the items of the delayed inodes were forgotten to be freed, this patch
fix it.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
fs/btrfs/delayed-inode.c | 18 ++++++++++++++++++
fs/btrfs/delayed-inode.h | 3 +++
fs/btrfs/disk-io.c | 6 ++++++
3 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 03e3748..858d6c7 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1879,3 +1879,21 @@ void btrfs_kill_all_delayed_nodes(struct btrfs_root *root)
}
}
}
+
+void btrfs_destroy_delayed_inodes(struct btrfs_root *root)
+{
+ struct btrfs_delayed_root *delayed_root;
+ struct btrfs_delayed_node *curr_node, *prev_node;
+
+ delayed_root = btrfs_get_delayed_root(root);
+
+ curr_node = btrfs_first_delayed_node(delayed_root);
+ while (curr_node) {
+ __btrfs_kill_delayed_node(curr_node);
+
+ prev_node = curr_node;
+ curr_node = btrfs_next_delayed_node(curr_node);
+ btrfs_release_delayed_node(prev_node);
+ }
+}
+
diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
index 7083d08..c1cfa87 100644
--- a/fs/btrfs/delayed-inode.h
+++ b/fs/btrfs/delayed-inode.h
@@ -124,6 +124,9 @@ int btrfs_fill_inode(struct inode *inode, u32 *rdev);
/* Used for drop dead root */
void btrfs_kill_all_delayed_nodes(struct btrfs_root *root);
+/* Used for clean the transaction */
+void btrfs_destroy_delayed_inodes(struct btrfs_root *root)
+
/* Used for readdir() */
void btrfs_get_delayed_items(struct inode *inode, struct list_head *ins_list,
struct list_head *del_list);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 20196f4..a56026f 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3583,6 +3583,9 @@ void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans,
if (waitqueue_active(&cur_trans->commit_wait))
wake_up(&cur_trans->commit_wait);
+ btrfs_destroy_delayed_inodes(root);
+ btrfs_assert_delayed_root_empty(root);
+
btrfs_destroy_pending_snapshots(cur_trans);
btrfs_destroy_marked_extents(root, &cur_trans->dirty_pages,
@@ -3635,6 +3638,9 @@ int btrfs_cleanup_transaction(struct btrfs_root *root)
if (waitqueue_active(&t->commit_wait))
wake_up(&t->commit_wait);
+ btrfs_destroy_delayed_inodes(root);
+ btrfs_assert_delayed_root_empty(root);
+
btrfs_destroy_pending_snapshots(t);
btrfs_destroy_delalloc_inodes(root);
--
1.7.6.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-05-18 10:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-18 10:07 [PATCH 1/2] Btrfs: avoid memory leak of extent state in error handling routine Liu Bo
2012-05-18 10:07 ` [PATCH 2/2] Btrfs: make sure that we've made everything in pinned tree clean Liu Bo
2012-05-18 10:07 ` [PATCH] Btrfs: destroy the items of the delayed inodes in error handling routine Liu Bo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).