Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 32646
b: refs/heads/master
c: c259cc2
h: refs/heads/master
v: v3
  • Loading branch information
Roland Dreier authored and Linus Torvalds committed Jul 15, 2006
1 parent dcf931e commit 33c317b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 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: 6fbe82a952790c634ea6035c223a01a81377daf1
refs/heads/master: c259cc281255bdb30ceba190bfd7f37e3ae3fc85
16 changes: 10 additions & 6 deletions trunk/lib/idr.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ static kmem_cache_t *idr_layer_cache;
static struct idr_layer *alloc_layer(struct idr *idp)
{
struct idr_layer *p;
unsigned long flags;

spin_lock(&idp->lock);
spin_lock_irqsave(&idp->lock, flags);
if ((p = idp->id_free)) {
idp->id_free = p->ary[0];
idp->id_free_cnt--;
p->ary[0] = NULL;
}
spin_unlock(&idp->lock);
spin_unlock_irqrestore(&idp->lock, flags);
return(p);
}

Expand All @@ -59,12 +60,14 @@ static void __free_layer(struct idr *idp, struct idr_layer *p)

static void free_layer(struct idr *idp, struct idr_layer *p)
{
unsigned long flags;

/*
* Depends on the return element being zeroed.
*/
spin_lock(&idp->lock);
spin_lock_irqsave(&idp->lock, flags);
__free_layer(idp, p);
spin_unlock(&idp->lock);
spin_unlock_irqrestore(&idp->lock, flags);
}

/**
Expand Down Expand Up @@ -168,6 +171,7 @@ static int idr_get_new_above_int(struct idr *idp, void *ptr, int starting_id)
{
struct idr_layer *p, *new;
int layers, v, id;
unsigned long flags;

id = starting_id;
build_up:
Expand All @@ -191,14 +195,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);
spin_lock_irqsave(&idp->lock, flags);
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);
}
spin_unlock(&idp->lock);
spin_unlock_irqrestore(&idp->lock, flags);
return -1;
}
new->ary[0] = p;
Expand Down

0 comments on commit 33c317b

Please sign in to comment.