mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	btrfs: use btrfs_for_each_slot in btrfs_search_dir_index_item
This function can be simplified by refactoring to use the new iterator macro. No functional changes. Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com> Signed-off-by: Gabriel Niebler <gniebler@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
		
							parent
							
								
									9bc5fc0417
								
							
						
					
					
						commit
						9dcbe16fcc
					
				
					 1 changed files with 6 additions and 25 deletions
				
			
		| 
						 | 
				
			
			@ -325,36 +325,15 @@ btrfs_search_dir_index_item(struct btrfs_root *root,
 | 
			
		|||
			    struct btrfs_path *path, u64 dirid,
 | 
			
		||||
			    const char *name, int name_len)
 | 
			
		||||
{
 | 
			
		||||
	struct extent_buffer *leaf;
 | 
			
		||||
	struct btrfs_dir_item *di;
 | 
			
		||||
	struct btrfs_key key;
 | 
			
		||||
	u32 nritems;
 | 
			
		||||
	int ret;
 | 
			
		||||
 | 
			
		||||
	key.objectid = dirid;
 | 
			
		||||
	key.type = BTRFS_DIR_INDEX_KEY;
 | 
			
		||||
	key.offset = 0;
 | 
			
		||||
 | 
			
		||||
	ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
 | 
			
		||||
	if (ret < 0)
 | 
			
		||||
		return ERR_PTR(ret);
 | 
			
		||||
 | 
			
		||||
	leaf = path->nodes[0];
 | 
			
		||||
	nritems = btrfs_header_nritems(leaf);
 | 
			
		||||
 | 
			
		||||
	while (1) {
 | 
			
		||||
		if (path->slots[0] >= nritems) {
 | 
			
		||||
			ret = btrfs_next_leaf(root, path);
 | 
			
		||||
			if (ret < 0)
 | 
			
		||||
				return ERR_PTR(ret);
 | 
			
		||||
			if (ret > 0)
 | 
			
		||||
				break;
 | 
			
		||||
			leaf = path->nodes[0];
 | 
			
		||||
			nritems = btrfs_header_nritems(leaf);
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
 | 
			
		||||
	btrfs_for_each_slot(root, &key, &key, path, ret) {
 | 
			
		||||
		if (key.objectid != dirid || key.type != BTRFS_DIR_INDEX_KEY)
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -362,10 +341,12 @@ btrfs_search_dir_index_item(struct btrfs_root *root,
 | 
			
		|||
					       name, name_len);
 | 
			
		||||
		if (di)
 | 
			
		||||
			return di;
 | 
			
		||||
 | 
			
		||||
		path->slots[0]++;
 | 
			
		||||
	}
 | 
			
		||||
	return NULL;
 | 
			
		||||
	/* Adjust return code if the key was not found in the next leaf. */
 | 
			
		||||
	if (ret > 0)
 | 
			
		||||
		ret = 0;
 | 
			
		||||
 | 
			
		||||
	return ERR_PTR(ret);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue