Skip to content

Commit 25b8d7d

Browse files
committed
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>
1 parent 1d5385b commit 25b8d7d

3 files changed

Lines changed: 22 additions & 29 deletions

File tree

‎fs/nilfs2/bmap.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@
3232

3333
#define NILFS_BMAP_INVALID_PTR 0
3434

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-
4035
#define nilfs_bmap_keydiff_abs(diff) ((diff) < 0 ? -(diff) : (diff))
4136

4237

‎fs/nilfs2/btree.c‎

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -191,29 +191,27 @@ nilfs_btree_node_dptrs(const struct nilfs_btree_node *node,
191191
static inline __u64
192192
nilfs_btree_node_get_key(const struct nilfs_btree_node *node, int index)
193193
{
194-
return nilfs_bmap_dkey_to_key(*(nilfs_btree_node_dkeys(node) + index));
194+
return le64_to_cpu(*(nilfs_btree_node_dkeys(node) + index));
195195
}
196196

197197
static inline void
198198
nilfs_btree_node_set_key(struct nilfs_btree_node *node, int index, __u64 key)
199199
{
200-
*(nilfs_btree_node_dkeys(node) + index) = nilfs_bmap_key_to_dkey(key);
200+
*(nilfs_btree_node_dkeys(node) + index) = cpu_to_le64(key);
201201
}
202202

203203
static inline __u64
204204
nilfs_btree_node_get_ptr(const struct nilfs_btree *btree,
205205
const struct nilfs_btree_node *node, int index)
206206
{
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));
209208
}
210209

211210
static inline void
212211
nilfs_btree_node_set_ptr(struct nilfs_btree *btree,
213212
struct nilfs_btree_node *node, int index, __u64 ptr)
214213
{
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);
217215
}
218216

219217
static void nilfs_btree_node_init(struct nilfs_btree *btree,
@@ -232,8 +230,8 @@ static void nilfs_btree_node_init(struct nilfs_btree *btree,
232230
dkeys = nilfs_btree_node_dkeys(node);
233231
dptrs = nilfs_btree_node_dptrs(node, btree);
234232
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]);
237235
}
238236
}
239237

@@ -313,8 +311,8 @@ static void nilfs_btree_node_insert(struct nilfs_btree *btree,
313311
memmove(dptrs + index + 1, dptrs + index,
314312
(nchildren - index) * sizeof(*dptrs));
315313
}
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);
318316
nchildren++;
319317
nilfs_btree_node_set_nchildren(node, nchildren);
320318
}
@@ -332,8 +330,8 @@ static void nilfs_btree_node_delete(struct nilfs_btree *btree,
332330

333331
dkeys = nilfs_btree_node_dkeys(node);
334332
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]);
337335
nchildren = nilfs_btree_node_get_nchildren(node);
338336
if (keyp != NULL)
339337
*keyp = key;
@@ -1569,8 +1567,8 @@ static int nilfs_btree_gather_data(struct nilfs_bmap *bmap,
15691567
dkeys = nilfs_btree_node_dkeys(node);
15701568
dptrs = nilfs_btree_node_dptrs(node, btree);
15711569
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]);
15741572
}
15751573

15761574
if (bh != NULL)
@@ -2059,7 +2057,7 @@ static int nilfs_btree_assign_p(struct nilfs_btree *btree,
20592057

20602058
key = nilfs_btree_node_get_key(parent, path[level + 1].bp_index);
20612059
/* 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);
20632061
binfo->bi_dat.bi_level = level;
20642062

20652063
return 0;
@@ -2090,8 +2088,8 @@ static int nilfs_btree_assign_v(struct nilfs_btree *btree,
20902088

20912089
key = nilfs_btree_node_get_key(parent, path[level + 1].bp_index);
20922090
/* 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);
20952093

20962094
return 0;
20972095
}
@@ -2159,7 +2157,7 @@ static int nilfs_btree_assign_gc(struct nilfs_bmap *bmap,
21592157

21602158
/* on-disk format */
21612159
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);
21632161

21642162
return 0;
21652163
}

‎fs/nilfs2/direct.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ static inline __le64 *nilfs_direct_dptrs(const struct nilfs_direct *direct)
3636
static inline __u64
3737
nilfs_direct_get_ptr(const struct nilfs_direct *direct, __u64 key)
3838
{
39-
return nilfs_bmap_dptr_to_ptr(*(nilfs_direct_dptrs(direct) + key));
39+
return le64_to_cpu(*(nilfs_direct_dptrs(direct) + key));
4040
}
4141

4242
static inline void nilfs_direct_set_ptr(struct nilfs_direct *direct,
4343
__u64 key, __u64 ptr)
4444
{
45-
*(nilfs_direct_dptrs(direct) + key) = nilfs_bmap_ptr_to_dptr(ptr);
45+
*(nilfs_direct_dptrs(direct) + key) = cpu_to_le64(ptr);
4646
}
4747

4848
static int nilfs_direct_lookup(const struct nilfs_bmap *bmap,
@@ -258,7 +258,7 @@ int nilfs_direct_delete_and_convert(struct nilfs_bmap *bmap,
258258
for (i = 0, j = 0; i < NILFS_DIRECT_NBLOCKS; i++) {
259259
if ((j < n) && (i == keys[j])) {
260260
dptrs[i] = (i != key) ?
261-
nilfs_bmap_ptr_to_dptr(ptrs[j]) :
261+
cpu_to_le64(ptrs[j]) :
262262
NILFS_BMAP_INVALID_PTR;
263263
j++;
264264
} else
@@ -315,8 +315,8 @@ static int nilfs_direct_assign_v(struct nilfs_direct *direct,
315315
ret = nilfs_dat_prepare_start(dat, &req.bpr_req);
316316
if (!ret) {
317317
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);
320320
}
321321
return ret;
322322
}
@@ -329,7 +329,7 @@ static int nilfs_direct_assign_p(struct nilfs_direct *direct,
329329
{
330330
nilfs_direct_set_ptr(direct, key, blocknr);
331331

332-
binfo->bi_dat.bi_blkoff = nilfs_bmap_key_to_dkey(key);
332+
binfo->bi_dat.bi_blkoff = cpu_to_le64(key);
333333
binfo->bi_dat.bi_level = 0;
334334

335335
return 0;

0 commit comments

Comments
 (0)