• Qu Wenruo's avatar
    btrfs: do not utilize goto to implement delayed inode ref deletion · 9ba7c686
    Qu Wenruo authored
    [PROBLEM]
    The function __btrfs_update_delayed_inode() is doing something not
    meeting the code standard of today:
    
    	path->slots[0]++
    	if (path->slots[0] >= btrfs_header_nritems(leaf))
    		goto search;
    again:
    	if (!is_the_target_inode_ref())
    		goto out;
    	ret = btrfs_delete_item();
    	/* Some cleanup. */
    	return ret;
    
    search:
    	ret = search_for_the_last_inode_ref();
    	goto again;
    
    With the tag named "again", it's pretty common to think it's a loop, but
    the truth is, we only need to do the search once, to locate the last
    (also the first, since there should only be one INODE_REF or
    INODE_EXTREF now) ref of the inode.
    
    [FIX]
    Instead of the weird jumps, just do them in a stream-lined fashion.
    This removes those weird labels, and add extra comments on why we can do
    the different searches.
    Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    9ba7c686
delayed-inode.c 61.3 KB