diff options
-rw-r--r-- | fs/btrfs/TODO | 2 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 1 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 1 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 21 | ||||
-rw-r--r-- | fs/btrfs/inode-map.c | 27 |
5 files changed, 39 insertions, 13 deletions
diff --git a/fs/btrfs/TODO b/fs/btrfs/TODO index e9371385ccc0..db986c46a554 100644 --- a/fs/btrfs/TODO +++ b/fs/btrfs/TODO | |||
@@ -1,9 +1,7 @@ | |||
1 | * cleanup, add more error checking, get rid of BUG_ONs | 1 | * cleanup, add more error checking, get rid of BUG_ONs |
2 | * Fix ENOSPC handling | 2 | * Fix ENOSPC handling |
3 | * Do checksumming | ||
4 | * Add block mapping tree (simple dm layer) | 3 | * Add block mapping tree (simple dm layer) |
5 | * Make allocator smarter | 4 | * Make allocator smarter |
6 | * make level a field in header | ||
7 | * add a block group to struct inode | 5 | * add a block group to struct inode |
8 | * Make directory hashing work on 32 bit | 6 | * Make directory hashing work on 32 bit |
9 | * Make sure nobh stuff is working properly for cows | 7 | * Make sure nobh stuff is working properly for cows |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index d8e03bd797ff..41cc013ef08d 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -238,7 +238,6 @@ struct btrfs_fs_info { | |||
238 | struct radix_tree_root pending_del_radix; | 238 | struct radix_tree_root pending_del_radix; |
239 | struct radix_tree_root pinned_radix; | 239 | struct radix_tree_root pinned_radix; |
240 | u64 last_inode_alloc; | 240 | u64 last_inode_alloc; |
241 | u64 last_inode_alloc_dirid; | ||
242 | u64 generation; | 241 | u64 generation; |
243 | struct btrfs_transaction *running_transaction; | 242 | struct btrfs_transaction *running_transaction; |
244 | struct btrfs_super_block *disk_super; | 243 | struct btrfs_super_block *disk_super; |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 055cd45e802e..de9ee3aa0aad 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -311,7 +311,6 @@ struct btrfs_root *open_ctree(struct super_block *sb) | |||
311 | fs_info->extent_root = extent_root; | 311 | fs_info->extent_root = extent_root; |
312 | fs_info->inode_root = inode_root; | 312 | fs_info->inode_root = inode_root; |
313 | fs_info->last_inode_alloc = 0; | 313 | fs_info->last_inode_alloc = 0; |
314 | fs_info->last_inode_alloc_dirid = 0; | ||
315 | fs_info->sb = sb; | 314 | fs_info->sb = sb; |
316 | fs_info->btree_inode = new_inode(sb); | 315 | fs_info->btree_inode = new_inode(sb); |
317 | fs_info->btree_inode->i_ino = 1; | 316 | fs_info->btree_inode->i_ino = 1; |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index cd40a08dd8a6..688aa861a928 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -339,13 +339,30 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root | |||
339 | int total_needed = num_blocks; | 339 | int total_needed = num_blocks; |
340 | int level; | 340 | int level; |
341 | 341 | ||
342 | path = btrfs_alloc_path(); | ||
343 | ins->flags = 0; | ||
344 | btrfs_set_key_type(ins, BTRFS_EXTENT_ITEM_KEY); | ||
345 | |||
342 | level = btrfs_header_level(btrfs_buffer_header(root->node)); | 346 | level = btrfs_header_level(btrfs_buffer_header(root->node)); |
343 | total_needed += (level + 1) * 3; | 347 | total_needed += (level + 1) * 3; |
348 | if (root->fs_info->last_insert.objectid == 0 && search_end == (u64)-1) { | ||
349 | struct btrfs_disk_key *last_key; | ||
350 | btrfs_init_path(path); | ||
351 | ins->objectid = (u64)-1; | ||
352 | ins->offset = (u64)-1; | ||
353 | ret = btrfs_search_slot(trans, root, ins, path, 0, 0); | ||
354 | if (ret < 0) | ||
355 | goto error; | ||
356 | BUG_ON(ret == 0); | ||
357 | if (path->slots[0] > 0) | ||
358 | path->slots[0]--; | ||
359 | l = btrfs_buffer_leaf(path->nodes[0]); | ||
360 | last_key = &l->items[path->slots[0]].key; | ||
361 | search_start = btrfs_disk_key_objectid(last_key); | ||
362 | } | ||
344 | if (root->fs_info->last_insert.objectid > search_start) | 363 | if (root->fs_info->last_insert.objectid > search_start) |
345 | search_start = root->fs_info->last_insert.objectid; | 364 | search_start = root->fs_info->last_insert.objectid; |
346 | 365 | ||
347 | ins->flags = 0; | ||
348 | btrfs_set_key_type(ins, BTRFS_EXTENT_ITEM_KEY); | ||
349 | path = btrfs_alloc_path(); | 366 | path = btrfs_alloc_path(); |
350 | 367 | ||
351 | check_failed: | 368 | check_failed: |
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c index b3de823eb628..329edb42897e 100644 --- a/fs/btrfs/inode-map.c +++ b/fs/btrfs/inode-map.c | |||
@@ -22,17 +22,31 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, | |||
22 | struct btrfs_key search_key; | 22 | struct btrfs_key search_key; |
23 | u64 search_start = dirid; | 23 | u64 search_start = dirid; |
24 | 24 | ||
25 | if (fs_root->fs_info->last_inode_alloc_dirid == dirid) | 25 | path = btrfs_alloc_path(); |
26 | search_start = fs_root->fs_info->last_inode_alloc; | 26 | BUG_ON(!path); |
27 | search_key.flags = 0; | ||
28 | btrfs_set_key_type(&search_key, BTRFS_INODE_MAP_ITEM_KEY); | ||
27 | 29 | ||
30 | search_start = fs_root->fs_info->last_inode_alloc; | ||
31 | if (search_start == 0) { | ||
32 | struct btrfs_disk_key *last_key; | ||
33 | btrfs_init_path(path); | ||
34 | search_key.objectid = (u64)-1; | ||
35 | search_key.offset = (u64)-1; | ||
36 | ret = btrfs_search_slot(trans, root, &search_key, path, 0, 0); | ||
37 | if (ret < 0) | ||
38 | goto error; | ||
39 | BUG_ON(ret == 0); | ||
40 | if (path->slots[0] > 0) | ||
41 | path->slots[0]--; | ||
42 | l = btrfs_buffer_leaf(path->nodes[0]); | ||
43 | last_key = &l->items[path->slots[0]].key; | ||
44 | search_start = btrfs_disk_key_objectid(last_key); | ||
45 | } | ||
28 | search_start = max(search_start, BTRFS_FIRST_FREE_OBJECTID); | 46 | search_start = max(search_start, BTRFS_FIRST_FREE_OBJECTID); |
29 | search_key.objectid = search_start; | 47 | search_key.objectid = search_start; |
30 | search_key.flags = 0; | ||
31 | btrfs_set_key_type(&search_key, BTRFS_INODE_MAP_ITEM_KEY); | ||
32 | search_key.offset = 0; | 48 | search_key.offset = 0; |
33 | 49 | ||
34 | path = btrfs_alloc_path(); | ||
35 | BUG_ON(!path); | ||
36 | btrfs_init_path(path); | 50 | btrfs_init_path(path); |
37 | start_found = 0; | 51 | start_found = 0; |
38 | ret = btrfs_search_slot(trans, root, &search_key, path, 0, 0); | 52 | ret = btrfs_search_slot(trans, root, &search_key, path, 0, 0); |
@@ -79,7 +93,6 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, | |||
79 | // FIXME -ENOSPC | 93 | // FIXME -ENOSPC |
80 | found: | 94 | found: |
81 | root->fs_info->last_inode_alloc = *objectid; | 95 | root->fs_info->last_inode_alloc = *objectid; |
82 | root->fs_info->last_inode_alloc_dirid = dirid; | ||
83 | btrfs_release_path(root, path); | 96 | btrfs_release_path(root, path); |
84 | btrfs_free_path(path); | 97 | btrfs_free_path(path); |
85 | BUG_ON(*objectid < search_start); | 98 | BUG_ON(*objectid < search_start); |