From 6cc9afc8a0d80350b2fc338d3c6963f55df5c0c5 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 4 Feb 2010 17:57:37 +0900 Subject: [PATCH] --- yaml --- r: 180222 b: refs/heads/master c: 6f14a668f1a8b715a6e855f4e32705e54a6e86a1 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/lib/idr.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index c7b640fa536f..db5d43723c76 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: e9e70bc14ea5974e21f5baecf95a123844c412b9 +refs/heads/master: 6f14a668f1a8b715a6e855f4e32705e54a6e86a1 diff --git a/trunk/lib/idr.c b/trunk/lib/idr.c index ba7d37cf7847..1cac726c44bc 100644 --- a/trunk/lib/idr.c +++ b/trunk/lib/idr.c @@ -140,7 +140,8 @@ static int sub_alloc(struct idr *idp, int *starting_id, struct idr_layer **pa) id = *starting_id; restart: p = idp->top; - l = p->layer; + l = idp->layers; + pa[l--] = NULL; while (1) { /* * We run around this while until we reach the leaf node... @@ -154,8 +155,8 @@ static int sub_alloc(struct idr *idp, int *starting_id, struct idr_layer **pa) oid = id; id = (id | ((1 << (IDR_BITS * l)) - 1)) + 1; - /* did id go over the limit? */ - if (id >= (1 << (idp->layers * IDR_BITS))) { + /* if already at the top layer, we need to grow */ + if (!(p = pa[l])) { *starting_id = id; return IDR_NEED_TO_GROW; }