lkml.org 
[lkml]   [2013]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 60/62] sctp: convert to idr_alloc()
On Mon, Feb 04, 2013 at 11:22:26AM -0500, Vlad Yasevich wrote:
> >+ ret = idr_alloc(&sctp_assocs_id, asoc, idr_low, 0, GFP_NOWAIT);
> >+ if (ret >= 0) {
>
> In SCTP, association id is not allowed to be 0, so we have to treat
> 0 as an error.

That condition is specified via @idr_low and 0 won't be returned. If
your point is that the condition better be "ret > 0" for clarity, I
don't know. At that point, we already requested an ID in the
acceptable range and testing whether the allocation succeeded or not
where failure will always be indicated by -errno.

We can surely add "if (ret == 0) ret = -EINVAL" but that would be a
completely dead path (should we add dead retry loop too?). If we
don't add such code, the code would appear as silently ignoring error.

So, I think "ret >= 0" is better there. Maybe we can throw in a
comment explaining idr_low never goes to zero.

BTW, this style of cyclic allocation is broken. It's prone to -ENOSPC
failure after the first wrap around. I think we need to implement
proper cyclic support in idr, but let's worry about that later.

Thanks.

--
tejun


\
 
 \ /
  Last update: 2013-02-04 18:24    [W:0.125 / U:2.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site