aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/btree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nilfs2/btree.c')
-rw-r--r--fs/nilfs2/btree.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
index 6c9ec566d000..b2347f793072 100644
--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -191,29 +191,27 @@ nilfs_btree_node_dptrs(const struct nilfs_btree_node *node,
191static inline __u64 191static inline __u64
192nilfs_btree_node_get_key(const struct nilfs_btree_node *node, int index) 192nilfs_btree_node_get_key(const struct nilfs_btree_node *node, int index)
193{ 193{
194 return nilfs_bmap_dkey_to_key(*(nilfs_btree_node_dkeys(node) + index)); 194 return le64_to_cpu(*(nilfs_btree_node_dkeys(node) + index));
195} 195}
196 196
197static inline void 197static inline void
198nilfs_btree_node_set_key(struct nilfs_btree_node *node, int index, __u64 key) 198nilfs_btree_node_set_key(struct nilfs_btree_node *node, int index, __u64 key)
199{ 199{
200 *(nilfs_btree_node_dkeys(node) + index) = nilfs_bmap_key_to_dkey(key); 200 *(nilfs_btree_node_dkeys(node) + index) = cpu_to_le64(key);
201} 201}
202 202
203static inline __u64 203static inline __u64
204nilfs_btree_node_get_ptr(const struct nilfs_btree *btree, 204nilfs_btree_node_get_ptr(const struct nilfs_btree *btree,
205 const struct nilfs_btree_node *node, int index) 205 const struct nilfs_btree_node *node, int index)
206{ 206{
207 return nilfs_bmap_dptr_to_ptr(*(nilfs_btree_node_dptrs(node, btree) + 207 return le64_to_cpu(*(nilfs_btree_node_dptrs(node, btree) + index));
208 index));
209} 208}
210 209
211static inline void 210static inline void
212nilfs_btree_node_set_ptr(struct nilfs_btree *btree, 211nilfs_btree_node_set_ptr(struct nilfs_btree *btree,
213 struct nilfs_btree_node *node, int index, __u64 ptr) 212 struct nilfs_btree_node *node, int index, __u64 ptr)
214{ 213{
215 *(nilfs_btree_node_dptrs(node, btree) + index) = 214 *(nilfs_btree_node_dptrs(node, btree) + index) = cpu_to_le64(ptr);
216 nilfs_bmap_ptr_to_dptr(ptr);
217} 215}
218 216
219static void nilfs_btree_node_init(struct nilfs_btree *btree, 217static void nilfs_btree_node_init(struct nilfs_btree *btree,
@@ -232,8 +230,8 @@ static void nilfs_btree_node_init(struct nilfs_btree *btree,
232 dkeys = nilfs_btree_node_dkeys(node); 230 dkeys = nilfs_btree_node_dkeys(node);
233 dptrs = nilfs_btree_node_dptrs(node, btree); 231 dptrs = nilfs_btree_node_dptrs(node, btree);
234 for (i = 0; i < nchildren; i++) { 232 for (i = 0; i < nchildren; i++) {
235 dkeys[i] = nilfs_bmap_key_to_dkey(keys[i]); 233 dkeys[i] = cpu_to_le64(keys[i]);
236 dptrs[i] = nilfs_bmap_ptr_to_dptr(ptrs[i]); 234 dptrs[i] = cpu_to_le64(ptrs[i]);
237 } 235 }
238} 236}
239 237
@@ -313,8 +311,8 @@ static void nilfs_btree_node_insert(struct nilfs_btree *btree,
313 memmove(dptrs + index + 1, dptrs + index, 311 memmove(dptrs + index + 1, dptrs + index,
314 (nchildren - index) * sizeof(*dptrs)); 312 (nchildren - index) * sizeof(*dptrs));
315 } 313 }
316 dkeys[index] = nilfs_bmap_key_to_dkey(key); 314 dkeys[index] = cpu_to_le64(key);
317 dptrs[index] = nilfs_bmap_ptr_to_dptr(ptr); 315 dptrs[index] = cpu_to_le64(ptr);
318 nchildren++; 316 nchildren++;
319 nilfs_btree_node_set_nchildren(node, nchildren); 317 nilfs_btree_node_set_nchildren(node, nchildren);
320} 318}
@@ -332,8 +330,8 @@ static void nilfs_btree_node_delete(struct nilfs_btree *btree,
332 330
333 dkeys = nilfs_btree_node_dkeys(node); 331 dkeys = nilfs_btree_node_dkeys(node);
334 dptrs = nilfs_btree_node_dptrs(node, btree); 332 dptrs = nilfs_btree_node_dptrs(node, btree);
335 key = nilfs_bmap_dkey_to_key(dkeys[index]); 333 key = le64_to_cpu(dkeys[index]);
336 ptr = nilfs_bmap_dptr_to_ptr(dptrs[index]); 334 ptr = le64_to_cpu(dptrs[index]);
337 nchildren = nilfs_btree_node_get_nchildren(node); 335 nchildren = nilfs_btree_node_get_nchildren(node);
338 if (keyp != NULL) 336 if (keyp != NULL)
339 *keyp = key; 337 *keyp = key;
@@ -1569,8 +1567,8 @@ static int nilfs_btree_gather_data(struct nilfs_bmap *bmap,
1569 dkeys = nilfs_btree_node_dkeys(node); 1567 dkeys = nilfs_btree_node_dkeys(node);
1570 dptrs = nilfs_btree_node_dptrs(node, btree); 1568 dptrs = nilfs_btree_node_dptrs(node, btree);
1571 for (i = 0; i < nitems; i++) { 1569 for (i = 0; i < nitems; i++) {
1572 keys[i] = nilfs_bmap_dkey_to_key(dkeys[i]); 1570 keys[i] = le64_to_cpu(dkeys[i]);
1573 ptrs[i] = nilfs_bmap_dptr_to_ptr(dptrs[i]); 1571 ptrs[i] = le64_to_cpu(dptrs[i]);
1574 } 1572 }
1575 1573
1576 if (bh != NULL) 1574 if (bh != NULL)
@@ -2059,7 +2057,7 @@ static int nilfs_btree_assign_p(struct nilfs_btree *btree,
2059 2057
2060 key = nilfs_btree_node_get_key(parent, path[level + 1].bp_index); 2058 key = nilfs_btree_node_get_key(parent, path[level + 1].bp_index);
2061 /* on-disk format */ 2059 /* on-disk format */
2062 binfo->bi_dat.bi_blkoff = nilfs_bmap_key_to_dkey(key); 2060 binfo->bi_dat.bi_blkoff = cpu_to_le64(key);
2063 binfo->bi_dat.bi_level = level; 2061 binfo->bi_dat.bi_level = level;
2064 2062
2065 return 0; 2063 return 0;
@@ -2090,8 +2088,8 @@ static int nilfs_btree_assign_v(struct nilfs_btree *btree,
2090 2088
2091 key = nilfs_btree_node_get_key(parent, path[level + 1].bp_index); 2089 key = nilfs_btree_node_get_key(parent, path[level + 1].bp_index);
2092 /* on-disk format */ 2090 /* on-disk format */
2093 binfo->bi_v.bi_vblocknr = nilfs_bmap_ptr_to_dptr(ptr); 2091 binfo->bi_v.bi_vblocknr = cpu_to_le64(ptr);
2094 binfo->bi_v.bi_blkoff = nilfs_bmap_key_to_dkey(key); 2092 binfo->bi_v.bi_blkoff = cpu_to_le64(key);
2095 2093
2096 return 0; 2094 return 0;
2097} 2095}
@@ -2159,7 +2157,7 @@ static int nilfs_btree_assign_gc(struct nilfs_bmap *bmap,
2159 2157
2160 /* on-disk format */ 2158 /* on-disk format */
2161 binfo->bi_v.bi_vblocknr = cpu_to_le64((*bh)->b_blocknr); 2159 binfo->bi_v.bi_vblocknr = cpu_to_le64((*bh)->b_blocknr);
2162 binfo->bi_v.bi_blkoff = nilfs_bmap_key_to_dkey(key); 2160 binfo->bi_v.bi_blkoff = cpu_to_le64(key);
2163 2161
2164 return 0; 2162 return 0;
2165} 2163}