IB/core: convert to idr_alloc()
Convert to the much saner new idr interface.
v2: Mike triggered WARN_ON() in idr_preload() because send_mad(),
which may be used from non-process context, was calling
idr_preload() unconditionally. Preload iff @gfp_mask has
__GFP_WAIT.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Sean Hefty <sean.hefty@intel.com>
Reported-by: "Marciniszyn, Mike" <mike.marciniszyn@intel.com>
Cc: Roland Dreier <roland@kernel.org>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
4ae42b0ff0
commit
3b069c5d85
@@ -125,18 +125,17 @@ static int idr_add_uobj(struct idr *idr, struct ib_uobject *uobj)
|
||||
{
|
||||
int ret;
|
||||
|
||||
retry:
|
||||
if (!idr_pre_get(idr, GFP_KERNEL))
|
||||
return -ENOMEM;
|
||||
|
||||
idr_preload(GFP_KERNEL);
|
||||
spin_lock(&ib_uverbs_idr_lock);
|
||||
ret = idr_get_new(idr, uobj, &uobj->id);
|
||||
|
||||
ret = idr_alloc(idr, uobj, 0, 0, GFP_NOWAIT);
|
||||
if (ret >= 0)
|
||||
uobj->id = ret;
|
||||
|
||||
spin_unlock(&ib_uverbs_idr_lock);
|
||||
idr_preload_end();
|
||||
|
||||
if (ret == -EAGAIN)
|
||||
goto retry;
|
||||
|
||||
return ret;
|
||||
return ret < 0 ? ret : 0;
|
||||
}
|
||||
|
||||
void idr_remove_uobj(struct idr *idr, struct ib_uobject *uobj)
|
||||
|
||||
Reference in New Issue
Block a user