From: Jeff Layton Date: Mon, 29 Apr 2013 23:21:22 +0000 (-0700) Subject: sctp: convert sctp_assoc_set_id() to use idr_alloc_cyclic() X-Git-Tag: v3.10-rc1~178^2~19 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=713e00a324e49e8adee2753e1bb7bc3806bb53b6;p=~emulex%2Finfiniband.git sctp: convert sctp_assoc_set_id() to use idr_alloc_cyclic() Signed-off-by: Jeff Layton Cc: Vlad Yasevich Cc: Sridhar Samudrala Cc: Neil Horman Cc: "David S. Miller" Cc: Tejun Heo Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/net/sctp/associola.c b/net/sctp/associola.c index d2709e2b7be..fa261a3594c 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -66,13 +66,6 @@ static void sctp_assoc_bh_rcv(struct work_struct *work); static void sctp_assoc_free_asconf_acks(struct sctp_association *asoc); static void sctp_assoc_free_asconf_queue(struct sctp_association *asoc); -/* Keep track of the new idr low so that we don't re-use association id - * numbers too fast. It is protected by they idr spin lock is in the - * range of 1 - INT_MAX. - */ -static u32 idr_low = 1; - - /* 1st Level Abstractions. */ /* Initialize a new association from provided memory. */ @@ -1601,13 +1594,8 @@ int sctp_assoc_set_id(struct sctp_association *asoc, gfp_t gfp) if (preload) idr_preload(gfp); spin_lock_bh(&sctp_assocs_id_lock); - /* 0 is not a valid id, idr_low is always >= 1 */ - ret = idr_alloc(&sctp_assocs_id, asoc, idr_low, 0, GFP_NOWAIT); - if (ret >= 0) { - idr_low = ret + 1; - if (idr_low == INT_MAX) - idr_low = 1; - } + /* 0 is not a valid assoc_id, must be >= 1 */ + ret = idr_alloc_cyclic(&sctp_assocs_id, asoc, 1, 0, GFP_NOWAIT); spin_unlock_bh(&sctp_assocs_id_lock); if (preload) idr_preload_end();