linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: quwenruo@cn.fujitsu.com
Cc: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs: fix btrfs_check_degradable() to free extent map
Date: Mon, 18 Apr 2016 16:47:51 +0800	[thread overview]
Message-ID: <1460969271-7436-1-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1442801443-5132-2-git-send-email-quwenruo@cn.fujitsu.com>

I am making the following changes...

--------------- 8< ----------------------
Free the extent map and realign the map_tree read_lock
to fix the following..

kernel: BUG btrfs_extent_map (Tainted: G    B          ): Objects remaining in btrfs_extent_map on __kmem_cache_shutdown()
kernel: -----------------------------------------------------------------------------
kernel: INFO: Slab 0xffffea0001e4ef80 objects=28 used=9 fp=0xffff8800793be1b0 flags=0x1fffe0000000080
kernel: CPU: 0 PID: 5397 Comm: modprobe Tainted: G    B           4.6.0-rc2asj+ #5
kernel: Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
kernel:  0000000000000086 00000000c6b0aa23 ffff880035f3bcf8 ffffffff8141b7e3
kernel:  ffffea0001e4ef80 ffff880036994a00 ffff880035f3bdd0 ffffffff81217310
kernel:  0000000000000020 ffff880035f3bde0 ffff880035f3bd90 656a624f00000000
kernel: Call Trace:
kernel:  [<ffffffff8141b7e3>] dump_stack+0x85/0xc2
kernel:  [<ffffffff81217310>] slab_err+0xb0/0xe0
kernel:  [<ffffffff8121c109>] ? __kmalloc+0x259/0x3a0
kernel:  [<ffffffff8121f34c>] ? __kmem_cache_shutdown+0x14c/0x380
kernel:  [<ffffffff8121f36b>] __kmem_cache_shutdown+0x16b/0x380
kernel:  [<ffffffff811de5fb>] kmem_cache_destroy+0x1fb/0x2b0
kernel:  [<ffffffffa055be55>] extent_map_exit+0x15/0x20 [btrfs]
kernel:  [<ffffffffa05d8012>] exit_btrfs_fs+0x27/0x1015 [btrfs]
kernel:  [<ffffffff811365e3>] SyS_delete_module+0x1b3/0x260
kernel:  [<ffffffff810036ba>] ? exit_to_usermode_loop+0x6a/0xc0
kernel:  [<ffffffff8100301b>] ? trace_hardirqs_on_thunk+0x1b/0x1d
kernel:  [<ffffffff816a023c>] entry_SYSCALL_64_fastpath+0x1f/0xbd
kernel: INFO: Object 0xffff8800793be240 @offset=576
kernel: INFO: Object 0xffff8800793be2d0 @offset=720
kernel: INFO: Object 0xffff8800793be3f0 @offset=1008
kernel: INFO: Object 0xffff8800793be480 @offset=1152
kernel: INFO: Object 0xffff8800793be7e0 @offset=2016
kernel: INFO: Object 0xffff8800793be870 @offset=2160
kernel: INFO: Object 0xffff8800793be900 @offset=2304
kernel: INFO: Object 0xffff8800793beab0 @offset=2736
kernel: INFO: Object 0xffff8800793bebd0 @offset=3024

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/volumes.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 91d094ae2a10..36398c9d34eb 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -7105,6 +7105,7 @@ int btrfs_check_degradable(struct btrfs_fs_info *fs_info, unsigned flags)
 
 	read_lock(&map_tree->map_tree.lock);
 	em = lookup_extent_mapping(&map_tree->map_tree, 0, (u64)(-1));
+	read_unlock(&map_tree->map_tree.lock);
 	/* No any chunk? Should be a huge bug */
 	if (!em) {
 		ret = -ENOENT;
@@ -7143,11 +7144,14 @@ int btrfs_check_degradable(struct btrfs_fs_info *fs_info, unsigned flags)
 		 * Alwasy search range [next_start, (u64)-1) to find the next
 		 * chunk map
 		 */
+		free_extent_map(em);
+		read_lock(&map_tree->map_tree.lock);
 		em = lookup_extent_mapping(&map_tree->map_tree, next_start,
 					   (u64)(-1) - next_start);
+		read_unlock(&map_tree->map_tree.lock);
 	}
 out:
-	read_unlock(&map_tree->map_tree.lock);
+	free_extent_map(em);
 	return ret;
 }
 
-- 
2.7.0


  reply	other threads:[~2016-04-18  8:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-21  2:10 [PATCH 0/5] Btrfs: Per-chunk degradable check Qu Wenruo
2015-09-21  2:10 ` [PATCH 1/5] btrfs: Introduce a new function to check if all chunks a OK for degraded mount Qu Wenruo
2016-04-18  8:47   ` Anand Jain [this message]
2015-09-21  2:10 ` [PATCH 2/5] btrfs: Do per-chunk check for mount time check Qu Wenruo
2015-09-25  7:05   ` Anand Jain
2015-09-21  2:10 ` [PATCH 3/5] btrfs: Do per-chunk degraded check for remount Qu Wenruo
2015-09-25  6:54   ` Anand Jain
2015-09-25  8:08     ` Qu Wenruo
2015-09-25  8:30       ` Anand Jain
2015-09-25  8:34         ` Qu Wenruo
2015-09-25  8:24   ` [PATCH 1/1] " Anand Jain
2015-09-21  2:10 ` [PATCH 4/5] btrfs: Allow barrier_all_devices to do per-chunk device check Qu Wenruo
2015-10-30  8:32   ` Anand Jain
2015-10-30 11:41     ` Qu Wenruo
2015-10-30 23:52       ` Anand Jain
2015-09-21  2:10 ` [PATCH 5/5] btrfs: Cleanup num_tolerated_disk_barrier_failures Qu Wenruo
2015-11-05  0:57 ` [PATCH 0/5] Btrfs: Per-chunk degradable check Qu Wenruo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460969271-7436-1-git-send-email-anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=quwenruo@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).