aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2011-03-27 22:01:25 -0400
committerChris Mason <chris.mason@oracle.com>2011-04-05 01:20:24 -0400
commit08fe4db170b4193603d9d31f40ebaf652d07ac9c (patch)
tree2d0d2abe40b77266600653e399d4973a679716a9 /fs/btrfs/ctree.h
parentadae52b94e18afa1f84fab67df2a8a872c2f5533 (diff)
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/ctree.h')
-rw-r--r--fs/btrfs/ctree.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index d47ce8307854..3458b5725540 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1284,6 +1284,8 @@ struct btrfs_root {
1284#define BTRFS_INODE_DIRSYNC (1 << 10) 1284#define BTRFS_INODE_DIRSYNC (1 << 10)
1285#define BTRFS_INODE_COMPRESS (1 << 11) 1285#define BTRFS_INODE_COMPRESS (1 << 11)
1286 1286
1287#define BTRFS_INODE_ROOT_ITEM_INIT (1 << 31)
1288
1287/* some macros to generate set/get funcs for the struct fields. This 1289/* some macros to generate set/get funcs for the struct fields. This
1288 * assumes there is a lefoo_to_cpu for every type, so lets make a simple 1290 * assumes there is a lefoo_to_cpu for every type, so lets make a simple
1289 * one for u8: 1291 * one for u8:
@@ -2359,6 +2361,8 @@ int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid);
2359int btrfs_find_orphan_roots(struct btrfs_root *tree_root); 2361int btrfs_find_orphan_roots(struct btrfs_root *tree_root);
2360int btrfs_set_root_node(struct btrfs_root_item *item, 2362int btrfs_set_root_node(struct btrfs_root_item *item,
2361 struct extent_buffer *node); 2363 struct extent_buffer *node);
2364void btrfs_check_and_init_root_item(struct btrfs_root_item *item);
2365
2362/* dir-item.c */ 2366/* dir-item.c */
2363int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, 2367int btrfs_insert_dir_item(struct btrfs_trans_handle *trans,
2364 struct btrfs_root *root, const char *name, 2368 struct btrfs_root *root, const char *name,