Btrfs: Fix uninitialized root flags for subvolumes
authorLi Zefan <lizf@cn.fujitsu.com>
Mon, 28 Mar 2011 02:01:25 +0000 (02:01 +0000)
committerBrad Figg <brad.figg@canonical.com>
Wed, 27 Apr 2011 18:40:56 +0000 (11:40 -0700)
commite35675d922d2df7be295048d2b1a7bd7778ef319
tree23bbe9f1d494b9eaf75fb36f1667ccba786b369b
parenta0345bfefd08584cd72654f8d832611aed25a593
Btrfs: Fix uninitialized root flags for subvolumes

BugLink: http://bugs.launchpad.net/bugs/761134

commit 08fe4db170b4193603d9d31f40ebaf652d07ac9c upstream.

root_item->flags and root_item->byte_limit are not initialized when
a subvolume is created. This bug is not revealed until we added
readonly snapshot support - now you mount a btrfs filesystem and you
may find the subvolumes in it are readonly.

To work around this problem, we steal a bit from root_item->inode_item->flags,
and use it to indicate if those fields have been properly initialized.
When we read a tree root from disk, we check if the bit is set, and if
not we'll set the flag and initialize the two fields of the root item.

Reported-by: Andreas Philipp <philipp.andreas@gmail.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Tested-by: Andreas Philipp <philipp.andreas@gmail.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/ioctl.c
fs/btrfs/root-tree.c
fs/btrfs/transaction.c