diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2011-07-13 23:17:52 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-08-01 14:30:48 -0400 |
commit | 85d85a743da894029723e002eb556ceeebc03658 (patch) | |
tree | fb9cc28ea108c85785ac38f92a16a60467452dd1 /fs | |
parent | 9b89d95a143bb0a9abc4ba0fdcdda78211930f1a (diff) |
Btrfs: remove redundant code for dir item lookup
When we search a dir item with a specific hash code, we can
just return NULL without further checking if btrfs_search_slot()
returns 1.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/dir-item.c | 30 |
1 files changed, 2 insertions, 28 deletions
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c index c360a848d97..31d84e78129 100644 --- a/fs/btrfs/dir-item.c +++ b/fs/btrfs/dir-item.c | |||
@@ -198,8 +198,6 @@ struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, | |||
198 | struct btrfs_key key; | 198 | struct btrfs_key key; |
199 | int ins_len = mod < 0 ? -1 : 0; | 199 | int ins_len = mod < 0 ? -1 : 0; |
200 | int cow = mod != 0; | 200 | int cow = mod != 0; |
201 | struct btrfs_key found_key; | ||
202 | struct extent_buffer *leaf; | ||
203 | 201 | ||
204 | key.objectid = dir; | 202 | key.objectid = dir; |
205 | btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY); | 203 | btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY); |
@@ -209,18 +207,7 @@ struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, | |||
209 | ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow); | 207 | ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow); |
210 | if (ret < 0) | 208 | if (ret < 0) |
211 | return ERR_PTR(ret); | 209 | return ERR_PTR(ret); |
212 | if (ret > 0) { | 210 | if (ret > 0) |
213 | if (path->slots[0] == 0) | ||
214 | return NULL; | ||
215 | path->slots[0]--; | ||
216 | } | ||
217 | |||
218 | leaf = path->nodes[0]; | ||
219 | btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); | ||
220 | |||
221 | if (found_key.objectid != dir || | ||
222 | btrfs_key_type(&found_key) != BTRFS_DIR_ITEM_KEY || | ||
223 | found_key.offset != key.offset) | ||
224 | return NULL; | 211 | return NULL; |
225 | 212 | ||
226 | return btrfs_match_dir_item_name(root, path, name, name_len); | 213 | return btrfs_match_dir_item_name(root, path, name, name_len); |
@@ -315,8 +302,6 @@ struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans, | |||
315 | struct btrfs_key key; | 302 | struct btrfs_key key; |
316 | int ins_len = mod < 0 ? -1 : 0; | 303 | int ins_len = mod < 0 ? -1 : 0; |
317 | int cow = mod != 0; | 304 | int cow = mod != 0; |
318 | struct btrfs_key found_key; | ||
319 | struct extent_buffer *leaf; | ||
320 | 305 | ||
321 | key.objectid = dir; | 306 | key.objectid = dir; |
322 | btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY); | 307 | btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY); |
@@ -324,18 +309,7 @@ struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans, | |||
324 | ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow); | 309 | ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow); |
325 | if (ret < 0) | 310 | if (ret < 0) |
326 | return ERR_PTR(ret); | 311 | return ERR_PTR(ret); |
327 | if (ret > 0) { | 312 | if (ret > 0) |
328 | if (path->slots[0] == 0) | ||
329 | return NULL; | ||
330 | path->slots[0]--; | ||
331 | } | ||
332 | |||
333 | leaf = path->nodes[0]; | ||
334 | btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); | ||
335 | |||
336 | if (found_key.objectid != dir || | ||
337 | btrfs_key_type(&found_key) != BTRFS_XATTR_ITEM_KEY || | ||
338 | found_key.offset != key.offset) | ||
339 | return NULL; | 313 | return NULL; |
340 | 314 | ||
341 | return btrfs_match_dir_item_name(root, path, name, name_len); | 315 | return btrfs_match_dir_item_name(root, path, name, name_len); |