diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2011-03-28 02:01:25 +0000 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-04-05 01:20:24 -0400 |
commit | 08fe4db170b4193603d9d31f40ebaf652d07ac9c (patch) | |
tree | 2d0d2abe40b77266600653e399d4973a679716a9 /fs/btrfs/ioctl.c | |
parent | adae52b94e18afa1f84fab67df2a8a872c2f5533 (diff) | |
download | linux-3.10-08fe4db170b4193603d9d31f40ebaf652d07ac9c.tar.gz linux-3.10-08fe4db170b4193603d9d31f40ebaf652d07ac9c.tar.bz2 linux-3.10-08fe4db170b4193603d9d31f40ebaf652d07ac9c.zip |
Btrfs: Fix uninitialized root flags for subvolumes
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>
cc: stable@kernel.org
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r-- | fs/btrfs/ioctl.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 255c7c5279c..f9c93a9ed4a 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -373,6 +373,10 @@ static noinline int create_subvol(struct btrfs_root *root, inode_item->nbytes = cpu_to_le64(root->leafsize); inode_item->mode = cpu_to_le32(S_IFDIR | 0755); + root_item.flags = 0; + root_item.byte_limit = 0; + inode_item->flags = cpu_to_le64(BTRFS_INODE_ROOT_ITEM_INIT); + btrfs_set_root_bytenr(&root_item, leaf->start); btrfs_set_root_generation(&root_item, trans->transid); btrfs_set_root_level(&root_item, 0); |