diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-04-18 16:15:28 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-04-18 16:15:28 -0400 |
commit | a429e51371eee3c989160c003ee40bc3947c6a76 (patch) | |
tree | 863b55de8823be579264260a51407cd90aac103d /fs/btrfs/dir-item.c | |
parent | 70b2befd0c8a4064715d8b340270650cc9d15af8 (diff) |
Btrfs: working file_write, reorganized key flags
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/dir-item.c')
-rw-r--r-- | fs/btrfs/dir-item.c | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c index cd4137a8b87e..a43deb726486 100644 --- a/fs/btrfs/dir-item.c +++ b/fs/btrfs/dir-item.c | |||
@@ -58,30 +58,6 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | |||
58 | 58 | ||
59 | btrfs_memcpy(root, path->nodes[0]->b_data, name_ptr, name, name_len); | 59 | btrfs_memcpy(root, path->nodes[0]->b_data, name_ptr, name, name_len); |
60 | btrfs_mark_buffer_dirty(path->nodes[0]); | 60 | btrfs_mark_buffer_dirty(path->nodes[0]); |
61 | |||
62 | /* FIXME, use some real flag for selecting the extra index */ | ||
63 | if (root == root->fs_info->tree_root) | ||
64 | goto out; | ||
65 | |||
66 | btrfs_release_path(root, path); | ||
67 | |||
68 | btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY); | ||
69 | key.offset = location->objectid; | ||
70 | ret = insert_with_overflow(trans, root, path, &key, data_size); | ||
71 | // FIXME clear the dirindex bit | ||
72 | if (ret) | ||
73 | goto out; | ||
74 | |||
75 | dir_item = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]), | ||
76 | path->slots[0], | ||
77 | struct btrfs_dir_item); | ||
78 | btrfs_cpu_key_to_disk(&dir_item->location, location); | ||
79 | btrfs_set_dir_type(dir_item, type); | ||
80 | btrfs_set_dir_flags(dir_item, 0); | ||
81 | btrfs_set_dir_name_len(dir_item, name_len); | ||
82 | name_ptr = (char *)(dir_item + 1); | ||
83 | btrfs_memcpy(root, path->nodes[0]->b_data, name_ptr, name, name_len); | ||
84 | btrfs_mark_buffer_dirty(path->nodes[0]); | ||
85 | out: | 61 | out: |
86 | btrfs_release_path(root, path); | 62 | btrfs_release_path(root, path); |
87 | btrfs_free_path(path); | 63 | btrfs_free_path(path); |
@@ -135,52 +111,6 @@ int btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | |||
135 | return 1; | 111 | return 1; |
136 | } | 112 | } |
137 | 113 | ||
138 | int btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans, | ||
139 | struct btrfs_root *root, | ||
140 | struct btrfs_path *path, u64 dir, | ||
141 | u64 objectid, int mod) | ||
142 | { | ||
143 | int ret; | ||
144 | struct btrfs_key key; | ||
145 | int ins_len = mod < 0 ? -1 : 0; | ||
146 | int cow = mod != 0; | ||
147 | struct btrfs_disk_key *found_key; | ||
148 | struct btrfs_leaf *leaf; | ||
149 | int overflow = 0; | ||
150 | |||
151 | key.objectid = dir; | ||
152 | key.flags = 0; | ||
153 | btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY); | ||
154 | key.offset = objectid; | ||
155 | |||
156 | while(1) { | ||
157 | btrfs_set_key_overflow(&key, overflow); | ||
158 | ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow); | ||
159 | if (ret < 0) | ||
160 | return ret; | ||
161 | if (ret > 0) { | ||
162 | if (overflow >= BTRFS_KEY_OVERFLOW_MAX) | ||
163 | return 1; | ||
164 | overflow++; | ||
165 | btrfs_set_key_overflow(&key, overflow); | ||
166 | btrfs_release_path(root, path); | ||
167 | continue; | ||
168 | } else { | ||
169 | /* found */ | ||
170 | break; | ||
171 | } | ||
172 | } | ||
173 | leaf = btrfs_buffer_leaf(path->nodes[0]); | ||
174 | found_key = &leaf->items[path->slots[0]].key; | ||
175 | |||
176 | if (btrfs_disk_key_objectid(found_key) != dir || | ||
177 | btrfs_disk_key_type(found_key) != BTRFS_DIR_INDEX_KEY) | ||
178 | return 1; | ||
179 | if (btrfs_disk_key_offset(found_key) == objectid) | ||
180 | return 0; | ||
181 | return 1; | ||
182 | } | ||
183 | |||
184 | int btrfs_match_dir_item_name(struct btrfs_root *root, | 114 | int btrfs_match_dir_item_name(struct btrfs_root *root, |
185 | struct btrfs_path *path, | 115 | struct btrfs_path *path, |
186 | const char *name, int name_len) | 116 | const char *name, int name_len) |