Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 359322
b: refs/heads/master
c: 3594eb2
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo authored and Linus Torvalds committed Feb 28, 2013
1 parent 2282619 commit 3229676
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 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: 12d1b4393e0d8df36b2646a5e512f0513fb532d2
refs/heads/master: 3594eb2894f571c9b9a497159b1e4d84fdac5688
30 changes: 12 additions & 18 deletions trunk/lib/idr.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,24 +278,15 @@ static int idr_get_empty_slot(struct idr *idp, int starting_id,
return(v);
}

static int idr_get_new_above_int(struct idr *idp, void *ptr, int starting_id)
/*
* @id and @pa are from a successful allocation from idr_get_empty_slot().
* Install the user pointer @ptr and mark the slot full.
*/
static void idr_fill_slot(void *ptr, int id, struct idr_layer **pa)
{
struct idr_layer *pa[MAX_IDR_LEVEL];
int id;

id = idr_get_empty_slot(idp, starting_id, pa);
if (id >= 0) {
/*
* Successfully found an empty slot. Install the user
* pointer and mark the slot full.
*/
rcu_assign_pointer(pa[0]->ary[id & IDR_MASK],
(struct idr_layer *)ptr);
pa[0]->count++;
idr_mark_full(pa, id);
}

return id;
rcu_assign_pointer(pa[0]->ary[id & IDR_MASK], (struct idr_layer *)ptr);
pa[0]->count++;
idr_mark_full(pa, id);
}

/**
Expand All @@ -318,11 +309,14 @@ static int idr_get_new_above_int(struct idr *idp, void *ptr, int starting_id)
*/
int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id)
{
struct idr_layer *pa[MAX_IDR_LEVEL];
int rv;

rv = idr_get_new_above_int(idp, ptr, starting_id);
rv = idr_get_empty_slot(idp, starting_id, pa);
if (rv < 0)
return rv == -ENOMEM ? -EAGAIN : rv;

idr_fill_slot(ptr, rv, pa);
*id = rv;
return 0;
}
Expand Down

0 comments on commit 3229676

Please sign in to comment.