lkml.org 
[lkml]   [2019]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Design of xa_alloc
On Thu, Jan 17, 2019 at 12:08:17PM -0800, Matthew Wilcox wrote:
> It would, of course, be possible to make the xa_alloc() API identical
> to idr_alloc(). idr_alloc() has been a phenomenal success with around
> 200 callers in the kernel today. But it could be improved, and this
> seems like a good time to make the API changes.

> Problem 3 is solved by using xa_insert() instead of xa_alloc(). It does
> return a different errno (-EEXIST) instead of -ENOSPC, but most users
> convert the errno to something else anyway because -ENOSPC is a horrible
> errno to return to userspace.

Writing this down and then thinking about it more makes me think that
this is the right time to change the return code of xa_alloc(). I chose
-ENOSPC to be compatible with idr_alloc(), but bugs like
https://bugzilla.kernel.org/show_bug.cgi?id=202297
show that returning an -ENOSPC error to userspace is just confusing:

: # tc filter add dev ipenc0 parent 2:0 handle ::102 protocol ip prio 1 u32 match ip dst 224.44.44.4/32 flowid 2:102
: RTNETLINK answers: No space left on device
: We have an error talking to the kernel

I'm really tempted to make it return -EEXIST instead of -ENOSPC to match
xa_insert().

\
 
 \ /
  Last update: 2019-01-22 02:54    [W:0.030 / U:77.384 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site