Re: [PATCH v5 10/13] io_uring: create common fixed_rsrc_data allocation routines

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

 



On 12/01/2021 21:33, Bijan Mottahedeh wrote:
> Create common alloc/free fixed_rsrc_data routines for both files and
> buffers.
> 
> Signed-off-by: Bijan Mottahedeh <bijan.mottahedeh@xxxxxxxxxx>
> ---
>  fs/io_uring.c | 75 ++++++++++++++++++++++++++++++++---------------------------
>  1 file changed, 41 insertions(+), 34 deletions(-)
> 
[...]
> @@ -8672,32 +8688,23 @@ static struct fixed_rsrc_data *io_buffers_map_alloc(struct io_ring_ctx *ctx,
>  	if (!nr_args || nr_args > IORING_MAX_FIXED_BUFS)
>  		return ERR_PTR(-EINVAL);
>  
> -	buf_data = kzalloc(sizeof(*ctx->buf_data), GFP_KERNEL);
> -	if (!buf_data)
> -		return ERR_PTR(-ENOMEM);
> -	buf_data->ctx = ctx;
> -	init_completion(&buf_data->done);
> +	buf_data = alloc_fixed_rsrc_data(ctx);
> +	if (IS_ERR(buf_data))
> +		return buf_data;

As you remember it's planned to be partially merged first, so when
you'll be rebasing, please use all these helpers from the beginning
(i.e. in 8/13 or so). Just a nit

>  
>  	nr_tables = DIV_ROUND_UP(nr_args, IORING_MAX_BUFS_TABLE);
>  	buf_data->table = kcalloc(nr_tables, sizeof(*buf_data->table),
>  				  GFP_KERNEL);
>  	if (!buf_data->table)
> -		goto out_free;
> -
> -	if (percpu_ref_init(&buf_data->refs, io_rsrc_ref_kill,
> -			    PERCPU_REF_ALLOW_REINIT, GFP_KERNEL))
> -		goto out_free;
> +		goto out;
>  
>  	if (io_alloc_buf_tables(buf_data, nr_tables, nr_args))
> -		goto out_ref;
> +		goto out;
>  
>  	return buf_data;
> -
> -out_ref:
> -	percpu_ref_exit(&buf_data->refs);
> -out_free:
> -	kfree(buf_data->table);
> -	kfree(buf_data);
> +out:
> +	free_fixed_rsrc_data(ctx->buf_data);
> +	ctx->buf_data = NULL;
>  	return ERR_PTR(ret);
>  }
>  
> 

-- 
Pavel Begunkov



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux