All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] btrfs: free fs roots on failed mount
@ 2020-07-22 16:07 Josef Bacik
  2020-07-22 16:07 ` [PATCH 2/2] btrfs: fix root leak printk to use %lld instead of %llu Josef Bacik
  2020-07-27 14:19 ` [PATCH 1/2] btrfs: free fs roots on failed mount David Sterba
  0 siblings, 2 replies; 18+ messages in thread
From: Josef Bacik @ 2020-07-22 16:07 UTC (permalink / raw)
  To: linux-btrfs, kernel-team

While testing a weird problem with -o degraded, I noticed I was getting
leaked root errors

BTRFS warning (device loop0): writable mount is not allowed due to too many missing devices
BTRFS error (device loop0): open_ctree failed
BTRFS error (device loop0): leaked root -9-0 refcount 1

This is the DATA_RELOC root, which gets read before the other fs roots,
but is included in the fs roots radix tree, and thus gets freed by
btrfs_free_fs_roots.  Fix this by moving the call into fail_tree_roots:
in open_ctree.  With this fix we no longer leak that root on mount
failure.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/disk-io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index c850d7f44fbe..f1fdbdd44c02 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3421,7 +3421,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
 fail_trans_kthread:
 	kthread_stop(fs_info->transaction_kthread);
 	btrfs_cleanup_transaction(fs_info);
-	btrfs_free_fs_roots(fs_info);
 fail_cleaner:
 	kthread_stop(fs_info->cleaner_kthread);
 
@@ -3441,6 +3440,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
 	btrfs_put_block_group_cache(fs_info);
 
 fail_tree_roots:
+	btrfs_free_fs_roots(fs_info);
 	free_root_pointers(fs_info, true);
 	invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
 
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread
* [PATCH 0/2][v2] Some leaked root fixes
@ 2020-08-20 20:00 Josef Bacik
  2020-08-20 20:00 ` [PATCH 1/2] btrfs: free fs roots on failed mount Josef Bacik
  0 siblings, 1 reply; 18+ messages in thread
From: Josef Bacik @ 2020-08-20 20:00 UTC (permalink / raw)
  To: linux-btrfs, kernel-team

Hello,

These are two fixes for a leaked root problem I noticed a while ago.  One is the
actual leaked root fix, the other is to add a pretty print for the leaked root
message, as figuring out that some giant %llu number was the data reloc root is
not a feat meant for humans.  Thanks,

Josef

^ permalink raw reply	[flat|nested] 18+ messages in thread
* [PATCH 0/2][v3] Some leaked root fixes
@ 2020-09-03 18:29 Josef Bacik
  2020-09-03 18:29 ` [PATCH 1/2] btrfs: free fs roots on failed mount Josef Bacik
  0 siblings, 1 reply; 18+ messages in thread
From: Josef Bacik @ 2020-09-03 18:29 UTC (permalink / raw)
  To: linux-btrfs, kernel-team

v2->v3:
- Reworked the pretty print for roots so it's a little cleaner, also made it so
  only reloc roots spit out the offset, since that's the only time we care.
- Added Nikolay's reviewed-by for the first patch.

--- Original email ---
Hello,

These are two fixes for a leaked root problem I noticed a while ago.  One is the
actual leaked root fix, the other is to add a pretty print for the leaked root
message, as figuring out that some giant %llu number was the data reloc root is
not a feat meant for humans.  Thanks,

Josef

Josef Bacik (2):
  btrfs: free fs roots on failed mount
  btrfs: pretty print leaked root name

 fs/btrfs/disk-io.c    |  8 ++++++--
 fs/btrfs/print-tree.c | 39 +++++++++++++++++++++++++++++++++++++++
 fs/btrfs/print-tree.h |  3 +++
 3 files changed, 48 insertions(+), 2 deletions(-)

-- 
2.24.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2020-09-07 12:51 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 16:07 [PATCH 1/2] btrfs: free fs roots on failed mount Josef Bacik
2020-07-22 16:07 ` [PATCH 2/2] btrfs: fix root leak printk to use %lld instead of %llu Josef Bacik
2020-07-23 14:20   ` David Sterba
2020-07-24  0:40     ` Qu Wenruo
2020-07-27 14:03       ` David Sterba
2020-07-27 14:07         ` David Sterba
2020-07-27 23:47         ` Qu Wenruo
2020-07-28 15:09           ` David Sterba
2020-07-27 14:19 ` [PATCH 1/2] btrfs: free fs roots on failed mount David Sterba
2020-07-27 14:33   ` Josef Bacik
2020-07-27 15:17     ` David Sterba
2020-07-27 15:37       ` Josef Bacik
2020-08-20 20:00 [PATCH 0/2][v2] Some leaked root fixes Josef Bacik
2020-08-20 20:00 ` [PATCH 1/2] btrfs: free fs roots on failed mount Josef Bacik
2020-08-21  7:31   ` Nikolay Borisov
2020-08-21 13:59     ` Josef Bacik
2020-08-21 14:07       ` Nikolay Borisov
2020-09-03 18:29 [PATCH 0/2][v3] Some leaked root fixes Josef Bacik
2020-09-03 18:29 ` [PATCH 1/2] btrfs: free fs roots on failed mount Josef Bacik
2020-09-07 12:50   ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.