Commit 25b8d7ded0e4579bf152882249abfd351e65a17d

Authored by Ryusuke Konishi
1 parent 1d5385b9f3

nilfs2: get rid of private conversion macros on bmap key and pointer

Will remove nilfs_bmap_key_to_dkey(), nilfs_bmap_dkey_to_key(),
nilfs_bmap_ptr_to_dptr(), and nilfs_bmap_dptr_to_ptr() for simplicity.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>

Showing 3 changed files with 22 additions and 29 deletions Side-by-side Diff

... ... @@ -32,11 +32,6 @@
32 32  
33 33 #define NILFS_BMAP_INVALID_PTR 0
34 34  
35   -#define nilfs_bmap_dkey_to_key(dkey) le64_to_cpu(dkey)
36   -#define nilfs_bmap_key_to_dkey(key) cpu_to_le64(key)
37   -#define nilfs_bmap_dptr_to_ptr(dptr) le64_to_cpu(dptr)
38   -#define nilfs_bmap_ptr_to_dptr(ptr) cpu_to_le64(ptr)
39   -
40 35 #define nilfs_bmap_keydiff_abs(diff) ((diff) < 0 ? -(diff) : (diff))
41 36  
42 37  
... ... @@ -191,29 +191,27 @@
191 191 static inline __u64
192 192 nilfs_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  
197 197 static inline void
198 198 nilfs_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  
203 203 static inline __u64
204 204 nilfs_btree_node_get_ptr(const struct nilfs_btree *btree,
205 205 const struct nilfs_btree_node *node, int index)
206 206 {
207   - return nilfs_bmap_dptr_to_ptr(*(nilfs_btree_node_dptrs(node, btree) +
208   - index));
  207 + return le64_to_cpu(*(nilfs_btree_node_dptrs(node, btree) + index));
209 208 }
210 209  
211 210 static inline void
212 211 nilfs_btree_node_set_ptr(struct nilfs_btree *btree,
213 212 struct nilfs_btree_node *node, int index, __u64 ptr)
214 213 {
215   - *(nilfs_btree_node_dptrs(node, btree) + index) =
216   - nilfs_bmap_ptr_to_dptr(ptr);
  214 + *(nilfs_btree_node_dptrs(node, btree) + index) = cpu_to_le64(ptr);
217 215 }
218 216  
219 217 static void nilfs_btree_node_init(struct nilfs_btree *btree,
... ... @@ -232,8 +230,8 @@
232 230 dkeys = nilfs_btree_node_dkeys(node);
233 231 dptrs = nilfs_btree_node_dptrs(node, btree);
234 232 for (i = 0; i < nchildren; i++) {
235   - dkeys[i] = nilfs_bmap_key_to_dkey(keys[i]);
236   - dptrs[i] = nilfs_bmap_ptr_to_dptr(ptrs[i]);
  233 + dkeys[i] = cpu_to_le64(keys[i]);
  234 + dptrs[i] = cpu_to_le64(ptrs[i]);
237 235 }
238 236 }
239 237  
... ... @@ -313,8 +311,8 @@
313 311 memmove(dptrs + index + 1, dptrs + index,
314 312 (nchildren - index) * sizeof(*dptrs));
315 313 }
316   - dkeys[index] = nilfs_bmap_key_to_dkey(key);
317   - dptrs[index] = nilfs_bmap_ptr_to_dptr(ptr);
  314 + dkeys[index] = cpu_to_le64(key);
  315 + dptrs[index] = cpu_to_le64(ptr);
318 316 nchildren++;
319 317 nilfs_btree_node_set_nchildren(node, nchildren);
320 318 }
... ... @@ -332,8 +330,8 @@
332 330  
333 331 dkeys = nilfs_btree_node_dkeys(node);
334 332 dptrs = nilfs_btree_node_dptrs(node, btree);
335   - key = nilfs_bmap_dkey_to_key(dkeys[index]);
336   - ptr = nilfs_bmap_dptr_to_ptr(dptrs[index]);
  333 + key = le64_to_cpu(dkeys[index]);
  334 + ptr = le64_to_cpu(dptrs[index]);
337 335 nchildren = nilfs_btree_node_get_nchildren(node);
338 336 if (keyp != NULL)
339 337 *keyp = key;
... ... @@ -1569,8 +1567,8 @@
1569 1567 dkeys = nilfs_btree_node_dkeys(node);
1570 1568 dptrs = nilfs_btree_node_dptrs(node, btree);
1571 1569 for (i = 0; i < nitems; i++) {
1572   - keys[i] = nilfs_bmap_dkey_to_key(dkeys[i]);
1573   - ptrs[i] = nilfs_bmap_dptr_to_ptr(dptrs[i]);
  1570 + keys[i] = le64_to_cpu(dkeys[i]);
  1571 + ptrs[i] = le64_to_cpu(dptrs[i]);
1574 1572 }
1575 1573  
1576 1574 if (bh != NULL)
... ... @@ -2059,7 +2057,7 @@
2059 2057  
2060 2058 key = nilfs_btree_node_get_key(parent, path[level + 1].bp_index);
2061 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 2061 binfo->bi_dat.bi_level = level;
2064 2062  
2065 2063 return 0;
... ... @@ -2090,8 +2088,8 @@
2090 2088  
2091 2089 key = nilfs_btree_node_get_key(parent, path[level + 1].bp_index);
2092 2090 /* on-disk format */
2093   - binfo->bi_v.bi_vblocknr = nilfs_bmap_ptr_to_dptr(ptr);
2094   - binfo->bi_v.bi_blkoff = nilfs_bmap_key_to_dkey(key);
  2091 + binfo->bi_v.bi_vblocknr = cpu_to_le64(ptr);
  2092 + binfo->bi_v.bi_blkoff = cpu_to_le64(key);
2095 2093  
2096 2094 return 0;
2097 2095 }
... ... @@ -2159,7 +2157,7 @@
2159 2157  
2160 2158 /* on-disk format */
2161 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 2162 return 0;
2165 2163 }
... ... @@ -36,13 +36,13 @@
36 36 static inline __u64
37 37 nilfs_direct_get_ptr(const struct nilfs_direct *direct, __u64 key)
38 38 {
39   - return nilfs_bmap_dptr_to_ptr(*(nilfs_direct_dptrs(direct) + key));
  39 + return le64_to_cpu(*(nilfs_direct_dptrs(direct) + key));
40 40 }
41 41  
42 42 static inline void nilfs_direct_set_ptr(struct nilfs_direct *direct,
43 43 __u64 key, __u64 ptr)
44 44 {
45   - *(nilfs_direct_dptrs(direct) + key) = nilfs_bmap_ptr_to_dptr(ptr);
  45 + *(nilfs_direct_dptrs(direct) + key) = cpu_to_le64(ptr);
46 46 }
47 47  
48 48 static int nilfs_direct_lookup(const struct nilfs_bmap *bmap,
... ... @@ -258,7 +258,7 @@
258 258 for (i = 0, j = 0; i < NILFS_DIRECT_NBLOCKS; i++) {
259 259 if ((j < n) && (i == keys[j])) {
260 260 dptrs[i] = (i != key) ?
261   - nilfs_bmap_ptr_to_dptr(ptrs[j]) :
  261 + cpu_to_le64(ptrs[j]) :
262 262 NILFS_BMAP_INVALID_PTR;
263 263 j++;
264 264 } else
... ... @@ -315,8 +315,8 @@
315 315 ret = nilfs_dat_prepare_start(dat, &req.bpr_req);
316 316 if (!ret) {
317 317 nilfs_dat_commit_start(dat, &req.bpr_req, blocknr);
318   - binfo->bi_v.bi_vblocknr = nilfs_bmap_ptr_to_dptr(ptr);
319   - binfo->bi_v.bi_blkoff = nilfs_bmap_key_to_dkey(key);
  318 + binfo->bi_v.bi_vblocknr = cpu_to_le64(ptr);
  319 + binfo->bi_v.bi_blkoff = cpu_to_le64(key);
320 320 }
321 321 return ret;
322 322 }
... ... @@ -329,7 +329,7 @@
329 329 {
330 330 nilfs_direct_set_ptr(direct, key, blocknr);
331 331  
332   - binfo->bi_dat.bi_blkoff = nilfs_bmap_key_to_dkey(key);
  332 + binfo->bi_dat.bi_blkoff = cpu_to_le64(key);
333 333 binfo->bi_dat.bi_level = 0;
334 334  
335 335 return 0;