diff options
author | Tejun Heo <tj@kernel.org> | 2013-02-27 20:04:16 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:16 -0500 |
commit | 3b069c5d857a5f1b8cb6bb74c70d9446089f5077 (patch) | |
tree | 58e005a8e9beba035a2551edd34afe1d802dba53 /drivers/infiniband/core/sa_query.c | |
parent | 4ae42b0ff0f9993c79d7282218b98d8a8a4263f5 (diff) |
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>
Diffstat (limited to 'drivers/infiniband/core/sa_query.c')
-rw-r--r-- | drivers/infiniband/core/sa_query.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index a8905abc56e4..934f45e79e5e 100644 --- a/drivers/infiniband/core/sa_query.c +++ b/drivers/infiniband/core/sa_query.c | |||
@@ -611,19 +611,21 @@ static void init_mad(struct ib_sa_mad *mad, struct ib_mad_agent *agent) | |||
611 | 611 | ||
612 | static int send_mad(struct ib_sa_query *query, int timeout_ms, gfp_t gfp_mask) | 612 | static int send_mad(struct ib_sa_query *query, int timeout_ms, gfp_t gfp_mask) |
613 | { | 613 | { |
614 | bool preload = gfp_mask & __GFP_WAIT; | ||
614 | unsigned long flags; | 615 | unsigned long flags; |
615 | int ret, id; | 616 | int ret, id; |
616 | 617 | ||
617 | retry: | 618 | if (preload) |
618 | if (!idr_pre_get(&query_idr, gfp_mask)) | 619 | idr_preload(gfp_mask); |
619 | return -ENOMEM; | ||
620 | spin_lock_irqsave(&idr_lock, flags); | 620 | spin_lock_irqsave(&idr_lock, flags); |
621 | ret = idr_get_new(&query_idr, query, &id); | 621 | |
622 | id = idr_alloc(&query_idr, query, 0, 0, GFP_NOWAIT); | ||
623 | |||
622 | spin_unlock_irqrestore(&idr_lock, flags); | 624 | spin_unlock_irqrestore(&idr_lock, flags); |
623 | if (ret == -EAGAIN) | 625 | if (preload) |
624 | goto retry; | 626 | idr_preload_end(); |
625 | if (ret) | 627 | if (id < 0) |
626 | return ret; | 628 | return id; |
627 | 629 | ||
628 | query->mad_buf->timeout_ms = timeout_ms; | 630 | query->mad_buf->timeout_ms = timeout_ms; |
629 | query->mad_buf->context[0] = query; | 631 | query->mad_buf->context[0] = query; |