aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorYan Zheng <zheng.yan@oracle.com>2008-11-17 21:11:30 -0500
committerChris Mason <chris.mason@oracle.com>2008-11-17 21:11:30 -0500
commit2b82032c34ec40515d3c45c36cd1961f37977de8 (patch)
treefbdfe7b13dd51983dfca4aeb75983b37ee186ff9 /fs/btrfs/ctree.h
parentc146afad2c7fea6a366d4945c1bab9b03880f526 (diff)
Btrfs: Seed device support
Seed device is a special btrfs with SEEDING super flag set and can only be mounted in read-only mode. Seed devices allow people to create new btrfs on top of it. The new FS contains the same contents as the seed device, but it can be mounted in read-write mode. This patch does the following: 1) split code in btrfs_alloc_chunk into two parts. The first part does makes the newly allocated chunk usable, but does not do any operation that modifies the chunk tree. The second part does the the chunk tree modifications. This division is for the bootstrap step of adding storage to the seed device. 2) Update device management code to handle seed device. The basic idea is: For an FS grown from seed devices, its seed devices are put into a list. Seed devices are opened on demand at mounting time. If any seed device is missing or has been changed, btrfs kernel module will refuse to mount the FS. 3) make btrfs_find_block_group not return NULL when all block groups are read-only. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index c4c6c127323b..5ff74282a620 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -177,6 +177,9 @@ struct btrfs_dev_item {
177 /* type and info about this device */ 177 /* type and info about this device */
178 __le64 type; 178 __le64 type;
179 179
180 /* expected generation for this device */
181 __le64 generation;
182
180 /* grouping information for allocation decisions */ 183 /* grouping information for allocation decisions */
181 __le32 dev_group; 184 __le32 dev_group;
182 185
@@ -188,6 +191,9 @@ struct btrfs_dev_item {
188 191
189 /* btrfs generated uuid for this device */ 192 /* btrfs generated uuid for this device */
190 u8 uuid[BTRFS_UUID_SIZE]; 193 u8 uuid[BTRFS_UUID_SIZE];
194
195 /* uuid of FS who owns this device */
196 u8 fsid[BTRFS_UUID_SIZE];
191} __attribute__ ((__packed__)); 197} __attribute__ ((__packed__));
192 198
193struct btrfs_stripe { 199struct btrfs_stripe {
@@ -263,6 +269,7 @@ struct btrfs_header {
263 sizeof(struct btrfs_item) - \ 269 sizeof(struct btrfs_item) - \
264 sizeof(struct btrfs_file_extent_item)) 270 sizeof(struct btrfs_file_extent_item))
265 271
272#define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)
266 273
267/* 274/*
268 * this is a very generous portion of the super block, giving us 275 * this is a very generous portion of the super block, giving us
@@ -278,7 +285,7 @@ struct btrfs_header {
278struct btrfs_super_block { 285struct btrfs_super_block {
279 u8 csum[BTRFS_CSUM_SIZE]; 286 u8 csum[BTRFS_CSUM_SIZE];
280 /* the first 4 fields must match struct btrfs_header */ 287 /* the first 4 fields must match struct btrfs_header */
281 u8 fsid[16]; /* FS specific uuid */ 288 u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
282 __le64 bytenr; /* this block number */ 289 __le64 bytenr; /* this block number */
283 __le64 flags; 290 __le64 flags;
284 291
@@ -941,6 +948,7 @@ BTRFS_SETGET_FUNCS(device_id, struct btrfs_dev_item, devid, 64);
941BTRFS_SETGET_FUNCS(device_group, struct btrfs_dev_item, dev_group, 32); 948BTRFS_SETGET_FUNCS(device_group, struct btrfs_dev_item, dev_group, 32);
942BTRFS_SETGET_FUNCS(device_seek_speed, struct btrfs_dev_item, seek_speed, 8); 949BTRFS_SETGET_FUNCS(device_seek_speed, struct btrfs_dev_item, seek_speed, 8);
943BTRFS_SETGET_FUNCS(device_bandwidth, struct btrfs_dev_item, bandwidth, 8); 950BTRFS_SETGET_FUNCS(device_bandwidth, struct btrfs_dev_item, bandwidth, 8);
951BTRFS_SETGET_FUNCS(device_generation, struct btrfs_dev_item, generation, 64);
944 952
945BTRFS_SETGET_STACK_FUNCS(stack_device_type, struct btrfs_dev_item, type, 64); 953BTRFS_SETGET_STACK_FUNCS(stack_device_type, struct btrfs_dev_item, type, 64);
946BTRFS_SETGET_STACK_FUNCS(stack_device_total_bytes, struct btrfs_dev_item, 954BTRFS_SETGET_STACK_FUNCS(stack_device_total_bytes, struct btrfs_dev_item,
@@ -960,12 +968,19 @@ BTRFS_SETGET_STACK_FUNCS(stack_device_seek_speed, struct btrfs_dev_item,
960 seek_speed, 8); 968 seek_speed, 8);
961BTRFS_SETGET_STACK_FUNCS(stack_device_bandwidth, struct btrfs_dev_item, 969BTRFS_SETGET_STACK_FUNCS(stack_device_bandwidth, struct btrfs_dev_item,
962 bandwidth, 8); 970 bandwidth, 8);
971BTRFS_SETGET_STACK_FUNCS(stack_device_generation, struct btrfs_dev_item,
972 generation, 64);
963 973
964static inline char *btrfs_device_uuid(struct btrfs_dev_item *d) 974static inline char *btrfs_device_uuid(struct btrfs_dev_item *d)
965{ 975{
966 return (char *)d + offsetof(struct btrfs_dev_item, uuid); 976 return (char *)d + offsetof(struct btrfs_dev_item, uuid);
967} 977}
968 978
979static inline char *btrfs_device_fsid(struct btrfs_dev_item *d)
980{
981 return (char *)d + offsetof(struct btrfs_dev_item, fsid);
982}
983
969BTRFS_SETGET_FUNCS(chunk_length, struct btrfs_chunk, length, 64); 984BTRFS_SETGET_FUNCS(chunk_length, struct btrfs_chunk, length, 64);
970BTRFS_SETGET_FUNCS(chunk_owner, struct btrfs_chunk, owner, 64); 985BTRFS_SETGET_FUNCS(chunk_owner, struct btrfs_chunk, owner, 64);
971BTRFS_SETGET_FUNCS(chunk_stripe_len, struct btrfs_chunk, stripe_len, 64); 986BTRFS_SETGET_FUNCS(chunk_stripe_len, struct btrfs_chunk, stripe_len, 64);
@@ -1661,6 +1676,7 @@ int btrfs_reloc_tree_cache_ref(struct btrfs_trans_handle *trans,
1661 struct extent_buffer *buf, u64 orig_start); 1676 struct extent_buffer *buf, u64 orig_start);
1662int btrfs_add_dead_reloc_root(struct btrfs_root *root); 1677int btrfs_add_dead_reloc_root(struct btrfs_root *root);
1663int btrfs_cleanup_reloc_trees(struct btrfs_root *root); 1678int btrfs_cleanup_reloc_trees(struct btrfs_root *root);
1679u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags);
1664/* ctree.c */ 1680/* ctree.c */
1665int btrfs_previous_item(struct btrfs_root *root, 1681int btrfs_previous_item(struct btrfs_root *root,
1666 struct btrfs_path *path, u64 min_objectid, 1682 struct btrfs_path *path, u64 min_objectid,