aboutsummaryrefslogtreecommitdiff
path: root/fs/btrfs/inode-map.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-04-04 15:27:52 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-04-04 15:27:52 -0400
commitb1a4d96509a78ad234d94e0b914b289c60d2969d (patch)
treea6e9ff68dc1ff89097bf56355585f23bec70f847 /fs/btrfs/inode-map.c
parente8f05c4508aed906146919f2efa89242a7f90a8b (diff)
Btrfs: tweak the inode-map and free extent search starts on cold mount
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode-map.c')
-rw-r--r--fs/btrfs/inode-map.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
index b3de823eb62..329edb42897 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,
struct btrfs_key search_key;
u64 search_start = dirid;
- if (fs_root->fs_info->last_inode_alloc_dirid == dirid)
- search_start = fs_root->fs_info->last_inode_alloc;
+ path = btrfs_alloc_path();
+ BUG_ON(!path);
+ search_key.flags = 0;
+ btrfs_set_key_type(&search_key, BTRFS_INODE_MAP_ITEM_KEY);
+ search_start = fs_root->fs_info->last_inode_alloc;
+ if (search_start == 0) {
+ struct btrfs_disk_key *last_key;
+ btrfs_init_path(path);
+ search_key.objectid = (u64)-1;
+ search_key.offset = (u64)-1;
+ ret = btrfs_search_slot(trans, root, &search_key, path, 0, 0);
+ if (ret < 0)
+ goto error;
+ BUG_ON(ret == 0);
+ if (path->slots[0] > 0)
+ path->slots[0]--;
+ l = btrfs_buffer_leaf(path->nodes[0]);
+ last_key = &l->items[path->slots[0]].key;
+ search_start = btrfs_disk_key_objectid(last_key);
+ }
search_start = max(search_start, BTRFS_FIRST_FREE_OBJECTID);
search_key.objectid = search_start;
- search_key.flags = 0;
- btrfs_set_key_type(&search_key, BTRFS_INODE_MAP_ITEM_KEY);
search_key.offset = 0;
- path = btrfs_alloc_path();
- BUG_ON(!path);
btrfs_init_path(path);
start_found = 0;
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,
// FIXME -ENOSPC
found:
root->fs_info->last_inode_alloc = *objectid;
- root->fs_info->last_inode_alloc_dirid = dirid;
btrfs_release_path(root, path);
btrfs_free_path(path);
BUG_ON(*objectid < search_start);