2013-03-05 20:03:03

by Tejun Heo

[permalink] [raw]
Subject: [PATCHSET 3.9-rc1] idr: final idr_alloc() conversions and deprecation of old interface

Hello,

These are the final pieces of idr_alloc() conversion and deprecation
of idr_pre_get() and idr_get_new*().

This patchset contains the following seven patches.

0001-nfsd-remove-unused-get_new_stid.patch
0002-nfsd-convert-to-idr_alloc.patch
0003-workqueue-convert-to-idr_alloc.patch
0004-mlx4-remove-leftover-idr_pre_get-call.patch
0005-zcache-convert-to-idr_alloc.patch
0006-tidspbridge-convert-to-idr_alloc.patch
0007-idr-deprecate-idr_pre_get-and-idr_get_new-_above.patch

The patches based on top of v3.9-rc1 and are also available in the
following git branch.

git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git idr_alloc-final

Andrew, can you please route these through -mm?

diffstat follows, thanks.

drivers/infiniband/hw/mlx4/cm.c | 1
drivers/staging/tidspbridge/rmgr/drv.c | 70 ++++++++++++---------------------
drivers/staging/zcache/ramster/tcp.c | 25 ++++-------
fs/nfsd/nfs4state.c | 36 ----------------
include/linux/idr.h | 66 +++++++++++++++++++++++--------
kernel/workqueue.c | 7 +--
lib/idr.c | 41 ++-----------------
7 files changed, 97 insertions(+), 149 deletions(-)

--
tejun


2013-03-05 20:03:06

by Tejun Heo

[permalink] [raw]
Subject: [PATCH 1/7] nfsd: remove unused get_new_stid()

get_new_stid() is no longer used since 3abdb607125 ("nfsd4: simplify
idr allocation"). Remove it.

Signed-off-by: Tejun Heo <[email protected]>
Cc: "J. Bruce Fields" <[email protected]>
Cc: [email protected]
---
fs/nfsd/nfs4state.c | 31 -------------------------------
1 file changed, 31 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 16d39c6..d91d6db 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -230,37 +230,6 @@ static void nfs4_file_put_access(struct nfs4_file *fp, int oflag)
__nfs4_file_put_access(fp, oflag);
}

-static inline int get_new_stid(struct nfs4_stid *stid)
-{
- static int min_stateid = 0;
- struct idr *stateids = &stid->sc_client->cl_stateids;
- int new_stid;
- int error;
-
- error = idr_get_new_above(stateids, stid, min_stateid, &new_stid);
- /*
- * Note: the necessary preallocation was done in
- * nfs4_alloc_stateid(). The idr code caps the number of
- * preallocations that can exist at a time, but the state lock
- * prevents anyone from using ours before we get here:
- */
- WARN_ON_ONCE(error);
- /*
- * It shouldn't be a problem to reuse an opaque stateid value.
- * I don't think it is for 4.1. But with 4.0 I worry that, for
- * example, a stray write retransmission could be accepted by
- * the server when it should have been rejected. Therefore,
- * adopt a trick from the sctp code to attempt to maximize the
- * amount of time until an id is reused, by ensuring they always
- * "increase" (mod INT_MAX):
- */
-
- min_stateid = new_stid+1;
- if (min_stateid == INT_MAX)
- min_stateid = 0;
- return new_stid;
-}
-
static struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl, struct
kmem_cache *slab)
{
--
1.8.1.4

2013-03-05 20:03:14

by Tejun Heo

[permalink] [raw]
Subject: [PATCH 3/7] workqueue: convert to idr_alloc()

idr_get_new*() and friends are about to be deprecated. Convert to the
new idr_alloc() interface.

Signed-off-by: Tejun Heo <[email protected]>
---
kernel/workqueue.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 81f2457..55fac5b 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -457,11 +457,12 @@ static int worker_pool_assign_id(struct worker_pool *pool)
int ret;

mutex_lock(&worker_pool_idr_mutex);
- idr_pre_get(&worker_pool_idr, GFP_KERNEL);
- ret = idr_get_new(&worker_pool_idr, pool, &pool->id);
+ ret = idr_alloc(&worker_pool_idr, pool, 0, 0, GFP_KERNEL);
+ if (ret >= 0)
+ pool->id = ret;
mutex_unlock(&worker_pool_idr_mutex);

- return ret;
+ return ret < 0 ? ret : 0;
}

/*
--
1.8.1.4

2013-03-05 20:03:23

by Tejun Heo

[permalink] [raw]
Subject: [PATCH 6/7] tidspbridge: convert to idr_alloc()

idr_get_new*() and friends are about to be deprecated. Convert to the
new idr_alloc() interface.

There are some peculiarities and possible bugs in the converted
functions. This patch preserves those.

* drv_insert_node_res_element() returns -ENOMEM on alloc failure,
-EFAULT if id space is exhausted. -EFAULT is at best misleading.

* drv_proc_insert_strm_res_element() is even weirder. It returns
-EFAULT if kzalloc() fails, -ENOMEM if idr preloading fails and
-EPERM if id space is exhausted. What's going on here?

* drv_proc_insert_strm_res_element() doesn't free *pstrm_res after
failure.

Only compile tested.

Signed-off-by: Tejun Heo <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Víctor Manuel Jáquez Leal <[email protected]>
Cc: Rene Sapiens <[email protected]>
Cc: Armando Uribe <[email protected]>
Cc: Omar Ramirez Luna <[email protected]>
---
drivers/staging/tidspbridge/rmgr/drv.c | 70 +++++++++++++---------------------
1 file changed, 26 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/drv.c b/drivers/staging/tidspbridge/rmgr/drv.c
index db1da28..be26917 100644
--- a/drivers/staging/tidspbridge/rmgr/drv.c
+++ b/drivers/staging/tidspbridge/rmgr/drv.c
@@ -76,37 +76,28 @@ int drv_insert_node_res_element(void *hnode, void *node_resource,
struct node_res_object **node_res_obj =
(struct node_res_object **)node_resource;
struct process_context *ctxt = (struct process_context *)process_ctxt;
- int status = 0;
int retval;

*node_res_obj = kzalloc(sizeof(struct node_res_object), GFP_KERNEL);
- if (!*node_res_obj) {
- status = -ENOMEM;
- goto func_end;
- }
+ if (!*node_res_obj)
+ return -ENOMEM;

(*node_res_obj)->node = hnode;
- retval = idr_get_new(ctxt->node_id, *node_res_obj,
- &(*node_res_obj)->id);
- if (retval == -EAGAIN) {
- if (!idr_pre_get(ctxt->node_id, GFP_KERNEL)) {
- pr_err("%s: OUT OF MEMORY\n", __func__);
- status = -ENOMEM;
- goto func_end;
- }
-
- retval = idr_get_new(ctxt->node_id, *node_res_obj,
- &(*node_res_obj)->id);
+ retval = idr_alloc(ctxt->node_id, *node_res_obj, 0, 0, GFP_KERNEL);
+ if (retval >= 0) {
+ (*node_res_obj)->id = retval;
+ return 0;
}
- if (retval) {
+
+ kfree(*node_res_obj);
+
+ if (retval == -ENOSPC) {
pr_err("%s: FAILED, IDR is FULL\n", __func__);
- status = -EFAULT;
+ return -EFAULT;
+ } else {
+ pr_err("%s: OUT OF MEMORY\n", __func__);
+ return -ENOMEM;
}
-func_end:
- if (status)
- kfree(*node_res_obj);
-
- return status;
}

/* Release all Node resources and its context
@@ -201,35 +192,26 @@ int drv_proc_insert_strm_res_element(void *stream_obj,
struct strm_res_object **pstrm_res =
(struct strm_res_object **)strm_res;
struct process_context *ctxt = (struct process_context *)process_ctxt;
- int status = 0;
int retval;

*pstrm_res = kzalloc(sizeof(struct strm_res_object), GFP_KERNEL);
- if (*pstrm_res == NULL) {
- status = -EFAULT;
- goto func_end;
- }
+ if (*pstrm_res == NULL)
+ return -EFAULT;

(*pstrm_res)->stream = stream_obj;
- retval = idr_get_new(ctxt->stream_id, *pstrm_res,
- &(*pstrm_res)->id);
- if (retval == -EAGAIN) {
- if (!idr_pre_get(ctxt->stream_id, GFP_KERNEL)) {
- pr_err("%s: OUT OF MEMORY\n", __func__);
- status = -ENOMEM;
- goto func_end;
- }
-
- retval = idr_get_new(ctxt->stream_id, *pstrm_res,
- &(*pstrm_res)->id);
+ retval = idr_alloc(ctxt->stream_id, *pstrm_res, 0, 0, GFP_KERNEL);
+ if (retval >= 0) {
+ (*pstrm_res)->id = retval;
+ return 0;
}
- if (retval) {
+
+ if (retval == -ENOSPC) {
pr_err("%s: FAILED, IDR is FULL\n", __func__);
- status = -EPERM;
+ return -EPERM;
+ } else {
+ pr_err("%s: OUT OF MEMORY\n", __func__);
+ return -ENOMEM;
}
-
-func_end:
- return status;
}

static int drv_proc_free_strm_res(int id, void *p, void *process_ctxt)
--
1.8.1.4

2013-03-05 20:03:30

by Tejun Heo

[permalink] [raw]
Subject: [PATCH 7/7] idr: deprecate idr_pre_get() and idr_get_new[_above]()

Now that all in-kernel users are converted to ues the new alloc
interface, mark the old interface deprecated. We should be able to
remove these in a few releases.

Signed-off-by: Tejun Heo <[email protected]>
Cc: Rusty Russell <[email protected]>
---
include/linux/idr.h | 66 ++++++++++++++++++++++++++++++++++++++++-------------
lib/idr.c | 41 ++++-----------------------------
2 files changed, 55 insertions(+), 52 deletions(-)

diff --git a/include/linux/idr.h b/include/linux/idr.h
index a6f38b5..1fd0bde 100644
--- a/include/linux/idr.h
+++ b/include/linux/idr.h
@@ -73,8 +73,6 @@ struct idr {
*/

void *idr_find_slowpath(struct idr *idp, int id);
-int idr_pre_get(struct idr *idp, gfp_t gfp_mask);
-int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id);
void idr_preload(gfp_t gfp_mask);
int idr_alloc(struct idr *idp, void *ptr, int start, int end, gfp_t gfp_mask);
int idr_for_each(struct idr *idp,
@@ -120,19 +118,6 @@ static inline void *idr_find(struct idr *idr, int id)
}

/**
- * idr_get_new - allocate new idr entry
- * @idp: idr handle
- * @ptr: pointer you want associated with the id
- * @id: pointer to the allocated handle
- *
- * Simple wrapper around idr_get_new_above() w/ @starting_id of zero.
- */
-static inline int idr_get_new(struct idr *idp, void *ptr, int *id)
-{
- return idr_get_new_above(idp, ptr, 0, id);
-}
-
-/**
* idr_for_each_entry - iterate over an idr's elements of a given type
* @idp: idr handle
* @entry: the type * to use as cursor
@@ -143,7 +128,56 @@ static inline int idr_get_new(struct idr *idp, void *ptr, int *id)
entry != NULL; \
++id, entry = (typeof(entry))idr_get_next((idp), &(id)))

-void __idr_remove_all(struct idr *idp); /* don't use */
+/*
+ * Don't use the following functions. These exist only to suppress
+ * deprecated warnings on EXPORT_SYMBOL()s.
+ */
+int __idr_pre_get(struct idr *idp, gfp_t gfp_mask);
+int __idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id);
+void __idr_remove_all(struct idr *idp);
+
+/**
+ * idr_pre_get - reserve resources for idr allocation
+ * @idp: idr handle
+ * @gfp_mask: memory allocation flags
+ *
+ * Part of old alloc interface. This is going away. Use
+ * idr_preload[_end]() and idr_alloc() instead.
+ */
+static inline int __deprecated idr_pre_get(struct idr *idp, gfp_t gfp_mask)
+{
+ return __idr_pre_get(idp, gfp_mask);
+}
+
+/**
+ * idr_get_new_above - allocate new idr entry above or equal to a start id
+ * @idp: idr handle
+ * @ptr: pointer you want associated with the id
+ * @starting_id: id to start search at
+ * @id: pointer to the allocated handle
+ *
+ * Part of old alloc interface. This is going away. Use
+ * idr_preload[_end]() and idr_alloc() instead.
+ */
+static inline int __deprecated idr_get_new_above(struct idr *idp, void *ptr,
+ int starting_id, int *id)
+{
+ return __idr_get_new_above(idp, ptr, starting_id, id);
+}
+
+/**
+ * idr_get_new - allocate new idr entry
+ * @idp: idr handle
+ * @ptr: pointer you want associated with the id
+ * @id: pointer to the allocated handle
+ *
+ * Part of old alloc interface. This is going away. Use
+ * idr_preload[_end]() and idr_alloc() instead.
+ */
+static inline int __deprecated idr_get_new(struct idr *idp, void *ptr, int *id)
+{
+ return __idr_get_new_above(idp, ptr, 0, id);
+}

/**
* idr_remove_all - remove all ids from the given idr tree
diff --git a/lib/idr.c b/lib/idr.c
index 73f4d53..708106b 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -184,20 +184,7 @@ static void idr_mark_full(struct idr_layer **pa, int id)
}
}

-/**
- * idr_pre_get - reserve resources for idr allocation
- * @idp: idr handle
- * @gfp_mask: memory allocation flags
- *
- * This function should be called prior to calling the idr_get_new* functions.
- * It preallocates enough memory to satisfy the worst possible allocation. The
- * caller should pass in GFP_KERNEL if possible. This of course requires that
- * no spinning locks be held.
- *
- * If the system is REALLY out of memory this function returns %0,
- * otherwise %1.
- */
-int idr_pre_get(struct idr *idp, gfp_t gfp_mask)
+int __idr_pre_get(struct idr *idp, gfp_t gfp_mask)
{
while (idp->id_free_cnt < MAX_IDR_FREE) {
struct idr_layer *new;
@@ -208,7 +195,7 @@ int idr_pre_get(struct idr *idp, gfp_t gfp_mask)
}
return 1;
}
-EXPORT_SYMBOL(idr_pre_get);
+EXPORT_SYMBOL(__idr_pre_get);

/**
* sub_alloc - try to allocate an id without growing the tree depth
@@ -376,25 +363,7 @@ static void idr_fill_slot(struct idr *idr, void *ptr, int id,
idr_mark_full(pa, id);
}

-/**
- * idr_get_new_above - allocate new idr entry above or equal to a start id
- * @idp: idr handle
- * @ptr: pointer you want associated with the id
- * @starting_id: id to start search at
- * @id: pointer to the allocated handle
- *
- * This is the allocate id function. It should be called with any
- * required locks.
- *
- * If allocation from IDR's private freelist fails, idr_get_new_above() will
- * return %-EAGAIN. The caller should retry the idr_pre_get() call to refill
- * IDR's preallocation and then retry the idr_get_new_above() call.
- *
- * If the idr is full idr_get_new_above() will return %-ENOSPC.
- *
- * @id returns a value in the range @starting_id ... %0x7fffffff
- */
-int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id)
+int __idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id)
{
struct idr_layer *pa[MAX_IDR_LEVEL + 1];
int rv;
@@ -407,7 +376,7 @@ int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id)
*id = rv;
return 0;
}
-EXPORT_SYMBOL(idr_get_new_above);
+EXPORT_SYMBOL(__idr_get_new_above);

/**
* idr_preload - preload for idr_alloc()
@@ -918,7 +887,7 @@ static void free_bitmap(struct ida *ida, struct ida_bitmap *bitmap)
int ida_pre_get(struct ida *ida, gfp_t gfp_mask)
{
/* allocate idr_layers */
- if (!idr_pre_get(&ida->idr, gfp_mask))
+ if (!__idr_pre_get(&ida->idr, gfp_mask))
return 0;

/* allocate free_bitmap */
--
1.8.1.4

2013-03-05 20:04:20

by Tejun Heo

[permalink] [raw]
Subject: [PATCH 5/7] zcache: convert to idr_alloc()

idr_get_new*() and friends are about to be deprecated. Convert to the
new idr_alloc() interface.

Only compile tested.

Signed-off-by: Tejun Heo <[email protected]>
Cc: Dan Magenheimer <[email protected]>
---
drivers/staging/zcache/ramster/tcp.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/zcache/ramster/tcp.c b/drivers/staging/zcache/ramster/tcp.c
index aa2a1a7..f6e1e52 100644
--- a/drivers/staging/zcache/ramster/tcp.c
+++ b/drivers/staging/zcache/ramster/tcp.c
@@ -300,27 +300,22 @@ static u8 r2net_num_from_nn(struct r2net_node *nn)

static int r2net_prep_nsw(struct r2net_node *nn, struct r2net_status_wait *nsw)
{
- int ret = 0;
+ int ret;

- do {
- if (!idr_pre_get(&nn->nn_status_idr, GFP_ATOMIC)) {
- ret = -EAGAIN;
- break;
- }
- spin_lock(&nn->nn_lock);
- ret = idr_get_new(&nn->nn_status_idr, nsw, &nsw->ns_id);
- if (ret == 0)
- list_add_tail(&nsw->ns_node_item,
- &nn->nn_status_list);
- spin_unlock(&nn->nn_lock);
- } while (ret == -EAGAIN);
+ spin_lock(&nn->nn_lock);
+ ret = idr_alloc(&nn->nn_status_idr, nsw, 0, 0, GFP_ATOMIC);
+ if (ret >= 0) {
+ nsw->ns_id = ret;
+ list_add_tail(&nsw->ns_node_item, &nn->nn_status_list);
+ }
+ spin_unlock(&nn->nn_lock);

- if (ret == 0) {
+ if (ret >= 0) {
init_waitqueue_head(&nsw->ns_wq);
nsw->ns_sys_status = R2NET_ERR_NONE;
nsw->ns_status = 0;
+ return 0;
}
-
return ret;
}

--
1.8.1.4

2013-03-05 20:03:12

by Tejun Heo

[permalink] [raw]
Subject: [PATCH 2/7] nfsd: convert to idr_alloc()

idr_get_new*() and friends are about to be deprecated. Convert to the
new idr_alloc() interface.

Only compile-tested.

Signed-off-by: Tejun Heo <[email protected]>
Cc: "J. Bruce Fields" <[email protected]>
Cc: [email protected]
---
fs/nfsd/nfs4state.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index d91d6db..2e27430 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -242,9 +242,8 @@ kmem_cache *slab)
if (!stid)
return NULL;

- if (!idr_pre_get(stateids, GFP_KERNEL))
- goto out_free;
- if (idr_get_new_above(stateids, stid, min_stateid, &new_id))
+ new_id = idr_alloc(stateids, stid, min_stateid, 0, GFP_KERNEL);
+ if (new_id < 0)
goto out_free;
stid->sc_client = cl;
stid->sc_type = 0;
--
1.8.1.4

2013-03-05 20:04:57

by Tejun Heo

[permalink] [raw]
Subject: [PATCH 4/7] mlx4: remove leftover idr_pre_get() call

6a9200603d ("IB/mlx4: convert to idr_alloc()") forgot to remove
idr_pre_get() call in mlx4_ib_cm_paravirt_init(). It's unnecessary
and idr_pre_get() will soon be deprecated. Remove it.

Signed-off-by: Tejun Heo <[email protected]>
Cc: Jack Morgenstein <[email protected]>
Cc: Or Gerlitz <[email protected]>
Cc: Roland Dreier <[email protected]>
---
drivers/infiniband/hw/mlx4/cm.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx4/cm.c b/drivers/infiniband/hw/mlx4/cm.c
index e0d79b2..add98d0 100644
--- a/drivers/infiniband/hw/mlx4/cm.c
+++ b/drivers/infiniband/hw/mlx4/cm.c
@@ -362,7 +362,6 @@ void mlx4_ib_cm_paravirt_init(struct mlx4_ib_dev *dev)
INIT_LIST_HEAD(&dev->sriov.cm_list);
dev->sriov.sl_id_map = RB_ROOT;
idr_init(&dev->sriov.pv_id_table);
- idr_pre_get(&dev->sriov.pv_id_table, GFP_KERNEL);
}

/* slave = -1 ==> all slaves */
--
1.8.1.4

2013-03-05 20:05:25

by J. Bruce Fields

[permalink] [raw]
Subject: Re: [PATCH 1/7] nfsd: remove unused get_new_stid()

On Tue, Mar 05, 2013 at 12:02:46PM -0800, Tejun Heo wrote:
> get_new_stid() is no longer used since 3abdb607125 ("nfsd4: simplify
> idr allocation"). Remove it.

Whoops, thanks for catching that.

Acked-by: J. Bruce Fields <[email protected]>

>
> Signed-off-by: Tejun Heo <[email protected]>
> Cc: "J. Bruce Fields" <[email protected]>
> Cc: [email protected]
> ---
> fs/nfsd/nfs4state.c | 31 -------------------------------
> 1 file changed, 31 deletions(-)
>
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 16d39c6..d91d6db 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -230,37 +230,6 @@ static void nfs4_file_put_access(struct nfs4_file *fp, int oflag)
> __nfs4_file_put_access(fp, oflag);
> }
>
> -static inline int get_new_stid(struct nfs4_stid *stid)
> -{
> - static int min_stateid = 0;
> - struct idr *stateids = &stid->sc_client->cl_stateids;
> - int new_stid;
> - int error;
> -
> - error = idr_get_new_above(stateids, stid, min_stateid, &new_stid);
> - /*
> - * Note: the necessary preallocation was done in
> - * nfs4_alloc_stateid(). The idr code caps the number of
> - * preallocations that can exist at a time, but the state lock
> - * prevents anyone from using ours before we get here:
> - */
> - WARN_ON_ONCE(error);
> - /*
> - * It shouldn't be a problem to reuse an opaque stateid value.
> - * I don't think it is for 4.1. But with 4.0 I worry that, for
> - * example, a stray write retransmission could be accepted by
> - * the server when it should have been rejected. Therefore,
> - * adopt a trick from the sctp code to attempt to maximize the
> - * amount of time until an id is reused, by ensuring they always
> - * "increase" (mod INT_MAX):
> - */
> -
> - min_stateid = new_stid+1;
> - if (min_stateid == INT_MAX)
> - min_stateid = 0;
> - return new_stid;
> -}
> -
> static struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl, struct
> kmem_cache *slab)
> {
> --
> 1.8.1.4
>

2013-03-05 21:36:46

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 6/7] tidspbridge: convert to idr_alloc()

On Tue, Mar 05, 2013 at 12:02:51PM -0800, Tejun Heo wrote:
> idr_get_new*() and friends are about to be deprecated. Convert to the
> new idr_alloc() interface.
>
> There are some peculiarities and possible bugs in the converted
> functions. This patch preserves those.
>
> * drv_insert_node_res_element() returns -ENOMEM on alloc failure,
> -EFAULT if id space is exhausted. -EFAULT is at best misleading.
>
> * drv_proc_insert_strm_res_element() is even weirder. It returns
> -EFAULT if kzalloc() fails, -ENOMEM if idr preloading fails and
> -EPERM if id space is exhausted. What's going on here?
>
> * drv_proc_insert_strm_res_element() doesn't free *pstrm_res after
> failure.
>
> Only compile tested.
>
> Signed-off-by: Tejun Heo <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: V?ctor Manuel J?quez Leal <[email protected]>
> Cc: Rene Sapiens <[email protected]>
> Cc: Armando Uribe <[email protected]>
> Cc: Omar Ramirez Luna <[email protected]>
> ---
> drivers/staging/tidspbridge/rmgr/drv.c | 70 +++++++++++++---------------------
> 1 file changed, 26 insertions(+), 44 deletions(-)

Acked-by: Greg Kroah-Hartman <[email protected]>

2013-03-05 21:37:14

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 5/7] zcache: convert to idr_alloc()

On Tue, Mar 05, 2013 at 12:02:50PM -0800, Tejun Heo wrote:
> idr_get_new*() and friends are about to be deprecated. Convert to the
> new idr_alloc() interface.
>
> Only compile tested.
>
> Signed-off-by: Tejun Heo <[email protected]>
> Cc: Dan Magenheimer <[email protected]>
> ---
> drivers/staging/zcache/ramster/tcp.c | 25 ++++++++++---------------
> 1 file changed, 10 insertions(+), 15 deletions(-)

Acked-by: Greg Kroah-Hartman <[email protected]>

2013-03-05 22:31:46

by J. Bruce Fields

[permalink] [raw]
Subject: Re: [PATCH 2/7] nfsd: convert to idr_alloc()

On Tue, Mar 05, 2013 at 12:02:47PM -0800, Tejun Heo wrote:
> idr_get_new*() and friends are about to be deprecated. Convert to the
> new idr_alloc() interface.
>
> Only compile-tested.

Runs fine too--thanks.

Acked-by: J. Bruce Fields <[email protected]>

--b.

>
> Signed-off-by: Tejun Heo <[email protected]>
> Cc: "J. Bruce Fields" <[email protected]>
> Cc: [email protected]
> ---
> fs/nfsd/nfs4state.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index d91d6db..2e27430 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -242,9 +242,8 @@ kmem_cache *slab)
> if (!stid)
> return NULL;
>
> - if (!idr_pre_get(stateids, GFP_KERNEL))
> - goto out_free;
> - if (idr_get_new_above(stateids, stid, min_stateid, &new_id))
> + new_id = idr_alloc(stateids, stid, min_stateid, 0, GFP_KERNEL);
> + if (new_id < 0)
> goto out_free;
> stid->sc_client = cl;
> stid->sc_type = 0;
> --
> 1.8.1.4
>