public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] CFQ: clarify code touching 'cic_index' a bit
@ 2011-08-03 19:41 Paul Bolle
  2011-08-03 21:00 ` Vivek Goyal
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Bolle @ 2011-08-03 19:41 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
---
 block/cfq-iosched.c |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 1f96ad6..601a24c 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -3948,39 +3948,38 @@ static void cfq_exit_queue(struct elevator_queue *e)
 	kfree(cfqd);
 }
 
-static int cfq_alloc_cic_index(void)
+static int cfq_alloc_cic_index(int *cic_index)
 {
-	int index, error;
+	int error;
 
 	do {
 		if (!ida_pre_get(&cic_index_ida, GFP_KERNEL))
 			return -ENOMEM;
 
 		spin_lock(&cic_index_lock);
-		error = ida_get_new(&cic_index_ida, &index);
+		error = ida_get_new(&cic_index_ida, cic_index);
 		spin_unlock(&cic_index_lock);
 		if (error && error != -EAGAIN)
 			return error;
 	} while (error);
 
-	return index;
+	return 0;
 }
 
 static void *cfq_init_queue(struct request_queue *q)
 {
 	struct cfq_data *cfqd;
-	int i, j;
+	int i, j, cic_index;
 	struct cfq_group *cfqg;
 	struct cfq_rb_root *st;
 
-	i = cfq_alloc_cic_index();
-	if (i < 0)
+	if (cfq_alloc_cic_index(&cic_index))
 		return NULL;
 
 	cfqd = kmalloc_node(sizeof(*cfqd), GFP_KERNEL | __GFP_ZERO, q->node);
 	if (!cfqd) {
 		spin_lock(&cic_index_lock);
-		ida_remove(&cic_index_ida, i);
+		ida_remove(&cic_index_ida, cic_index);
 		spin_unlock(&cic_index_lock);
 		return NULL;
 	}
@@ -3989,7 +3988,7 @@ static void *cfq_init_queue(struct request_queue *q)
 	 * Don't need take queue_lock in the routine, since we are
 	 * initializing the ioscheduler, and nobody is using cfqd
 	 */
-	cfqd->cic_index = i;
+	cfqd->cic_index = cic_index;
 
 	/* Init root service tree */
 	cfqd->grp_service_tree = CFQ_RB_ROOT;
-- 
1.7.6




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] CFQ: clarify code touching 'cic_index' a bit
  2011-08-03 19:41 [PATCH] CFQ: clarify code touching 'cic_index' a bit Paul Bolle
@ 2011-08-03 21:00 ` Vivek Goyal
  0 siblings, 0 replies; 2+ messages in thread
From: Vivek Goyal @ 2011-08-03 21:00 UTC (permalink / raw)
  To: Paul Bolle; +Cc: Jens Axboe, linux-kernel

On Wed, Aug 03, 2011 at 09:41:12PM +0200, Paul Bolle wrote:
> Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
> ---
>  block/cfq-iosched.c |   17 ++++++++---------
>  1 files changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
> index 1f96ad6..601a24c 100644
> --- a/block/cfq-iosched.c
> +++ b/block/cfq-iosched.c
> @@ -3948,39 +3948,38 @@ static void cfq_exit_queue(struct elevator_queue *e)
>  	kfree(cfqd);
>  }
>  
> -static int cfq_alloc_cic_index(void)
> +static int cfq_alloc_cic_index(int *cic_index)

Changing function signature does not make it any more clear.


>  {
> -	int index, error;
> +	int error;
>  
>  	do {
>  		if (!ida_pre_get(&cic_index_ida, GFP_KERNEL))
>  			return -ENOMEM;
>  
>  		spin_lock(&cic_index_lock);
> -		error = ida_get_new(&cic_index_ida, &index);
> +		error = ida_get_new(&cic_index_ida, cic_index);
>  		spin_unlock(&cic_index_lock);
>  		if (error && error != -EAGAIN)
>  			return error;
>  	} while (error);
>  
> -	return index;
> +	return 0;
>  }
>  
>  static void *cfq_init_queue(struct request_queue *q)
>  {
>  	struct cfq_data *cfqd;
> -	int i, j;
> +	int i, j, cic_index;

If you want it little more clear then rename i to cic_index.

Thanks
Vivek

>  	struct cfq_group *cfqg;
>  	struct cfq_rb_root *st;
>  
> -	i = cfq_alloc_cic_index();
> -	if (i < 0)
> +	if (cfq_alloc_cic_index(&cic_index))
>  		return NULL;
>  
>  	cfqd = kmalloc_node(sizeof(*cfqd), GFP_KERNEL | __GFP_ZERO, q->node);
>  	if (!cfqd) {
>  		spin_lock(&cic_index_lock);
> -		ida_remove(&cic_index_ida, i);
> +		ida_remove(&cic_index_ida, cic_index);
>  		spin_unlock(&cic_index_lock);
>  		return NULL;
>  	}
> @@ -3989,7 +3988,7 @@ static void *cfq_init_queue(struct request_queue *q)
>  	 * Don't need take queue_lock in the routine, since we are
>  	 * initializing the ioscheduler, and nobody is using cfqd
>  	 */
> -	cfqd->cic_index = i;
> +	cfqd->cic_index = cic_index;
>  
>  	/* Init root service tree */
>  	cfqd->grp_service_tree = CFQ_RB_ROOT;
> -- 
> 1.7.6
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-03 21:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-03 19:41 [PATCH] CFQ: clarify code touching 'cic_index' a bit Paul Bolle
2011-08-03 21:00 ` Vivek Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox