diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-07-10 03:50:41 -0400 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-07-22 21:02:13 -0400 |
commit | 25b8d7ded0e4579bf152882249abfd351e65a17d (patch) | |
tree | 4949d1b531805b5ea2c25a544eea200f0ec3d580 /fs | |
parent | 1d5385b9f30ae43209459db424416a3e1d8f2bde (diff) |
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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nilfs2/bmap.h | 5 | ||||
-rw-r--r-- | fs/nilfs2/btree.c | 34 | ||||
-rw-r--r-- | fs/nilfs2/direct.c | 12 |
3 files changed, 22 insertions, 29 deletions
diff --git a/fs/nilfs2/bmap.h b/fs/nilfs2/bmap.h index 9980d7dbab91..de88ddf3bf02 100644 --- a/fs/nilfs2/bmap.h +++ b/fs/nilfs2/bmap.h | |||
@@ -32,11 +32,6 @@ | |||
32 | 32 | ||
33 | #define NILFS_BMAP_INVALID_PTR 0 | 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 | #define nilfs_bmap_keydiff_abs(diff) ((diff) < 0 ? -(diff) : (diff)) | 35 | #define nilfs_bmap_keydiff_abs(diff) ((diff) < 0 ? -(diff) : (diff)) |
41 | 36 | ||
42 | 37 | ||
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, | |||
191 | static inline __u64 | 191 | static inline __u64 |
192 | nilfs_btree_node_get_key(const struct nilfs_btree_node *node, int index) | 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 | static inline void | 197 | static inline void |
198 | nilfs_btree_node_set_key(struct nilfs_btree_node *node, int index, __u64 key) | 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 | static inline __u64 | 203 | static inline __u64 |
204 | nilfs_btree_node_get_ptr(const struct nilfs_btree *btree, | 204 | nilfs_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 | ||
211 | static inline void | 210 | static inline void |
212 | nilfs_btree_node_set_ptr(struct nilfs_btree *btree, | 211 | nilfs_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 | ||
219 | static void nilfs_btree_node_init(struct nilfs_btree *btree, | 217 | static 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 | } |
diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c index 236753df5cdf..32f1746a74a7 100644 --- a/fs/nilfs2/direct.c +++ b/fs/nilfs2/direct.c | |||
@@ -36,13 +36,13 @@ static inline __le64 *nilfs_direct_dptrs(const struct nilfs_direct *direct) | |||
36 | static inline __u64 | 36 | static inline __u64 |
37 | nilfs_direct_get_ptr(const struct nilfs_direct *direct, __u64 key) | 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 | static inline void nilfs_direct_set_ptr(struct nilfs_direct *direct, | 42 | static inline void nilfs_direct_set_ptr(struct nilfs_direct *direct, |
43 | __u64 key, __u64 ptr) | 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 | static int nilfs_direct_lookup(const struct nilfs_bmap *bmap, | 48 | static int nilfs_direct_lookup(const struct nilfs_bmap *bmap, |
@@ -258,7 +258,7 @@ int nilfs_direct_delete_and_convert(struct nilfs_bmap *bmap, | |||
258 | for (i = 0, j = 0; i < NILFS_DIRECT_NBLOCKS; i++) { | 258 | for (i = 0, j = 0; i < NILFS_DIRECT_NBLOCKS; i++) { |
259 | if ((j < n) && (i == keys[j])) { | 259 | if ((j < n) && (i == keys[j])) { |
260 | dptrs[i] = (i != key) ? | 260 | dptrs[i] = (i != key) ? |
261 | nilfs_bmap_ptr_to_dptr(ptrs[j]) : | 261 | cpu_to_le64(ptrs[j]) : |
262 | NILFS_BMAP_INVALID_PTR; | 262 | NILFS_BMAP_INVALID_PTR; |
263 | j++; | 263 | j++; |
264 | } else | 264 | } else |
@@ -315,8 +315,8 @@ static int nilfs_direct_assign_v(struct nilfs_direct *direct, | |||
315 | ret = nilfs_dat_prepare_start(dat, &req.bpr_req); | 315 | ret = nilfs_dat_prepare_start(dat, &req.bpr_req); |
316 | if (!ret) { | 316 | if (!ret) { |
317 | nilfs_dat_commit_start(dat, &req.bpr_req, blocknr); | 317 | nilfs_dat_commit_start(dat, &req.bpr_req, blocknr); |
318 | binfo->bi_v.bi_vblocknr = nilfs_bmap_ptr_to_dptr(ptr); | 318 | binfo->bi_v.bi_vblocknr = cpu_to_le64(ptr); |
319 | binfo->bi_v.bi_blkoff = nilfs_bmap_key_to_dkey(key); | 319 | binfo->bi_v.bi_blkoff = cpu_to_le64(key); |
320 | } | 320 | } |
321 | return ret; | 321 | return ret; |
322 | } | 322 | } |
@@ -329,7 +329,7 @@ static int nilfs_direct_assign_p(struct nilfs_direct *direct, | |||
329 | { | 329 | { |
330 | nilfs_direct_set_ptr(direct, key, blocknr); | 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 | binfo->bi_dat.bi_level = 0; | 333 | binfo->bi_dat.bi_level = 0; |
334 | 334 | ||
335 | return 0; | 335 | return 0; |