Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Li Zefan and committed by
Chris Mason
85d85a74 9b89d95a

+2 -28
+2 -28
fs/btrfs/dir-item.c
··· 198 198 struct btrfs_key key; 199 199 int ins_len = mod < 0 ? -1 : 0; 200 200 int cow = mod != 0; 201 - struct btrfs_key found_key; 202 - struct extent_buffer *leaf; 203 201 204 202 key.objectid = dir; 205 203 btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY); ··· 207 209 ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow); 208 210 if (ret < 0) 209 211 return ERR_PTR(ret); 210 - if (ret > 0) { 211 - if (path->slots[0] == 0) 212 - return NULL; 213 - path->slots[0]--; 214 - } 215 - 216 - leaf = path->nodes[0]; 217 - btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); 218 - 219 - if (found_key.objectid != dir || 220 - btrfs_key_type(&found_key) != BTRFS_DIR_ITEM_KEY || 221 - found_key.offset != key.offset) 212 + if (ret > 0) 222 213 return NULL; 223 214 224 215 return btrfs_match_dir_item_name(root, path, name, name_len); ··· 302 315 struct btrfs_key key; 303 316 int ins_len = mod < 0 ? -1 : 0; 304 317 int cow = mod != 0; 305 - struct btrfs_key found_key; 306 - struct extent_buffer *leaf; 307 318 308 319 key.objectid = dir; 309 320 btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY); ··· 309 324 ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow); 310 325 if (ret < 0) 311 326 return ERR_PTR(ret); 312 - if (ret > 0) { 313 - if (path->slots[0] == 0) 314 - return NULL; 315 - path->slots[0]--; 316 - } 317 - 318 - leaf = path->nodes[0]; 319 - btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); 320 - 321 - if (found_key.objectid != dir || 322 - btrfs_key_type(&found_key) != BTRFS_XATTR_ITEM_KEY || 323 - found_key.offset != key.offset) 327 + if (ret > 0) 324 328 return NULL; 325 329 326 330 return btrfs_match_dir_item_name(root, path, name, name_len);