public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] nilfs2: Combine nilfs_btree_alloc_path() and nilfs_btree_init_path()
@ 2010-04-02 10:42 Li Hong
  2010-04-02 10:48 ` [PATCH 2/2] nilfs2: Combine nilfs_btree_release_path() and nilfs_btree_free_path() Li Hong
  2010-04-02 11:45 ` [PATCH 1/2] nilfs2: Combine nilfs_btree_alloc_path() and nilfs_btree_init_path() Ryusuke Konishi
  0 siblings, 2 replies; 5+ messages in thread
From: Li Hong @ 2010-04-02 10:42 UTC (permalink / raw)
  To: KONISHI Ryusuke, linux-nilfs; +Cc: linux-kernel

nilfs_btree_alloc_path() and nilfs_btree_init_path() are bound into each other
tightly. Make them into one procedure to clearify the logic and avoid some
misusages.

Signed-off-by: Li Hong <lihong.hi@gmail.com>
---
 fs/nilfs2/btree.c |   39 +++++++++++++++++----------------------
 1 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
index 76c38e3..bb31ab3 100644
--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -71,23 +71,16 @@ void nilfs_btree_path_cache_destroy(void)
 	kmem_cache_destroy(nilfs_btree_path_cache);
 }
 
-static inline struct nilfs_btree_path *nilfs_btree_alloc_path(void)
+static struct nilfs_btree_path *nilfs_btree_alloc_path(void)
 {
-	return kmem_cache_alloc(nilfs_btree_path_cache, GFP_NOFS);
-}
-
-static inline void nilfs_btree_free_path(struct nilfs_btree_path *path)
-{
-	kmem_cache_free(nilfs_btree_path_cache, path);
-}
+	struct nilfs_btree_path *path;
+	int level = NILFS_BTREE_LEVEL_DATA;
 
-static void nilfs_btree_init_path(struct nilfs_btree_path *path)
-{
-	int level;
+        path = kmem_cache_alloc(nilfs_btree_path_cache, GFP_NOFS);
+	if (path == NULL)
+		goto out;
 
-	for (level = NILFS_BTREE_LEVEL_DATA;
-	     level < NILFS_BTREE_LEVEL_MAX;
-	     level++) {
+	for (; level < NILFS_BTREE_LEVEL_MAX; level++) {
 		path[level].bp_bh = NULL;
 		path[level].bp_sib_bh = NULL;
 		path[level].bp_index = 0;
@@ -95,6 +88,14 @@ static void nilfs_btree_init_path(struct nilfs_btree_path *path)
 		path[level].bp_newreq.bpr_ptr = NILFS_BMAP_INVALID_PTR;
 		path[level].bp_op = NULL;
 	}
+
+out:
+	return path;
+}
+
+static inline void nilfs_btree_free_path(struct nilfs_btree_path *path)
+{
+	kmem_cache_free(nilfs_btree_path_cache, path);
 }
 
 static void nilfs_btree_release_path(struct nilfs_btree_path *path)
@@ -566,7 +567,6 @@ static int nilfs_btree_lookup(const struct nilfs_bmap *bmap,
 	path = nilfs_btree_alloc_path();
 	if (path == NULL)
 		return -ENOMEM;
-	nilfs_btree_init_path(path);
 
 	ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level);
 
@@ -594,7 +594,7 @@ static int nilfs_btree_lookup_contig(const struct nilfs_bmap *bmap,
 	path = nilfs_btree_alloc_path();
 	if (path == NULL)
 		return -ENOMEM;
-	nilfs_btree_init_path(path);
+
 	ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level);
 	if (ret < 0)
 		goto out;
@@ -1123,7 +1123,6 @@ static int nilfs_btree_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr)
 	path = nilfs_btree_alloc_path();
 	if (path == NULL)
 		return -ENOMEM;
-	nilfs_btree_init_path(path);
 
 	ret = nilfs_btree_do_lookup(btree, path, key, NULL,
 				    NILFS_BTREE_LEVEL_NODE_MIN);
@@ -1456,7 +1455,7 @@ static int nilfs_btree_delete(struct nilfs_bmap *bmap, __u64 key)
 	path = nilfs_btree_alloc_path();
 	if (path == NULL)
 		return -ENOMEM;
-	nilfs_btree_init_path(path);
+
 	ret = nilfs_btree_do_lookup(btree, path, key, NULL,
 				    NILFS_BTREE_LEVEL_NODE_MIN);
 	if (ret < 0)
@@ -1488,7 +1487,6 @@ static int nilfs_btree_last_key(const struct nilfs_bmap *bmap, __u64 *keyp)
 	path = nilfs_btree_alloc_path();
 	if (path == NULL)
 		return -ENOMEM;
-	nilfs_btree_init_path(path);
 
 	ret = nilfs_btree_do_lookup_last(btree, path, keyp, NULL);
 
@@ -1923,7 +1921,6 @@ static int nilfs_btree_propagate(const struct nilfs_bmap *bmap,
 	path = nilfs_btree_alloc_path();
 	if (path == NULL)
 		return -ENOMEM;
-	nilfs_btree_init_path(path);
 
 	if (buffer_nilfs_node(bh)) {
 		node = (struct nilfs_btree_node *)bh->b_data;
@@ -2108,7 +2105,6 @@ static int nilfs_btree_assign(struct nilfs_bmap *bmap,
 	path = nilfs_btree_alloc_path();
 	if (path == NULL)
 		return -ENOMEM;
-	nilfs_btree_init_path(path);
 
 	if (buffer_nilfs_node(*bh)) {
 		node = (struct nilfs_btree_node *)(*bh)->b_data;
@@ -2175,7 +2171,6 @@ static int nilfs_btree_mark(struct nilfs_bmap *bmap, __u64 key, int level)
 	path = nilfs_btree_alloc_path();
 	if (path == NULL)
 		return -ENOMEM;
-	nilfs_btree_init_path(path);
 
 	ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level + 1);
 	if (ret < 0) {
-- 
1.6.3.3


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

* [PATCH 2/2] nilfs2: Combine nilfs_btree_release_path() and nilfs_btree_free_path()
  2010-03-31  7:41 [PATCH] nilfs2: fix a wrong type conversion in nilfs_ioctl() Li Hong
@ 2010-04-02 10:43 ` Li Hong
  0 siblings, 0 replies; 5+ messages in thread
From: Li Hong @ 2010-04-02 10:43 UTC (permalink / raw)
  To: KONISHI Ryusuke, linux-nilfs; +Cc: linux-kernel

nilfs_btree_release_path() and nilfs_btree_free_path() are bound into each other
tightly. Make them into one procedure to clearify the logic and avoid some
misusages.

Signed-off-by: Li Hong <lihong.hi@gmail.com>
---
 fs/nilfs2/btree.c |   22 +++++-----------------
 1 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
index bb31ab3..fa4b123 100644
--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -93,18 +93,14 @@ out:
 	return path;
 }
 
-static inline void nilfs_btree_free_path(struct nilfs_btree_path *path)
+static void nilfs_btree_free_path(struct nilfs_btree_path *path)
 {
-	kmem_cache_free(nilfs_btree_path_cache, path);
-}
-
-static void nilfs_btree_release_path(struct nilfs_btree_path *path)
-{
-	int level;
+	int level = NILFS_BTREE_LEVEL_DATA;
 
-	for (level = NILFS_BTREE_LEVEL_DATA; level < NILFS_BTREE_LEVEL_MAX;
-	     level++)
+	for (; level < NILFS_BTREE_LEVEL_MAX; level++)
 		brelse(path[level].bp_bh);
+
+	kmem_cache_free(nilfs_btree_path_cache, path);
 }
 
 /*
@@ -573,7 +569,6 @@ static int nilfs_btree_lookup(const struct nilfs_bmap *bmap,
 	if (ptrp != NULL)
 		*ptrp = ptr;
 
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 
 	return ret;
@@ -655,7 +650,6 @@ static int nilfs_btree_lookup_contig(const struct nilfs_bmap *bmap,
 	*ptrp = ptr;
 	ret = cnt;
  out:
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 	return ret;
 }
@@ -1139,7 +1133,6 @@ static int nilfs_btree_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr)
 	nilfs_bmap_add_blocks(bmap, stats.bs_nblocks);
 
  out:
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 	return ret;
 }
@@ -1472,7 +1465,6 @@ static int nilfs_btree_delete(struct nilfs_bmap *bmap, __u64 key)
 	nilfs_bmap_sub_blocks(bmap, stats.bs_nblocks);
 
 out:
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 	return ret;
 }
@@ -1490,7 +1482,6 @@ static int nilfs_btree_last_key(const struct nilfs_bmap *bmap, __u64 *keyp)
 
 	ret = nilfs_btree_do_lookup_last(btree, path, keyp, NULL);
 
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 
 	return ret;
@@ -1944,7 +1935,6 @@ static int nilfs_btree_propagate(const struct nilfs_bmap *bmap,
 		nilfs_btree_propagate_p(btree, path, level, bh);
 
  out:
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 
 	return ret;
@@ -2126,7 +2116,6 @@ static int nilfs_btree_assign(struct nilfs_bmap *bmap,
 		nilfs_btree_assign_p(btree, path, level, bh, blocknr, binfo);
 
  out:
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 
 	return ret;
@@ -2190,7 +2179,6 @@ static int nilfs_btree_mark(struct nilfs_bmap *bmap, __u64 key, int level)
 		nilfs_bmap_set_dirty(&btree->bt_bmap);
 
  out:
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 	return ret;
 }
-- 
1.6.3.3


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

* [PATCH 2/2] nilfs2: Combine nilfs_btree_release_path() and nilfs_btree_free_path()
  2010-04-02 10:42 [PATCH 1/2] nilfs2: Combine nilfs_btree_alloc_path() and nilfs_btree_init_path() Li Hong
@ 2010-04-02 10:48 ` Li Hong
  2010-04-02 11:45 ` [PATCH 1/2] nilfs2: Combine nilfs_btree_alloc_path() and nilfs_btree_init_path() Ryusuke Konishi
  1 sibling, 0 replies; 5+ messages in thread
From: Li Hong @ 2010-04-02 10:48 UTC (permalink / raw)
  To: KONISHI Ryusuke, linux-nilfs, linux-kernel

Sorry, a same patch sent out a short time ago but replied to a wrong thread.
-------------------- cut here ----------------------

nilfs_btree_release_path() and nilfs_btree_free_path() are bound into each other
tightly. Make them into one procedure to clearify the logic and avoid some
misusages.

Signed-off-by: Li Hong <lihong.hi@gmail.com>
---
 fs/nilfs2/btree.c |   22 +++++-----------------
 1 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
index bb31ab3..fa4b123 100644
--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -93,18 +93,14 @@ out:
 	return path;
 }
 
-static inline void nilfs_btree_free_path(struct nilfs_btree_path *path)
+static void nilfs_btree_free_path(struct nilfs_btree_path *path)
 {
-	kmem_cache_free(nilfs_btree_path_cache, path);
-}
-
-static void nilfs_btree_release_path(struct nilfs_btree_path *path)
-{
-	int level;
+	int level = NILFS_BTREE_LEVEL_DATA;
 
-	for (level = NILFS_BTREE_LEVEL_DATA; level < NILFS_BTREE_LEVEL_MAX;
-	     level++)
+	for (; level < NILFS_BTREE_LEVEL_MAX; level++)
 		brelse(path[level].bp_bh);
+
+	kmem_cache_free(nilfs_btree_path_cache, path);
 }
 
 /*
@@ -573,7 +569,6 @@ static int nilfs_btree_lookup(const struct nilfs_bmap *bmap,
 	if (ptrp != NULL)
 		*ptrp = ptr;
 
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 
 	return ret;
@@ -655,7 +650,6 @@ static int nilfs_btree_lookup_contig(const struct nilfs_bmap *bmap,
 	*ptrp = ptr;
 	ret = cnt;
  out:
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 	return ret;
 }
@@ -1139,7 +1133,6 @@ static int nilfs_btree_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr)
 	nilfs_bmap_add_blocks(bmap, stats.bs_nblocks);
 
  out:
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 	return ret;
 }
@@ -1472,7 +1465,6 @@ static int nilfs_btree_delete(struct nilfs_bmap *bmap, __u64 key)
 	nilfs_bmap_sub_blocks(bmap, stats.bs_nblocks);
 
 out:
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 	return ret;
 }
@@ -1490,7 +1482,6 @@ static int nilfs_btree_last_key(const struct nilfs_bmap *bmap, __u64 *keyp)
 
 	ret = nilfs_btree_do_lookup_last(btree, path, keyp, NULL);
 
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 
 	return ret;
@@ -1944,7 +1935,6 @@ static int nilfs_btree_propagate(const struct nilfs_bmap *bmap,
 		nilfs_btree_propagate_p(btree, path, level, bh);
 
  out:
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 
 	return ret;
@@ -2126,7 +2116,6 @@ static int nilfs_btree_assign(struct nilfs_bmap *bmap,
 		nilfs_btree_assign_p(btree, path, level, bh, blocknr, binfo);
 
  out:
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 
 	return ret;
@@ -2190,7 +2179,6 @@ static int nilfs_btree_mark(struct nilfs_bmap *bmap, __u64 key, int level)
 		nilfs_bmap_set_dirty(&btree->bt_bmap);
 
  out:
-	nilfs_btree_release_path(path);
 	nilfs_btree_free_path(path);
 	return ret;
 }
-- 
1.6.3.3


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

* Re: [PATCH 1/2] nilfs2: Combine nilfs_btree_alloc_path() and nilfs_btree_init_path()
  2010-04-02 10:42 [PATCH 1/2] nilfs2: Combine nilfs_btree_alloc_path() and nilfs_btree_init_path() Li Hong
  2010-04-02 10:48 ` [PATCH 2/2] nilfs2: Combine nilfs_btree_release_path() and nilfs_btree_free_path() Li Hong
@ 2010-04-02 11:45 ` Ryusuke Konishi
       [not found]   ` <20100402133605.GA10602@xhl>
  1 sibling, 1 reply; 5+ messages in thread
From: Ryusuke Konishi @ 2010-04-02 11:45 UTC (permalink / raw)
  To: lihong.hi; +Cc: konishi.ryusuke, linux-nilfs, linux-kernel

Hi,
On Fri, 2 Apr 2010 18:42:06 +0800, Li Hong <lihong.hi@gmail.com> wrote:
> nilfs_btree_alloc_path() and nilfs_btree_init_path() are bound into each other
> tightly. Make them into one procedure to clearify the logic and avoid some
> misusages.
> 
> Signed-off-by: Li Hong <lihong.hi@gmail.com>

This patch had a style problem:

 $ scripts/checkpatch.pl ../patch1
 ERROR: code indent should use tabs where possible
 #42: FILE: fs/nilfs2/btree.c:79:
 +        path = kmem_cache_alloc(nilfs_btree_path_cache, GFP_NOFS);$

Thanks,
Ryusuke Konishi

> ---
>  fs/nilfs2/btree.c |   39 +++++++++++++++++----------------------
>  1 files changed, 17 insertions(+), 22 deletions(-)
> 
> diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
> index 76c38e3..bb31ab3 100644
> --- a/fs/nilfs2/btree.c
> +++ b/fs/nilfs2/btree.c
> @@ -71,23 +71,16 @@ void nilfs_btree_path_cache_destroy(void)
>  	kmem_cache_destroy(nilfs_btree_path_cache);
>  }
>  
> -static inline struct nilfs_btree_path *nilfs_btree_alloc_path(void)
> +static struct nilfs_btree_path *nilfs_btree_alloc_path(void)
>  {
> -	return kmem_cache_alloc(nilfs_btree_path_cache, GFP_NOFS);
> -}
> -
> -static inline void nilfs_btree_free_path(struct nilfs_btree_path *path)
> -{
> -	kmem_cache_free(nilfs_btree_path_cache, path);
> -}
> +	struct nilfs_btree_path *path;
> +	int level = NILFS_BTREE_LEVEL_DATA;
>  
> -static void nilfs_btree_init_path(struct nilfs_btree_path *path)
> -{
> -	int level;
> +        path = kmem_cache_alloc(nilfs_btree_path_cache, GFP_NOFS);
> +	if (path == NULL)
> +		goto out;
>  
> -	for (level = NILFS_BTREE_LEVEL_DATA;
> -	     level < NILFS_BTREE_LEVEL_MAX;
> -	     level++) {
> +	for (; level < NILFS_BTREE_LEVEL_MAX; level++) {
>  		path[level].bp_bh = NULL;
>  		path[level].bp_sib_bh = NULL;
>  		path[level].bp_index = 0;
> @@ -95,6 +88,14 @@ static void nilfs_btree_init_path(struct nilfs_btree_path *path)
>  		path[level].bp_newreq.bpr_ptr = NILFS_BMAP_INVALID_PTR;
>  		path[level].bp_op = NULL;
>  	}
> +
> +out:
> +	return path;
> +}
> +
> +static inline void nilfs_btree_free_path(struct nilfs_btree_path *path)
> +{
> +	kmem_cache_free(nilfs_btree_path_cache, path);
>  }
>  
>  static void nilfs_btree_release_path(struct nilfs_btree_path *path)
> @@ -566,7 +567,6 @@ static int nilfs_btree_lookup(const struct nilfs_bmap *bmap,
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
>  
>  	ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level);
>  
> @@ -594,7 +594,7 @@ static int nilfs_btree_lookup_contig(const struct nilfs_bmap *bmap,
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
> +
>  	ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level);
>  	if (ret < 0)
>  		goto out;
> @@ -1123,7 +1123,6 @@ static int nilfs_btree_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr)
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
>  
>  	ret = nilfs_btree_do_lookup(btree, path, key, NULL,
>  				    NILFS_BTREE_LEVEL_NODE_MIN);
> @@ -1456,7 +1455,7 @@ static int nilfs_btree_delete(struct nilfs_bmap *bmap, __u64 key)
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
> +
>  	ret = nilfs_btree_do_lookup(btree, path, key, NULL,
>  				    NILFS_BTREE_LEVEL_NODE_MIN);
>  	if (ret < 0)
> @@ -1488,7 +1487,6 @@ static int nilfs_btree_last_key(const struct nilfs_bmap *bmap, __u64 *keyp)
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
>  
>  	ret = nilfs_btree_do_lookup_last(btree, path, keyp, NULL);
>  
> @@ -1923,7 +1921,6 @@ static int nilfs_btree_propagate(const struct nilfs_bmap *bmap,
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
>  
>  	if (buffer_nilfs_node(bh)) {
>  		node = (struct nilfs_btree_node *)bh->b_data;
> @@ -2108,7 +2105,6 @@ static int nilfs_btree_assign(struct nilfs_bmap *bmap,
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
>  
>  	if (buffer_nilfs_node(*bh)) {
>  		node = (struct nilfs_btree_node *)(*bh)->b_data;
> @@ -2175,7 +2171,6 @@ static int nilfs_btree_mark(struct nilfs_bmap *bmap, __u64 key, int level)
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
>  
>  	ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level + 1);
>  	if (ret < 0) {
> -- 
> 1.6.3.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/2] nilfs2: Combine nilfs_btree_alloc_path() and nilfs_btree_init_path()
       [not found]   ` <20100402133605.GA10602@xhl>
@ 2010-04-02 15:32     ` Ryusuke Konishi
  0 siblings, 0 replies; 5+ messages in thread
From: Ryusuke Konishi @ 2010-04-02 15:32 UTC (permalink / raw)
  To: lihong.hi; +Cc: konishi.ryusuke, linux-nilfs, linux-kernel

On Fri, 2 Apr 2010 21:36:05 +0800, Li Hong <lihong.hi@gmail.com> wrote:
> Hi Ryusuke Konishi,
> 
> Sorry. The patches passed checkpatch.pl now. Send them again.
> 
> Thanks,
> Li Hong

Ok, will queue the new ones.

Thanks,
Ryusuke Konishi
 
> From bbb2fd5b906dbae1cee759549cb24678e41f824c Mon Sep 17 00:00:00 2001
> From: Li Hong <lihong.hi@gmail.com>
> Date: Fri, 2 Apr 2010 17:36:34 +0800
> Subject: [PATCH 1/2] nilfs2: Combine nilfs_btree_alloc_path() and nilfs_btree_init_path()
> 
> nilfs_btree_alloc_path() and nilfs_btree_init_path() are bound into each other
> tightly. Make them into one procedure to clearify the logic and avoid some
> misusages.
> 
> Signed-off-by: Li Hong <lihong.hi@gmail.com>
> ---
>  fs/nilfs2/btree.c |   39 +++++++++++++++++----------------------
>  1 files changed, 17 insertions(+), 22 deletions(-)
> 
> diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
> index 76c38e3..bb31ab3 100644
> --- a/fs/nilfs2/btree.c
> +++ b/fs/nilfs2/btree.c
> @@ -71,23 +71,16 @@ void nilfs_btree_path_cache_destroy(void)
>  	kmem_cache_destroy(nilfs_btree_path_cache);
>  }
>  
> -static inline struct nilfs_btree_path *nilfs_btree_alloc_path(void)
> +static struct nilfs_btree_path *nilfs_btree_alloc_path(void)
>  {
> -	return kmem_cache_alloc(nilfs_btree_path_cache, GFP_NOFS);
> -}
> -
> -static inline void nilfs_btree_free_path(struct nilfs_btree_path *path)
> -{
> -	kmem_cache_free(nilfs_btree_path_cache, path);
> -}
> +	struct nilfs_btree_path *path;
> +	int level = NILFS_BTREE_LEVEL_DATA;
>  
> -static void nilfs_btree_init_path(struct nilfs_btree_path *path)
> -{
> -	int level;
> +	path = kmem_cache_alloc(nilfs_btree_path_cache, GFP_NOFS);
> +	if (path == NULL)
> +		goto out;
>  
> -	for (level = NILFS_BTREE_LEVEL_DATA;
> -	     level < NILFS_BTREE_LEVEL_MAX;
> -	     level++) {
> +	for (; level < NILFS_BTREE_LEVEL_MAX; level++) {
>  		path[level].bp_bh = NULL;
>  		path[level].bp_sib_bh = NULL;
>  		path[level].bp_index = 0;
> @@ -95,6 +88,14 @@ static void nilfs_btree_init_path(struct nilfs_btree_path *path)
>  		path[level].bp_newreq.bpr_ptr = NILFS_BMAP_INVALID_PTR;
>  		path[level].bp_op = NULL;
>  	}
> +
> +out:
> +	return path;
> +}
> +
> +static inline void nilfs_btree_free_path(struct nilfs_btree_path *path)
> +{
> +	kmem_cache_free(nilfs_btree_path_cache, path);
>  }
>  
>  static void nilfs_btree_release_path(struct nilfs_btree_path *path)
> @@ -566,7 +567,6 @@ static int nilfs_btree_lookup(const struct nilfs_bmap *bmap,
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
>  
>  	ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level);
>  
> @@ -594,7 +594,7 @@ static int nilfs_btree_lookup_contig(const struct nilfs_bmap *bmap,
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
> +
>  	ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level);
>  	if (ret < 0)
>  		goto out;
> @@ -1123,7 +1123,6 @@ static int nilfs_btree_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr)
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
>  
>  	ret = nilfs_btree_do_lookup(btree, path, key, NULL,
>  				    NILFS_BTREE_LEVEL_NODE_MIN);
> @@ -1456,7 +1455,7 @@ static int nilfs_btree_delete(struct nilfs_bmap *bmap, __u64 key)
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
> +
>  	ret = nilfs_btree_do_lookup(btree, path, key, NULL,
>  				    NILFS_BTREE_LEVEL_NODE_MIN);
>  	if (ret < 0)
> @@ -1488,7 +1487,6 @@ static int nilfs_btree_last_key(const struct nilfs_bmap *bmap, __u64 *keyp)
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
>  
>  	ret = nilfs_btree_do_lookup_last(btree, path, keyp, NULL);
>  
> @@ -1923,7 +1921,6 @@ static int nilfs_btree_propagate(const struct nilfs_bmap *bmap,
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
>  
>  	if (buffer_nilfs_node(bh)) {
>  		node = (struct nilfs_btree_node *)bh->b_data;
> @@ -2108,7 +2105,6 @@ static int nilfs_btree_assign(struct nilfs_bmap *bmap,
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
>  
>  	if (buffer_nilfs_node(*bh)) {
>  		node = (struct nilfs_btree_node *)(*bh)->b_data;
> @@ -2175,7 +2171,6 @@ static int nilfs_btree_mark(struct nilfs_bmap *bmap, __u64 key, int level)
>  	path = nilfs_btree_alloc_path();
>  	if (path == NULL)
>  		return -ENOMEM;
> -	nilfs_btree_init_path(path);
>  
>  	ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level + 1);
>  	if (ret < 0) {
> -- 
> 1.6.3.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2010-04-02 15:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-02 10:42 [PATCH 1/2] nilfs2: Combine nilfs_btree_alloc_path() and nilfs_btree_init_path() Li Hong
2010-04-02 10:48 ` [PATCH 2/2] nilfs2: Combine nilfs_btree_release_path() and nilfs_btree_free_path() Li Hong
2010-04-02 11:45 ` [PATCH 1/2] nilfs2: Combine nilfs_btree_alloc_path() and nilfs_btree_init_path() Ryusuke Konishi
     [not found]   ` <20100402133605.GA10602@xhl>
2010-04-02 15:32     ` Ryusuke Konishi
  -- strict thread matches above, loose matches on Subject: below --
2010-03-31  7:41 [PATCH] nilfs2: fix a wrong type conversion in nilfs_ioctl() Li Hong
2010-04-02 10:43 ` [PATCH 2/2] nilfs2: Combine nilfs_btree_release_path() and nilfs_btree_free_path() Li Hong

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