aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-05-24 05:07:59 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-06-10 10:41:11 -0400
commit7cde31d7d6959b2c608aa6b200eb68892d3a6063 (patch)
tree778190ae45040009a629ac3c5f6db670b2546d99 /fs/nilfs2
parent355c6b61034a571565dcd28801588671255d2329 (diff)
nilfs2: remove nilfs_btree_operations from btree mapping
will remove indirect function calls using nilfs_btree_operations table. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r--fs/nilfs2/btree.c52
-rw-r--r--fs/nilfs2/btree.h26
2 files changed, 15 insertions, 63 deletions
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
index 20e3fd0f4d4f..24395e6d29d0 100644
--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -913,9 +913,9 @@ static int nilfs_btree_prepare_insert(struct nilfs_btree *btree,
913 level = NILFS_BTREE_LEVEL_DATA; 913 level = NILFS_BTREE_LEVEL_DATA;
914 914
915 /* allocate a new ptr for data block */ 915 /* allocate a new ptr for data block */
916 if (btree->bt_ops->btop_find_target != NULL) 916 if (NILFS_BMAP_USE_VBN(&btree->bt_bmap))
917 path[level].bp_newreq.bpr_ptr = 917 path[level].bp_newreq.bpr_ptr =
918 btree->bt_ops->btop_find_target(btree, path, key); 918 nilfs_btree_find_target_v(btree, path, key);
919 919
920 ret = nilfs_bmap_prepare_alloc_ptr(&btree->bt_bmap, 920 ret = nilfs_bmap_prepare_alloc_ptr(&btree->bt_bmap,
921 &path[level].bp_newreq); 921 &path[level].bp_newreq);
@@ -1061,8 +1061,8 @@ static void nilfs_btree_commit_insert(struct nilfs_btree *btree,
1061 1061
1062 set_buffer_nilfs_volatile((struct buffer_head *)((unsigned long)ptr)); 1062 set_buffer_nilfs_volatile((struct buffer_head *)((unsigned long)ptr));
1063 ptr = path[NILFS_BTREE_LEVEL_DATA].bp_newreq.bpr_ptr; 1063 ptr = path[NILFS_BTREE_LEVEL_DATA].bp_newreq.bpr_ptr;
1064 if (btree->bt_ops->btop_set_target != NULL) 1064 if (NILFS_BMAP_USE_VBN(&btree->bt_bmap))
1065 btree->bt_ops->btop_set_target(btree, key, ptr); 1065 nilfs_btree_set_target_v(btree, key, ptr);
1066 1066
1067 for (level = NILFS_BTREE_LEVEL_NODE_MIN; level <= maxlevel; level++) { 1067 for (level = NILFS_BTREE_LEVEL_NODE_MIN; level <= maxlevel; level++) {
1068 nilfs_bmap_commit_alloc_ptr(&btree->bt_bmap, 1068 nilfs_bmap_commit_alloc_ptr(&btree->bt_bmap,
@@ -1586,9 +1586,9 @@ nilfs_btree_prepare_convert_and_insert(struct nilfs_bmap *bmap, __u64 key,
1586 1586
1587 /* for data */ 1587 /* for data */
1588 /* cannot find near ptr */ 1588 /* cannot find near ptr */
1589 if (btree->bt_ops->btop_find_target != NULL) 1589 if (NILFS_BMAP_USE_VBN(bmap))
1590 dreq->bpr_ptr 1590 dreq->bpr_ptr = nilfs_btree_find_target_v(btree, NULL, key);
1591 = btree->bt_ops->btop_find_target(btree, NULL, key); 1591
1592 ret = nilfs_bmap_prepare_alloc_ptr(bmap, dreq); 1592 ret = nilfs_bmap_prepare_alloc_ptr(bmap, dreq);
1593 if (ret < 0) 1593 if (ret < 0)
1594 return ret; 1594 return ret;
@@ -1681,8 +1681,8 @@ nilfs_btree_commit_convert_and_insert(struct nilfs_bmap *bmap,
1681 nilfs_bmap_set_dirty(bmap); 1681 nilfs_bmap_set_dirty(bmap);
1682 } 1682 }
1683 1683
1684 if (btree->bt_ops->btop_set_target != NULL) 1684 if (NILFS_BMAP_USE_VBN(bmap))
1685 btree->bt_ops->btop_set_target(btree, key, dreq->bpr_ptr); 1685 nilfs_btree_set_target_v(btree, key, dreq->bpr_ptr);
1686} 1686}
1687 1687
1688/** 1688/**
@@ -1926,7 +1926,9 @@ static int nilfs_btree_propagate(const struct nilfs_bmap *bmap,
1926 goto out; 1926 goto out;
1927 } 1927 }
1928 1928
1929 ret = btree->bt_ops->btop_propagate(btree, path, level, bh); 1929 ret = NILFS_BMAP_USE_VBN(bmap) ?
1930 nilfs_btree_propagate_v(btree, path, level, bh) :
1931 nilfs_btree_propagate_p(btree, path, level, bh);
1930 1932
1931 out: 1933 out:
1932 nilfs_btree_clear_path(btree, path); 1934 nilfs_btree_clear_path(btree, path);
@@ -2107,8 +2109,9 @@ static int nilfs_btree_assign(struct nilfs_bmap *bmap,
2107 goto out; 2109 goto out;
2108 } 2110 }
2109 2111
2110 ret = btree->bt_ops->btop_assign(btree, path, level, bh, 2112 ret = NILFS_BMAP_USE_VBN(bmap) ?
2111 blocknr, binfo); 2113 nilfs_btree_assign_v(btree, path, level, bh, blocknr, binfo) :
2114 nilfs_btree_assign_p(btree, path, level, bh, blocknr, binfo);
2112 2115
2113 out: 2116 out:
2114 nilfs_btree_clear_path(btree, path); 2117 nilfs_btree_clear_path(btree, path);
@@ -2220,34 +2223,9 @@ static const struct nilfs_bmap_operations nilfs_btree_ops_gc = {
2220 .bop_gather_data = NULL, 2223 .bop_gather_data = NULL,
2221}; 2224};
2222 2225
2223static const struct nilfs_btree_operations nilfs_btree_ops_v = {
2224 .btop_find_target = nilfs_btree_find_target_v,
2225 .btop_set_target = nilfs_btree_set_target_v,
2226 .btop_propagate = nilfs_btree_propagate_v,
2227 .btop_assign = nilfs_btree_assign_v,
2228};
2229
2230static const struct nilfs_btree_operations nilfs_btree_ops_p = {
2231 .btop_find_target = NULL,
2232 .btop_set_target = NULL,
2233 .btop_propagate = nilfs_btree_propagate_p,
2234 .btop_assign = nilfs_btree_assign_p,
2235};
2236
2237int nilfs_btree_init(struct nilfs_bmap *bmap) 2226int nilfs_btree_init(struct nilfs_bmap *bmap)
2238{ 2227{
2239 struct nilfs_btree *btree = (struct nilfs_btree *)bmap;
2240
2241 bmap->b_ops = &nilfs_btree_ops; 2228 bmap->b_ops = &nilfs_btree_ops;
2242 switch (bmap->b_inode->i_ino) {
2243 case NILFS_DAT_INO:
2244 btree->bt_ops = &nilfs_btree_ops_p;
2245 break;
2246 default:
2247 btree->bt_ops = &nilfs_btree_ops_v;
2248 break;
2249 }
2250
2251 return 0; 2229 return 0;
2252} 2230}
2253 2231
diff --git a/fs/nilfs2/btree.h b/fs/nilfs2/btree.h
index 48aad2a0c59f..0e72bbbc6b64 100644
--- a/fs/nilfs2/btree.h
+++ b/fs/nilfs2/btree.h
@@ -34,28 +34,6 @@ struct nilfs_btree;
34struct nilfs_btree_path; 34struct nilfs_btree_path;
35 35
36/** 36/**
37 * struct nilfs_btree_operations - B-tree operation table
38 */
39struct nilfs_btree_operations {
40 __u64 (*btop_find_target)(const struct nilfs_btree *,
41 const struct nilfs_btree_path *, __u64);
42 void (*btop_set_target)(struct nilfs_btree *, __u64, __u64);
43
44 struct the_nilfs *(*btop_get_nilfs)(struct nilfs_btree *);
45
46 int (*btop_propagate)(struct nilfs_btree *,
47 struct nilfs_btree_path *,
48 int,
49 struct buffer_head *);
50 int (*btop_assign)(struct nilfs_btree *,
51 struct nilfs_btree_path *,
52 int,
53 struct buffer_head **,
54 sector_t,
55 union nilfs_binfo *);
56};
57
58/**
59 * struct nilfs_btree_node - B-tree node 37 * struct nilfs_btree_node - B-tree node
60 * @bn_flags: flags 38 * @bn_flags: flags
61 * @bn_level: level 39 * @bn_level: level
@@ -80,13 +58,9 @@ struct nilfs_btree_node {
80/** 58/**
81 * struct nilfs_btree - B-tree structure 59 * struct nilfs_btree - B-tree structure
82 * @bt_bmap: bmap base structure 60 * @bt_bmap: bmap base structure
83 * @bt_ops: B-tree operation table
84 */ 61 */
85struct nilfs_btree { 62struct nilfs_btree {
86 struct nilfs_bmap bt_bmap; 63 struct nilfs_bmap bt_bmap;
87
88 /* B-tree-specific members */
89 const struct nilfs_btree_operations *bt_ops;
90}; 64};
91 65
92 66