[Devel] [PATCH VZ9 v2 1/2] fs/fuse kio: implement memory region to support zero-copy between userapce and kernel space.

Liu Kui kui.liu at virtuozzo.com
Mon May 27 08:04:30 MSK 2024


Actually it's already fixed, but is wrongly included in the next patch 
[2/2].

Anyway, I just resent v2 patches, please use latest one. Version number 
is not increased because there's no changed after both patches are applied.

On 26/5/24 2:18 am, Vasily Averin wrote:
> On 5/23/24 13:54, Liu Kui wrote:
>> +/*
>> + * Register a MR
>> + */
>> +int pcs_reg_mr(struct pcs_mr_set *mrs, u64 start, u64 len)
>> +{
>> +	int ret = 0;
>> +	struct pcs_mr *mr;
>> +	struct pcs_umem *umem;
>> +
>> +	if (!len)
>> +		return -EINVAL;
>> +
>> +	if (!can_do_mlock())
>> +		return -EPERM;
>> +
>> +	if (atomic_inc_return(&mrs->mr_num) > PCS_MAX_MR) {
>> +		atomic_dec(&mrs->mr_num);
>> +		return -ENOMEM;
>> +	}
>> +
>> +	umem = pcs_umem_get(start, len);
>> +	if (IS_ERR(umem))
> atomic_dec(&mrs->mr_num) is still missing here.
> Did you resend old patch version perhaps?
>
>> +		return PTR_ERR(umem);
>> +
>> +	mr = kzalloc(sizeof(*mr), GFP_KERNEL);
>> +	if (!mr) {
>> +		ret = -ENOMEM;
>> +		goto err_out;
>> +	}
>> +
>> +	mr->mrs = mrs;
>> +	mr->va = start;
>> +	mr->len = len;
>> +	mr->umem = umem;
>> +	kref_init(&mr->ref);
>> +
>> +	ret = xa_alloc_cyclic(&mrs->mr_xa, &mr->id, mr,
>> +			XA_LIMIT(1, PCS_MAX_MR), &mrs->mr_next, GFP_KERNEL);
>> +	if (ret < 0) {
>> +		kfree(mr);
>> +		goto err_out;
>> +	}
>> +
>> +	mr->id_valid = 1;
>> +
>> +	return mr->id;
>> +
>> +err_out:
>> +	pcs_umem_release(umem);
>> +	atomic_dec(&mrs->mr_num);
>> +	return ret;
>> +}


More information about the Devel mailing list