aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLi Hong <lihong.hi@gmail.com>2010-04-02 06:35:00 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-05-09 22:32:29 -0400
commit73bb48869b14fd5094b9ec173a2bf86bc0e464d4 (patch)
tree3c2ffd6ebdf3a821cb7a37fe873fe4e8e957bcd9 /fs
parentf905440f5edfa70a07e64bdbc973cbdd55dd001d (diff)
nilfs2: Combine nilfs_btree_release_path() and nilfs_btree_free_path()
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> Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs')
-rw-r--r--fs/nilfs2/btree.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
index f47984987465..dcd4e1c4deaa 100644
--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -93,18 +93,14 @@ out:
93 return path; 93 return path;
94} 94}
95 95
96static inline void nilfs_btree_free_path(struct nilfs_btree_path *path) 96static void nilfs_btree_free_path(struct nilfs_btree_path *path)
97{ 97{
98 kmem_cache_free(nilfs_btree_path_cache, path); 98 int level = NILFS_BTREE_LEVEL_DATA;
99}
100
101static void nilfs_btree_release_path(struct nilfs_btree_path *path)
102{
103 int level;
104 99
105 for (level = NILFS_BTREE_LEVEL_DATA; level < NILFS_BTREE_LEVEL_MAX; 100 for (; level < NILFS_BTREE_LEVEL_MAX; level++)
106 level++)
107 brelse(path[level].bp_bh); 101 brelse(path[level].bp_bh);
102
103 kmem_cache_free(nilfs_btree_path_cache, path);
108} 104}
109 105
110/* 106/*
@@ -573,7 +569,6 @@ static int nilfs_btree_lookup(const struct nilfs_bmap *bmap,
573 if (ptrp != NULL) 569 if (ptrp != NULL)
574 *ptrp = ptr; 570 *ptrp = ptr;
575 571
576 nilfs_btree_release_path(path);
577 nilfs_btree_free_path(path); 572 nilfs_btree_free_path(path);
578 573
579 return ret; 574 return ret;
@@ -655,7 +650,6 @@ static int nilfs_btree_lookup_contig(const struct nilfs_bmap *bmap,
655 *ptrp = ptr; 650 *ptrp = ptr;
656 ret = cnt; 651 ret = cnt;
657 out: 652 out:
658 nilfs_btree_release_path(path);
659 nilfs_btree_free_path(path); 653 nilfs_btree_free_path(path);
660 return ret; 654 return ret;
661} 655}
@@ -1139,7 +1133,6 @@ static int nilfs_btree_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr)
1139 nilfs_bmap_add_blocks(bmap, stats.bs_nblocks); 1133 nilfs_bmap_add_blocks(bmap, stats.bs_nblocks);
1140 1134
1141 out: 1135 out:
1142 nilfs_btree_release_path(path);
1143 nilfs_btree_free_path(path); 1136 nilfs_btree_free_path(path);
1144 return ret; 1137 return ret;
1145} 1138}
@@ -1472,7 +1465,6 @@ static int nilfs_btree_delete(struct nilfs_bmap *bmap, __u64 key)
1472 nilfs_bmap_sub_blocks(bmap, stats.bs_nblocks); 1465 nilfs_bmap_sub_blocks(bmap, stats.bs_nblocks);
1473 1466
1474out: 1467out:
1475 nilfs_btree_release_path(path);
1476 nilfs_btree_free_path(path); 1468 nilfs_btree_free_path(path);
1477 return ret; 1469 return ret;
1478} 1470}
@@ -1490,7 +1482,6 @@ static int nilfs_btree_last_key(const struct nilfs_bmap *bmap, __u64 *keyp)
1490 1482
1491 ret = nilfs_btree_do_lookup_last(btree, path, keyp, NULL); 1483 ret = nilfs_btree_do_lookup_last(btree, path, keyp, NULL);
1492 1484
1493 nilfs_btree_release_path(path);
1494 nilfs_btree_free_path(path); 1485 nilfs_btree_free_path(path);
1495 1486
1496 return ret; 1487 return ret;
@@ -1944,7 +1935,6 @@ static int nilfs_btree_propagate(const struct nilfs_bmap *bmap,
1944 nilfs_btree_propagate_p(btree, path, level, bh); 1935 nilfs_btree_propagate_p(btree, path, level, bh);
1945 1936
1946 out: 1937 out:
1947 nilfs_btree_release_path(path);
1948 nilfs_btree_free_path(path); 1938 nilfs_btree_free_path(path);
1949 1939
1950 return ret; 1940 return ret;
@@ -2126,7 +2116,6 @@ static int nilfs_btree_assign(struct nilfs_bmap *bmap,
2126 nilfs_btree_assign_p(btree, path, level, bh, blocknr, binfo); 2116 nilfs_btree_assign_p(btree, path, level, bh, blocknr, binfo);
2127 2117
2128 out: 2118 out:
2129 nilfs_btree_release_path(path);
2130 nilfs_btree_free_path(path); 2119 nilfs_btree_free_path(path);
2131 2120
2132 return ret; 2121 return ret;
@@ -2190,7 +2179,6 @@ static int nilfs_btree_mark(struct nilfs_bmap *bmap, __u64 key, int level)
2190 nilfs_bmap_set_dirty(&btree->bt_bmap); 2179 nilfs_bmap_set_dirty(&btree->bt_bmap);
2191 2180
2192 out: 2181 out:
2193 nilfs_btree_release_path(path);
2194 nilfs_btree_free_path(path); 2182 nilfs_btree_free_path(path);
2195 return ret; 2183 return ret;
2196} 2184}