Re: [PATCH 5/6] Btrfs: grab write lock directly if write_lock_level is the max level

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 15.05.2018 20:52, Liu Bo wrote:
> In case of (cow && (p->keep_locks || p->lowest_level)), write_lock_level
> is the max level, and we should grab write lock of root node from the very
> beginning.

THis needs to be expanded to explain what are the adverse effects (if
any) without this commit. And then explain how this commit actually
improve things.

> 
> Signed-off-by: Liu Bo <bo.liu@xxxxxxxxxxxxxxxxx>
> ---
>  fs/btrfs/ctree.c | 29 ++++++++++++++++-------------
>  1 file changed, 16 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
> index cf34eca41d4e..f7c3f581f647 100644
> --- a/fs/btrfs/ctree.c
> +++ b/fs/btrfs/ctree.c
> @@ -2633,20 +2633,23 @@ static struct extent_buffer *btrfs_search_slot_get_root(struct btrfs_root *root,
>  		goto out;
>  	}
>  
> -	/*
> -	 * we don't know the level of the root node until we actually
> -	 * have it read locked
> -	 */
> -	b = btrfs_read_lock_root_node(root);
> -	level = btrfs_header_level(b);
> -	if (level > write_lock_level)
> -		goto out;
> +	if (write_lock_level < BTRFS_MAX_LEVEL) {
> +		/*
> +		 * we don't know the level of the root node until we actually
> +		 * have it read locked
> +		 */
> +		b = btrfs_read_lock_root_node(root);
> +		level = btrfs_header_level(b);
> +		if (level > write_lock_level)
> +			goto out;
> +
> +		/*
> +		 * whoops, must trade for write lock
> +		 */
> +		btrfs_tree_read_unlock(b);
> +		free_extent_buffer(b);
> +	}

Here just seems you are adding 1 extra branch so more context please.

>  
> -	/*
> -	 * whoops, must trade for write lock
> -	 */
> -	btrfs_tree_read_unlock(b);
> -	free_extent_buffer(b);
>  	b = btrfs_lock_root_node(root);
>  	root_lock = BTRFS_WRITE_LOCK;
>  	/*
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux