Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 29832
b: refs/heads/master
c: 1eec005
h: refs/heads/master
v: v3
  • Loading branch information
Sonny Rao authored and Linus Torvalds committed Jun 25, 2006
1 parent 0d8c832 commit 226caa3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a45219483e2894af3c07f959cbd4edb4575b4f8c
refs/heads/master: 1eec00565d849ceda67f425e089c3233e3ef2ca2
16 changes: 12 additions & 4 deletions trunk/lib/idr.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,21 @@ static struct idr_layer *alloc_layer(struct idr *idp)
return(p);
}

/* only called when idp->lock is held */
static void __free_layer(struct idr *idp, struct idr_layer *p)
{
p->ary[0] = idp->id_free;
idp->id_free = p;
idp->id_free_cnt++;
}

static void free_layer(struct idr *idp, struct idr_layer *p)
{
/*
* Depends on the return element being zeroed.
*/
spin_lock(&idp->lock);
p->ary[0] = idp->id_free;
idp->id_free = p;
idp->id_free_cnt++;
__free_layer(idp, p);
spin_unlock(&idp->lock);
}

Expand Down Expand Up @@ -184,12 +190,14 @@ static int idr_get_new_above_int(struct idr *idp, void *ptr, int starting_id)
* The allocation failed. If we built part of
* the structure tear it down.
*/
spin_lock(&idp->lock);
for (new = p; p && p != idp->top; new = p) {
p = p->ary[0];
new->ary[0] = NULL;
new->bitmap = new->count = 0;
free_layer(idp, new);
__free_layer(idp, new);
}
spin_unlock(&idp->lock);
return -1;
}
new->ary[0] = p;
Expand Down

0 comments on commit 226caa3

Please sign in to comment.