aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode-map.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-04-10 12:13:09 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-04-10 12:13:09 -0400
commit1b05da2ee6217e7d55460d04335813fec25be4ca (patch)
tree250a3e789777c7a6d17dccf0bf5a57b00ef1bdac /fs/btrfs/inode-map.c
parentc5739bba5260a59cebd20a51a55080592c8d3b07 (diff)
Btrfs: drop the inode map tree
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode-map.c')
-rw-r--r--fs/btrfs/inode-map.c65
1 files changed, 4 insertions, 61 deletions
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
index f665221409ac..318e27a6378b 100644
--- a/fs/btrfs/inode-map.c
+++ b/fs/btrfs/inode-map.c
@@ -3,12 +3,11 @@
3#include "disk-io.h" 3#include "disk-io.h"
4#include "transaction.h" 4#include "transaction.h"
5 5
6int btrfs_find_highest_inode(struct btrfs_root *fs_root, u64 *objectid) 6int btrfs_find_highest_inode(struct btrfs_root *root, u64 *objectid)
7{ 7{
8 struct btrfs_path *path; 8 struct btrfs_path *path;
9 int ret; 9 int ret;
10 struct btrfs_leaf *l; 10 struct btrfs_leaf *l;
11 struct btrfs_root *root = fs_root->fs_info->inode_root;
12 struct btrfs_key search_key; 11 struct btrfs_key search_key;
13 int slot; 12 int slot;
14 13
@@ -38,7 +37,7 @@ error:
38 * walks the btree of allocated inodes and find a hole. 37 * walks the btree of allocated inodes and find a hole.
39 */ 38 */
40int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, 39int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
41 struct btrfs_root *fs_root, 40 struct btrfs_root *root,
42 u64 dirid, u64 *objectid) 41 u64 dirid, u64 *objectid)
43{ 42{
44 struct btrfs_path *path; 43 struct btrfs_path *path;
@@ -49,16 +48,13 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
49 u64 last_ino = 0; 48 u64 last_ino = 0;
50 int start_found; 49 int start_found;
51 struct btrfs_leaf *l; 50 struct btrfs_leaf *l;
52 struct btrfs_root *root = fs_root->fs_info->inode_root;
53 struct btrfs_key search_key; 51 struct btrfs_key search_key;
54 u64 search_start = dirid; 52 u64 search_start = dirid;
55 53
56 path = btrfs_alloc_path(); 54 path = btrfs_alloc_path();
57 BUG_ON(!path); 55 BUG_ON(!path);
58 search_key.flags = 0; 56 search_key.flags = 0;
59 btrfs_set_key_type(&search_key, BTRFS_INODE_MAP_ITEM_KEY); 57 search_start = root->last_inode_alloc;
60
61 search_start = fs_root->fs_info->last_inode_alloc;
62 search_start = max(search_start, BTRFS_FIRST_FREE_OBJECTID); 58 search_start = max(search_start, BTRFS_FIRST_FREE_OBJECTID);
63 search_key.objectid = search_start; 59 search_key.objectid = search_start;
64 search_key.offset = 0; 60 search_key.offset = 0;
@@ -108,7 +104,7 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
108 } 104 }
109 // FIXME -ENOSPC 105 // FIXME -ENOSPC
110found: 106found:
111 root->fs_info->last_inode_alloc = *objectid; 107 root->last_inode_alloc = *objectid;
112 btrfs_release_path(root, path); 108 btrfs_release_path(root, path);
113 btrfs_free_path(path); 109 btrfs_free_path(path);
114 BUG_ON(*objectid < search_start); 110 BUG_ON(*objectid < search_start);
@@ -118,56 +114,3 @@ error:
118 btrfs_free_path(path); 114 btrfs_free_path(path);
119 return ret; 115 return ret;
120} 116}
121
122int btrfs_insert_inode_map(struct btrfs_trans_handle *trans,
123 struct btrfs_root *fs_root,
124 u64 objectid, struct btrfs_key *location)
125{
126 int ret = 0;
127 struct btrfs_path *path;
128 struct btrfs_inode_map_item *inode_item;
129 struct btrfs_key key;
130 struct btrfs_root *inode_root = fs_root->fs_info->inode_root;
131
132 key.objectid = objectid;
133 key.flags = 0;
134 btrfs_set_key_type(&key, BTRFS_INODE_MAP_ITEM_KEY);
135 key.offset = 0;
136 path = btrfs_alloc_path();
137 BUG_ON(!path);
138 btrfs_init_path(path);
139 ret = btrfs_insert_empty_item(trans, inode_root, path, &key,
140 sizeof(struct btrfs_inode_map_item));
141 if (ret)
142 goto out;
143
144 inode_item = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]),
145 path->slots[0], struct btrfs_inode_map_item);
146 btrfs_cpu_key_to_disk(&inode_item->key, location);
147 btrfs_mark_buffer_dirty(path->nodes[0]);
148 if (objectid > fs_root->fs_info->highest_inode)
149 fs_root->fs_info->highest_inode = objectid;
150out:
151 btrfs_release_path(inode_root, path);
152 btrfs_free_path(path);
153 return ret;
154}
155
156int btrfs_lookup_inode_map(struct btrfs_trans_handle *trans,
157 struct btrfs_root *fs_root, struct btrfs_path *path,
158 u64 objectid, int mod)
159{
160 int ret;
161 struct btrfs_key key;
162 int ins_len = mod < 0 ? -1 : 0;
163 int cow = mod != 0;
164 struct btrfs_root *inode_root = fs_root->fs_info->inode_root;
165
166 key.objectid = objectid;
167 key.flags = 0;
168 key.offset = 0;
169 btrfs_set_key_type(&key, BTRFS_INODE_MAP_ITEM_KEY);
170 ret = btrfs_search_slot(trans, inode_root, &key, path, ins_len, cow);
171 return ret;
172}
173