summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <koverstreet@google.com>2013-06-14 00:33:34 -0700
committerKent Overstreet <koverstreet@google.com>2013-06-14 15:55:33 -0700
commit9b1a1a53a37f1a377ffde822dbf6b1585641dac7 (patch)
tree38ffc9876ab687d9b89c96de77cbb2c95aaaa7fb
parent7de40113622910fe0e2f6f5814ba46f0c0e27450 (diff)
kill ida_pre_get/ida_get_new
-rw-r--r--fs/nfs/nfs4state.c29
-rw-r--r--include/linux/idr.h2
-rw-r--r--lib/idr.c16
3 files changed, 18 insertions, 29 deletions
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 2eee60f85eb3..0cb9eab40545 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -431,7 +431,6 @@ nfs4_insert_state_owner_locked(struct nfs4_state_owner *new)
struct rb_node **p = &server->state_owners.rb_node,
*parent = NULL;
struct nfs4_state_owner *sp;
- int err;
while (*p != NULL) {
parent = *p;
@@ -448,9 +447,6 @@ nfs4_insert_state_owner_locked(struct nfs4_state_owner *new)
return sp;
}
}
- err = ida_get_new(&server->openowner_id, &new->so_seqid.owner_id);
- if (err)
- return ERR_PTR(err);
rb_link_node(&new->so_server_node, parent, p);
rb_insert_color(&new->so_server_node, &server->state_owners);
return new;
@@ -573,6 +569,7 @@ struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *server,
{
struct nfs_client *clp = server->nfs_client;
struct nfs4_state_owner *sp, *new;
+ int id;
spin_lock(&clp->cl_lock);
sp = nfs4_find_state_owner_locked(server, cred);
@@ -582,15 +579,23 @@ struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *server,
new = nfs4_alloc_state_owner(server, cred, gfp_flags);
if (new == NULL)
goto out;
- do {
- if (ida_pre_get(&server->openowner_id, gfp_flags) == 0)
- break;
- spin_lock(&clp->cl_lock);
- sp = nfs4_insert_state_owner_locked(new);
- spin_unlock(&clp->cl_lock);
- } while (sp == ERR_PTR(-EAGAIN));
- if (sp != new)
+
+ id = ida_get(&server->openowner_id, gfp_flags);
+ if (id < 0) {
nfs4_free_state_owner(new);
+ sp = ERR_PTR(id);
+ goto out;
+ }
+ new->so_seqid.owner_id = id;
+
+ spin_lock(&clp->cl_lock);
+ sp = nfs4_insert_state_owner_locked(new);
+ spin_unlock(&clp->cl_lock);
+
+ if (sp != new) {
+ ida_remove(&server->openowner_id, new->so_seqid.owner_id);
+ nfs4_free_state_owner(new);
+ }
out:
nfs4_gc_state_owners(server);
return sp;
diff --git a/include/linux/idr.h b/include/linux/idr.h
index 1b305ac344af..6f519dc66d72 100644
--- a/include/linux/idr.h
+++ b/include/linux/idr.h
@@ -219,8 +219,6 @@ struct ida {
#define IDA_INIT(name) { .idr = IDR_INIT((name).idr), .free_bitmap = NULL, }
#define DEFINE_IDA(name) struct ida name = IDA_INIT(name)
-int ida_pre_get(struct ida *ida, gfp_t gfp_mask);
-int ida_get_new(struct ida *ida, int *p_id);
void ida_remove(struct ida *ida, unsigned id);
void ida_destroy(struct ida *ida);
void ida_init(struct ida *ida);
diff --git a/lib/idr.c b/lib/idr.c
index c61418a83f68..647e56b39052 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -912,7 +912,7 @@ static void free_bitmap(struct ida *ida, struct ida_bitmap *bitmap)
* If the system is REALLY out of memory this function returns %0,
* otherwise %1.
*/
-int ida_pre_get(struct ida *ida, gfp_t gfp_mask)
+static int ida_pre_get(struct ida *ida, gfp_t gfp_mask)
{
/* allocate idr_layers */
if (!__idr_pre_get(&ida->idr, gfp_mask))
@@ -931,7 +931,6 @@ int ida_pre_get(struct ida *ida, gfp_t gfp_mask)
return 1;
}
-EXPORT_SYMBOL(ida_pre_get);
/**
* ida_get_new_above - allocate new ID above or equal to a start id
@@ -1020,19 +1019,6 @@ int ida_get_new_above(struct ida *ida, int starting_id, int *p_id)
return 0;
}
-/**
- * ida_get_new - allocate new ID
- * @ida: idr handle
- * @p_id: pointer to the allocated handle
- *
- * Simple wrapper around ida_get_new_above() w/ @starting_id of zero.
- */
-int ida_get_new(struct ida *ida, int *p_id)
-{
- return ida_get_new_above(ida, 0, p_id);
-}
-EXPORT_SYMBOL(ida_get_new);
-
static void __ida_remove(struct ida *ida, int id)
{
struct idr_layer *p = ida->idr.top;