]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.32.19/btrfs-remove-bug_on-due-to-mounting-bad-filesystem.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.32.19 / btrfs-remove-bug_on-due-to-mounting-bad-filesystem.patch
1 From d7ce5843bb28ada6845ab2ae8510ba3f12d33154 Mon Sep 17 00:00:00 2001
2 From: Miao Xie <miaox@cn.fujitsu.com>
3 Date: Tue, 2 Feb 2010 08:46:44 +0000
4 Subject: Btrfs: remove BUG_ON() due to mounting bad filesystem
5
6 From: Miao Xie <miaox@cn.fujitsu.com>
7
8 commit d7ce5843bb28ada6845ab2ae8510ba3f12d33154 upstream.
9
10 Mounting a bad filesystem caused a BUG_ON(). The following is steps to
11 reproduce it.
12 # mkfs.btrfs /dev/sda2
13 # mount /dev/sda2 /mnt
14 # mkfs.btrfs /dev/sda1 /dev/sda2
15 (the program says that /dev/sda2 was mounted, and then exits. )
16 # umount /mnt
17 # mount /dev/sda1 /mnt
18
19 At the third step, mkfs.btrfs exited in the way of make filesystem. So the
20 initialization of the filesystem didn't finish. So the filesystem was bad, and
21 it caused BUG_ON() when mounting it. But BUG_ON() should be called by the wrong
22 code, not user's operation, so I think it is a bug of btrfs.
23
24 This patch fixes it.
25
26 Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
27 Signed-off-by: Chris Mason <chris.mason@oracle.com>
28 Acked-by: Jeff Mahoney <jeffm@suse.com>
29 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
30
31 ---
32 fs/btrfs/disk-io.c | 7 ++++++-
33 fs/btrfs/relocation.c | 3 ++-
34 2 files changed, 8 insertions(+), 2 deletions(-)
35
36 --- a/fs/btrfs/disk-io.c
37 +++ b/fs/btrfs/disk-io.c
38 @@ -1982,7 +1982,12 @@ struct btrfs_root *open_ctree(struct sup
39
40 if (!(sb->s_flags & MS_RDONLY)) {
41 ret = btrfs_recover_relocation(tree_root);
42 - BUG_ON(ret);
43 + if (ret < 0) {
44 + printk(KERN_WARNING
45 + "btrfs: failed to recover relocation\n");
46 + err = -EINVAL;
47 + goto fail_trans_kthread;
48 + }
49 }
50
51 location.objectid = BTRFS_FS_TREE_OBJECTID;
52 --- a/fs/btrfs/relocation.c
53 +++ b/fs/btrfs/relocation.c
54 @@ -3764,7 +3764,8 @@ out:
55 BTRFS_DATA_RELOC_TREE_OBJECTID);
56 if (IS_ERR(fs_root))
57 err = PTR_ERR(fs_root);
58 - btrfs_orphan_cleanup(fs_root);
59 + else
60 + btrfs_orphan_cleanup(fs_root);
61 }
62 return err;
63 }