Re: [PATCH 1/7] sunrpc: Factor out rpc_xprt allocation

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

 



>> +struct rpc_xprt *xprt_alloc(int size, int max_req)
>> +{
>> +	struct rpc_xprt *xprt;
>> +
>> +	xprt = kzalloc(size, GFP_KERNEL);
>> +	if (xprt == NULL)
>> +		goto out;
>> +
>> +	xprt->max_reqs = max_req;
>> +	xprt->slot = kcalloc(max_req, sizeof(struct rpc_rqst), GFP_KERNEL);
>> +	if (xprt->slot == NULL)
>> +		goto out_free;
>> +
>> +	return xprt;
>> +
>> +out_free:
>> +	kfree(xprt);
>> +out:
>> +	return NULL;
>> +}
>> +EXPORT_SYMBOL_GPL(xprt_alloc);
> 
> If xprt_alloc is a generic function, used by different transport capabilities, 
> then it belongs in net/sunrpc/xprt.c, not in a transport-specific source file
> like xprtsock.c .

Will do.

> Also, would it makes sense to allocate these via a single kcalloc request, or
>  would that possibly result in a high-order (ie non-zero) allocation in some cases?

The kcalloc is used to allocate n elements of an equal size, but the first
element in this hypothetical allocation will be of another size...
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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 USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux