Re: [PATCH 2/2] btrfs: Move checks from btrfs_wq_run_delayed_node to btrfs_balance_delayed_items

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

 




On 2017年10月23日 18:51, Nikolay Borisov wrote:
> btrfs_balance_delayed_items is the sole caller of btrfs_wq_run_delayed_node and
> already includes one of the checks whether the delayed inodes should be run. On
> the other hand btrfs_wq_run_delayed_node duplicates that check and performs an
> additional one for wq congestion.
> 
> Let's remove the duplicate check and move the congestion one in
> btrfs_balance_delayed_items, leaving btrfs_wq_run_delayed_node to only care
> about setting up the wq run. No functional changes.
> 
> Signed-off-by: Nikolay Borisov <nborisov@xxxxxxxx>
btrfs_workqueue_normal_congested() is moved to the caller and removed
duplicated atomic_read().

Unless delayed_root->items get modified in the period, it should be good.
But anyway, the original code has nothing to protect different
atomic_read(), so I don't think it will cause any new problem.

Reviewed-by: Qu Wenruo <wqu@xxxxxxxx>

Thanks,
Qu
> ---
>  fs/btrfs/delayed-inode.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
> index 1bfdb90d7633..b7a0ec2c41e6 100644
> --- a/fs/btrfs/delayed-inode.c
> +++ b/fs/btrfs/delayed-inode.c
> @@ -1371,10 +1371,6 @@ static int btrfs_wq_run_delayed_node(struct btrfs_delayed_root *delayed_root,
>  {
>  	struct btrfs_async_delayed_work *async_work;
>  
> -	if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND ||
> -	    btrfs_workqueue_normal_congested(fs_info->delayed_workers))
> -		return 0;
> -
>  	async_work = kmalloc(sizeof(*async_work), GFP_NOFS);
>  	if (!async_work)
>  		return -ENOMEM;
> @@ -1410,7 +1406,8 @@ void btrfs_balance_delayed_items(struct btrfs_fs_info *fs_info)
>  {
>  	struct btrfs_delayed_root *delayed_root = fs_info->delayed_root;
>  
> -	if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
> +	if ((atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND) ||
> +		btrfs_workqueue_normal_congested(fs_info->delayed_workers))
>  		return;
>  
>  	if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
> 

Attachment: signature.asc
Description: OpenPGP digital signature


[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