ocfs2: fix BUG when calculate new backup super
authorJoseph Qi <joseph.qi@huawei.com>
Tue, 29 Dec 2015 22:54:06 +0000 (14:54 -0800)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 22 Jan 2016 21:40:08 +0000 (21:40 +0000)
commitb0fab23d2f70d52defacaa280152b64a4fbc5c95
tree8b86a0ae29b85f7ef75e9fe751116e465a19ff7d
parent39b214ba1a357359f9c0be6ef8d21f2e5187567a
ocfs2: fix BUG when calculate new backup super

commit 5c9ee4cbf2a945271f25b89b137f2c03bbc3be33 upstream.

When resizing, it firstly extends the last gd.  Once it should backup
super in the gd, it calculates new backup super and update the
corresponding value.

But it currently doesn't consider the situation that the backup super is
already done.  And in this case, it still sets the bit in gd bitmap and
then decrease from bg_free_bits_count, which leads to a corrupted gd and
trigger the BUG in ocfs2_block_group_set_bits:

    BUG_ON(le16_to_cpu(bg->bg_free_bits_count) < num_bits);

So check whether the backup super is done and then do the updates.

Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
Reviewed-by: Jiufei Xue <xuejiufei@huawei.com>
Reviewed-by: Yiwen Jiang <jiangyiwen@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/ocfs2/resize.c