aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dir2_node.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_dir2_node.c')
-rw-r--r--fs/xfs/xfs_dir2_node.c303
1 files changed, 152 insertions, 151 deletions
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index 641f8633d254..af556f16a0c7 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -76,7 +76,7 @@ xfs_dir2_free_log_bests(
76 xfs_dir2_free_t *free; /* freespace structure */ 76 xfs_dir2_free_t *free; /* freespace structure */
77 77
78 free = bp->data; 78 free = bp->data;
79 ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); 79 ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
80 xfs_da_log_buf(tp, bp, 80 xfs_da_log_buf(tp, bp,
81 (uint)((char *)&free->bests[first] - (char *)free), 81 (uint)((char *)&free->bests[first] - (char *)free),
82 (uint)((char *)&free->bests[last] - (char *)free + 82 (uint)((char *)&free->bests[last] - (char *)free +
@@ -94,7 +94,7 @@ xfs_dir2_free_log_header(
94 xfs_dir2_free_t *free; /* freespace structure */ 94 xfs_dir2_free_t *free; /* freespace structure */
95 95
96 free = bp->data; 96 free = bp->data;
97 ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); 97 ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
98 xfs_da_log_buf(tp, bp, (uint)((char *)&free->hdr - (char *)free), 98 xfs_da_log_buf(tp, bp, (uint)((char *)&free->hdr - (char *)free),
99 (uint)(sizeof(xfs_dir2_free_hdr_t) - 1)); 99 (uint)(sizeof(xfs_dir2_free_hdr_t) - 1));
100} 100}
@@ -114,14 +114,14 @@ xfs_dir2_leaf_to_node(
114 xfs_dabuf_t *fbp; /* freespace buffer */ 114 xfs_dabuf_t *fbp; /* freespace buffer */
115 xfs_dir2_db_t fdb; /* freespace block number */ 115 xfs_dir2_db_t fdb; /* freespace block number */
116 xfs_dir2_free_t *free; /* freespace structure */ 116 xfs_dir2_free_t *free; /* freespace structure */
117 xfs_dir2_data_off_t *from; /* pointer to freespace entry */ 117 __be16 *from; /* pointer to freespace entry */
118 int i; /* leaf freespace index */ 118 int i; /* leaf freespace index */
119 xfs_dir2_leaf_t *leaf; /* leaf structure */ 119 xfs_dir2_leaf_t *leaf; /* leaf structure */
120 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ 120 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
121 xfs_mount_t *mp; /* filesystem mount point */ 121 xfs_mount_t *mp; /* filesystem mount point */
122 int n; /* count of live freespc ents */ 122 int n; /* count of live freespc ents */
123 xfs_dir2_data_off_t off; /* freespace entry value */ 123 xfs_dir2_data_off_t off; /* freespace entry value */
124 xfs_dir2_data_off_t *to; /* pointer to freespace entry */ 124 __be16 *to; /* pointer to freespace entry */
125 xfs_trans_t *tp; /* transaction pointer */ 125 xfs_trans_t *tp; /* transaction pointer */
126 126
127 xfs_dir2_trace_args_b("leaf_to_node", args, lbp); 127 xfs_dir2_trace_args_b("leaf_to_node", args, lbp);
@@ -149,28 +149,28 @@ xfs_dir2_leaf_to_node(
149 /* 149 /*
150 * Initialize the freespace block header. 150 * Initialize the freespace block header.
151 */ 151 */
152 INT_SET(free->hdr.magic, ARCH_CONVERT, XFS_DIR2_FREE_MAGIC); 152 free->hdr.magic = cpu_to_be32(XFS_DIR2_FREE_MAGIC);
153 free->hdr.firstdb = 0; 153 free->hdr.firstdb = 0;
154 ASSERT(INT_GET(ltp->bestcount, ARCH_CONVERT) <= (uint)dp->i_d.di_size / mp->m_dirblksize); 154 ASSERT(be32_to_cpu(ltp->bestcount) <= (uint)dp->i_d.di_size / mp->m_dirblksize);
155 INT_COPY(free->hdr.nvalid, ltp->bestcount, ARCH_CONVERT); 155 free->hdr.nvalid = ltp->bestcount;
156 /* 156 /*
157 * Copy freespace entries from the leaf block to the new block. 157 * Copy freespace entries from the leaf block to the new block.
158 * Count active entries. 158 * Count active entries.
159 */ 159 */
160 for (i = n = 0, from = XFS_DIR2_LEAF_BESTS_P(ltp), to = free->bests; 160 for (i = n = 0, from = XFS_DIR2_LEAF_BESTS_P(ltp), to = free->bests;
161 i < INT_GET(ltp->bestcount, ARCH_CONVERT); i++, from++, to++) { 161 i < be32_to_cpu(ltp->bestcount); i++, from++, to++) {
162 if ((off = INT_GET(*from, ARCH_CONVERT)) != NULLDATAOFF) 162 if ((off = be16_to_cpu(*from)) != NULLDATAOFF)
163 n++; 163 n++;
164 INT_SET(*to, ARCH_CONVERT, off); 164 *to = cpu_to_be16(off);
165 } 165 }
166 INT_SET(free->hdr.nused, ARCH_CONVERT, n); 166 free->hdr.nused = cpu_to_be32(n);
167 INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, XFS_DIR2_LEAFN_MAGIC); 167 leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAFN_MAGIC);
168 /* 168 /*
169 * Log everything. 169 * Log everything.
170 */ 170 */
171 xfs_dir2_leaf_log_header(tp, lbp); 171 xfs_dir2_leaf_log_header(tp, lbp);
172 xfs_dir2_free_log_header(tp, fbp); 172 xfs_dir2_free_log_header(tp, fbp);
173 xfs_dir2_free_log_bests(tp, fbp, 0, INT_GET(free->hdr.nvalid, ARCH_CONVERT) - 1); 173 xfs_dir2_free_log_bests(tp, fbp, 0, be32_to_cpu(free->hdr.nvalid) - 1);
174 xfs_da_buf_done(fbp); 174 xfs_da_buf_done(fbp);
175 xfs_dir2_leafn_check(dp, lbp); 175 xfs_dir2_leafn_check(dp, lbp);
176 return 0; 176 return 0;
@@ -217,15 +217,15 @@ xfs_dir2_leafn_add(
217 * a compact. 217 * a compact.
218 */ 218 */
219 219
220 if (INT_GET(leaf->hdr.count, ARCH_CONVERT) == XFS_DIR2_MAX_LEAF_ENTS(mp)) { 220 if (be16_to_cpu(leaf->hdr.count) == XFS_DIR2_MAX_LEAF_ENTS(mp)) {
221 if (!leaf->hdr.stale) 221 if (!leaf->hdr.stale)
222 return XFS_ERROR(ENOSPC); 222 return XFS_ERROR(ENOSPC);
223 compact = INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1; 223 compact = be16_to_cpu(leaf->hdr.stale) > 1;
224 } else 224 } else
225 compact = 0; 225 compact = 0;
226 ASSERT(index == 0 || INT_GET(leaf->ents[index - 1].hashval, ARCH_CONVERT) <= args->hashval); 226 ASSERT(index == 0 || be32_to_cpu(leaf->ents[index - 1].hashval) <= args->hashval);
227 ASSERT(index == INT_GET(leaf->hdr.count, ARCH_CONVERT) || 227 ASSERT(index == be16_to_cpu(leaf->hdr.count) ||
228 INT_GET(leaf->ents[index].hashval, ARCH_CONVERT) >= args->hashval); 228 be32_to_cpu(leaf->ents[index].hashval) >= args->hashval);
229 229
230 if (args->justcheck) 230 if (args->justcheck)
231 return 0; 231 return 0;
@@ -242,7 +242,7 @@ xfs_dir2_leafn_add(
242 * Set impossible logging indices for this case. 242 * Set impossible logging indices for this case.
243 */ 243 */
244 else if (leaf->hdr.stale) { 244 else if (leaf->hdr.stale) {
245 lfloglow = INT_GET(leaf->hdr.count, ARCH_CONVERT); 245 lfloglow = be16_to_cpu(leaf->hdr.count);
246 lfloghigh = -1; 246 lfloghigh = -1;
247 } 247 }
248 /* 248 /*
@@ -250,12 +250,12 @@ xfs_dir2_leafn_add(
250 */ 250 */
251 if (!leaf->hdr.stale) { 251 if (!leaf->hdr.stale) {
252 lep = &leaf->ents[index]; 252 lep = &leaf->ents[index];
253 if (index < INT_GET(leaf->hdr.count, ARCH_CONVERT)) 253 if (index < be16_to_cpu(leaf->hdr.count))
254 memmove(lep + 1, lep, 254 memmove(lep + 1, lep,
255 (INT_GET(leaf->hdr.count, ARCH_CONVERT) - index) * sizeof(*lep)); 255 (be16_to_cpu(leaf->hdr.count) - index) * sizeof(*lep));
256 lfloglow = index; 256 lfloglow = index;
257 lfloghigh = INT_GET(leaf->hdr.count, ARCH_CONVERT); 257 lfloghigh = be16_to_cpu(leaf->hdr.count);
258 INT_MOD(leaf->hdr.count, ARCH_CONVERT, +1); 258 be16_add(&leaf->hdr.count, 1);
259 } 259 }
260 /* 260 /*
261 * There are stale entries. We'll use one for the new entry. 261 * There are stale entries. We'll use one for the new entry.
@@ -271,7 +271,7 @@ xfs_dir2_leafn_add(
271 */ 271 */
272 for (lowstale = index - 1; 272 for (lowstale = index - 1;
273 lowstale >= 0 && 273 lowstale >= 0 &&
274 INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) != 274 be32_to_cpu(leaf->ents[lowstale].address) !=
275 XFS_DIR2_NULL_DATAPTR; 275 XFS_DIR2_NULL_DATAPTR;
276 lowstale--) 276 lowstale--)
277 continue; 277 continue;
@@ -281,8 +281,8 @@ xfs_dir2_leafn_add(
281 * lowstale already found. 281 * lowstale already found.
282 */ 282 */
283 for (highstale = index; 283 for (highstale = index;
284 highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) && 284 highstale < be16_to_cpu(leaf->hdr.count) &&
285 INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != 285 be32_to_cpu(leaf->ents[highstale].address) !=
286 XFS_DIR2_NULL_DATAPTR && 286 XFS_DIR2_NULL_DATAPTR &&
287 (lowstale < 0 || 287 (lowstale < 0 ||
288 index - lowstale - 1 >= highstale - index); 288 index - lowstale - 1 >= highstale - index);
@@ -294,9 +294,9 @@ xfs_dir2_leafn_add(
294 * Shift entries up toward the stale slot. 294 * Shift entries up toward the stale slot.
295 */ 295 */
296 if (lowstale >= 0 && 296 if (lowstale >= 0 &&
297 (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) || 297 (highstale == be16_to_cpu(leaf->hdr.count) ||
298 index - lowstale - 1 < highstale - index)) { 298 index - lowstale - 1 < highstale - index)) {
299 ASSERT(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) == 299 ASSERT(be32_to_cpu(leaf->ents[lowstale].address) ==
300 XFS_DIR2_NULL_DATAPTR); 300 XFS_DIR2_NULL_DATAPTR);
301 ASSERT(index - lowstale - 1 >= 0); 301 ASSERT(index - lowstale - 1 >= 0);
302 if (index - lowstale - 1 > 0) 302 if (index - lowstale - 1 > 0)
@@ -312,7 +312,7 @@ xfs_dir2_leafn_add(
312 * Shift entries down toward the stale slot. 312 * Shift entries down toward the stale slot.
313 */ 313 */
314 else { 314 else {
315 ASSERT(INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) == 315 ASSERT(be32_to_cpu(leaf->ents[highstale].address) ==
316 XFS_DIR2_NULL_DATAPTR); 316 XFS_DIR2_NULL_DATAPTR);
317 ASSERT(highstale - index >= 0); 317 ASSERT(highstale - index >= 0);
318 if (highstale - index > 0) 318 if (highstale - index > 0)
@@ -323,13 +323,14 @@ xfs_dir2_leafn_add(
323 lfloglow = MIN(index, lfloglow); 323 lfloglow = MIN(index, lfloglow);
324 lfloghigh = MAX(highstale, lfloghigh); 324 lfloghigh = MAX(highstale, lfloghigh);
325 } 325 }
326 INT_MOD(leaf->hdr.stale, ARCH_CONVERT, -1); 326 be16_add(&leaf->hdr.stale, -1);
327 } 327 }
328 /* 328 /*
329 * Insert the new entry, log everything. 329 * Insert the new entry, log everything.
330 */ 330 */
331 INT_SET(lep->hashval, ARCH_CONVERT, args->hashval); 331 lep->hashval = cpu_to_be32(args->hashval);
332 INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_DB_OFF_TO_DATAPTR(mp, args->blkno, args->index)); 332 lep->address = cpu_to_be32(XFS_DIR2_DB_OFF_TO_DATAPTR(mp,
333 args->blkno, args->index));
333 xfs_dir2_leaf_log_header(tp, bp); 334 xfs_dir2_leaf_log_header(tp, bp);
334 xfs_dir2_leaf_log_ents(tp, bp, lfloglow, lfloghigh); 335 xfs_dir2_leaf_log_ents(tp, bp, lfloglow, lfloghigh);
335 xfs_dir2_leafn_check(dp, bp); 336 xfs_dir2_leafn_check(dp, bp);
@@ -352,17 +353,17 @@ xfs_dir2_leafn_check(
352 353
353 leaf = bp->data; 354 leaf = bp->data;
354 mp = dp->i_mount; 355 mp = dp->i_mount;
355 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 356 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
356 ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); 357 ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp));
357 for (i = stale = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); i++) { 358 for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) {
358 if (i + 1 < INT_GET(leaf->hdr.count, ARCH_CONVERT)) { 359 if (i + 1 < be16_to_cpu(leaf->hdr.count)) {
359 ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <= 360 ASSERT(be32_to_cpu(leaf->ents[i].hashval) <=
360 INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT)); 361 be32_to_cpu(leaf->ents[i + 1].hashval));
361 } 362 }
362 if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) 363 if (be32_to_cpu(leaf->ents[i].address) == XFS_DIR2_NULL_DATAPTR)
363 stale++; 364 stale++;
364 } 365 }
365 ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == stale); 366 ASSERT(be16_to_cpu(leaf->hdr.stale) == stale);
366} 367}
367#endif /* DEBUG */ 368#endif /* DEBUG */
368 369
@@ -378,12 +379,12 @@ xfs_dir2_leafn_lasthash(
378 xfs_dir2_leaf_t *leaf; /* leaf structure */ 379 xfs_dir2_leaf_t *leaf; /* leaf structure */
379 380
380 leaf = bp->data; 381 leaf = bp->data;
381 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 382 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
382 if (count) 383 if (count)
383 *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); 384 *count = be16_to_cpu(leaf->hdr.count);
384 if (!leaf->hdr.count) 385 if (!leaf->hdr.count)
385 return 0; 386 return 0;
386 return INT_GET(leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); 387 return be32_to_cpu(leaf->ents[be16_to_cpu(leaf->hdr.count) - 1].hashval);
387} 388}
388 389
389/* 390/*
@@ -419,9 +420,9 @@ xfs_dir2_leafn_lookup_int(
419 tp = args->trans; 420 tp = args->trans;
420 mp = dp->i_mount; 421 mp = dp->i_mount;
421 leaf = bp->data; 422 leaf = bp->data;
422 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 423 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
423#ifdef __KERNEL__ 424#ifdef __KERNEL__
424 ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) > 0); 425 ASSERT(be16_to_cpu(leaf->hdr.count) > 0);
425#endif 426#endif
426 xfs_dir2_leafn_check(dp, bp); 427 xfs_dir2_leafn_check(dp, bp);
427 /* 428 /*
@@ -443,7 +444,7 @@ xfs_dir2_leafn_lookup_int(
443 curdb = -1; 444 curdb = -1;
444 length = XFS_DIR2_DATA_ENTSIZE(args->namelen); 445 length = XFS_DIR2_DATA_ENTSIZE(args->namelen);
445 if ((free = (curbp ? curbp->data : NULL))) 446 if ((free = (curbp ? curbp->data : NULL)))
446 ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); 447 ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
447 } 448 }
448 /* 449 /*
449 * For others, it's a data block buffer, get the block number. 450 * For others, it's a data block buffer, get the block number.
@@ -456,17 +457,17 @@ xfs_dir2_leafn_lookup_int(
456 * Loop over leaf entries with the right hash value. 457 * Loop over leaf entries with the right hash value.
457 */ 458 */
458 for (lep = &leaf->ents[index]; 459 for (lep = &leaf->ents[index];
459 index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; 460 index < be16_to_cpu(leaf->hdr.count) && be32_to_cpu(lep->hashval) == args->hashval;
460 lep++, index++) { 461 lep++, index++) {
461 /* 462 /*
462 * Skip stale leaf entries. 463 * Skip stale leaf entries.
463 */ 464 */
464 if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) 465 if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
465 continue; 466 continue;
466 /* 467 /*
467 * Pull the data block number from the entry. 468 * Pull the data block number from the entry.
468 */ 469 */
469 newdb = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT)); 470 newdb = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address));
470 /* 471 /*
471 * For addname, we're looking for a place to put the new entry. 472 * For addname, we're looking for a place to put the new entry.
472 * We want to use a data block with an entry of equal 473 * We want to use a data block with an entry of equal
@@ -506,15 +507,15 @@ xfs_dir2_leafn_lookup_int(
506 } 507 }
507 curfdb = newfdb; 508 curfdb = newfdb;
508 free = curbp->data; 509 free = curbp->data;
509 ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == 510 ASSERT(be32_to_cpu(free->hdr.magic) ==
510 XFS_DIR2_FREE_MAGIC); 511 XFS_DIR2_FREE_MAGIC);
511 ASSERT((INT_GET(free->hdr.firstdb, ARCH_CONVERT) % 512 ASSERT((be32_to_cpu(free->hdr.firstdb) %
512 XFS_DIR2_MAX_FREE_BESTS(mp)) == 513 XFS_DIR2_MAX_FREE_BESTS(mp)) ==
513 0); 514 0);
514 ASSERT(INT_GET(free->hdr.firstdb, ARCH_CONVERT) <= curdb); 515 ASSERT(be32_to_cpu(free->hdr.firstdb) <= curdb);
515 ASSERT(curdb < 516 ASSERT(curdb <
516 INT_GET(free->hdr.firstdb, ARCH_CONVERT) + 517 be32_to_cpu(free->hdr.firstdb) +
517 INT_GET(free->hdr.nvalid, ARCH_CONVERT)); 518 be32_to_cpu(free->hdr.nvalid));
518 } 519 }
519 /* 520 /*
520 * Get the index for our entry. 521 * Get the index for our entry.
@@ -523,12 +524,12 @@ xfs_dir2_leafn_lookup_int(
523 /* 524 /*
524 * If it has room, return it. 525 * If it has room, return it.
525 */ 526 */
526 if (unlikely(INT_GET(free->bests[fi], ARCH_CONVERT) == NULLDATAOFF)) { 527 if (unlikely(be16_to_cpu(free->bests[fi]) == NULLDATAOFF)) {
527 XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int", 528 XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int",
528 XFS_ERRLEVEL_LOW, mp); 529 XFS_ERRLEVEL_LOW, mp);
529 return XFS_ERROR(EFSCORRUPTED); 530 return XFS_ERROR(EFSCORRUPTED);
530 } 531 }
531 if (INT_GET(free->bests[fi], ARCH_CONVERT) >= length) { 532 if (be16_to_cpu(free->bests[fi]) >= length) {
532 *indexp = index; 533 *indexp = index;
533 state->extravalid = 1; 534 state->extravalid = 1;
534 state->extrablk.bp = curbp; 535 state->extrablk.bp = curbp;
@@ -572,7 +573,7 @@ xfs_dir2_leafn_lookup_int(
572 */ 573 */
573 dep = (xfs_dir2_data_entry_t *) 574 dep = (xfs_dir2_data_entry_t *)
574 ((char *)curbp->data + 575 ((char *)curbp->data +
575 XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT))); 576 XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address)));
576 /* 577 /*
577 * Compare the entry, return it if it matches. 578 * Compare the entry, return it if it matches.
578 */ 579 */
@@ -619,7 +620,7 @@ xfs_dir2_leafn_lookup_int(
619 * Return the final index, that will be the insertion point. 620 * Return the final index, that will be the insertion point.
620 */ 621 */
621 *indexp = index; 622 *indexp = index;
622 ASSERT(index == INT_GET(leaf->hdr.count, ARCH_CONVERT) || args->oknoent); 623 ASSERT(index == be16_to_cpu(leaf->hdr.count) || args->oknoent);
623 return XFS_ERROR(ENOENT); 624 return XFS_ERROR(ENOENT);
624} 625}
625 626
@@ -657,12 +658,12 @@ xfs_dir2_leafn_moveents(
657 * destination leaf entries, open up a hole in the destination 658 * destination leaf entries, open up a hole in the destination
658 * to hold the new entries. 659 * to hold the new entries.
659 */ 660 */
660 if (start_d < INT_GET(leaf_d->hdr.count, ARCH_CONVERT)) { 661 if (start_d < be16_to_cpu(leaf_d->hdr.count)) {
661 memmove(&leaf_d->ents[start_d + count], &leaf_d->ents[start_d], 662 memmove(&leaf_d->ents[start_d + count], &leaf_d->ents[start_d],
662 (INT_GET(leaf_d->hdr.count, ARCH_CONVERT) - start_d) * 663 (be16_to_cpu(leaf_d->hdr.count) - start_d) *
663 sizeof(xfs_dir2_leaf_entry_t)); 664 sizeof(xfs_dir2_leaf_entry_t));
664 xfs_dir2_leaf_log_ents(tp, bp_d, start_d + count, 665 xfs_dir2_leaf_log_ents(tp, bp_d, start_d + count,
665 count + INT_GET(leaf_d->hdr.count, ARCH_CONVERT) - 1); 666 count + be16_to_cpu(leaf_d->hdr.count) - 1);
666 } 667 }
667 /* 668 /*
668 * If the source has stale leaves, count the ones in the copy range 669 * If the source has stale leaves, count the ones in the copy range
@@ -672,7 +673,7 @@ xfs_dir2_leafn_moveents(
672 int i; /* temp leaf index */ 673 int i; /* temp leaf index */
673 674
674 for (i = start_s, stale = 0; i < start_s + count; i++) { 675 for (i = start_s, stale = 0; i < start_s + count; i++) {
675 if (INT_GET(leaf_s->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) 676 if (be32_to_cpu(leaf_s->ents[i].address) == XFS_DIR2_NULL_DATAPTR)
676 stale++; 677 stale++;
677 } 678 }
678 } else 679 } else
@@ -687,7 +688,7 @@ xfs_dir2_leafn_moveents(
687 * If there are source entries after the ones we copied, 688 * If there are source entries after the ones we copied,
688 * delete the ones we copied by sliding the next ones down. 689 * delete the ones we copied by sliding the next ones down.
689 */ 690 */
690 if (start_s + count < INT_GET(leaf_s->hdr.count, ARCH_CONVERT)) { 691 if (start_s + count < be16_to_cpu(leaf_s->hdr.count)) {
691 memmove(&leaf_s->ents[start_s], &leaf_s->ents[start_s + count], 692 memmove(&leaf_s->ents[start_s], &leaf_s->ents[start_s + count],
692 count * sizeof(xfs_dir2_leaf_entry_t)); 693 count * sizeof(xfs_dir2_leaf_entry_t));
693 xfs_dir2_leaf_log_ents(tp, bp_s, start_s, start_s + count - 1); 694 xfs_dir2_leaf_log_ents(tp, bp_s, start_s, start_s + count - 1);
@@ -695,10 +696,10 @@ xfs_dir2_leafn_moveents(
695 /* 696 /*
696 * Update the headers and log them. 697 * Update the headers and log them.
697 */ 698 */
698 INT_MOD(leaf_s->hdr.count, ARCH_CONVERT, -(count)); 699 be16_add(&leaf_s->hdr.count, -(count));
699 INT_MOD(leaf_s->hdr.stale, ARCH_CONVERT, -(stale)); 700 be16_add(&leaf_s->hdr.stale, -(stale));
700 INT_MOD(leaf_d->hdr.count, ARCH_CONVERT, count); 701 be16_add(&leaf_d->hdr.count, count);
701 INT_MOD(leaf_d->hdr.stale, ARCH_CONVERT, stale); 702 be16_add(&leaf_d->hdr.stale, stale);
702 xfs_dir2_leaf_log_header(tp, bp_s); 703 xfs_dir2_leaf_log_header(tp, bp_s);
703 xfs_dir2_leaf_log_header(tp, bp_d); 704 xfs_dir2_leaf_log_header(tp, bp_d);
704 xfs_dir2_leafn_check(args->dp, bp_s); 705 xfs_dir2_leafn_check(args->dp, bp_s);
@@ -719,13 +720,13 @@ xfs_dir2_leafn_order(
719 720
720 leaf1 = leaf1_bp->data; 721 leaf1 = leaf1_bp->data;
721 leaf2 = leaf2_bp->data; 722 leaf2 = leaf2_bp->data;
722 ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 723 ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
723 ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 724 ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
724 if (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0 && 725 if (be16_to_cpu(leaf1->hdr.count) > 0 &&
725 INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0 && 726 be16_to_cpu(leaf2->hdr.count) > 0 &&
726 (INT_GET(leaf2->ents[0].hashval, ARCH_CONVERT) < INT_GET(leaf1->ents[0].hashval, ARCH_CONVERT) || 727 (be32_to_cpu(leaf2->ents[0].hashval) < be32_to_cpu(leaf1->ents[0].hashval) ||
727 INT_GET(leaf2->ents[INT_GET(leaf2->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT) < 728 be32_to_cpu(leaf2->ents[be16_to_cpu(leaf2->hdr.count) - 1].hashval) <
728 INT_GET(leaf1->ents[INT_GET(leaf1->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT))) 729 be32_to_cpu(leaf1->ents[be16_to_cpu(leaf1->hdr.count) - 1].hashval)))
729 return 1; 730 return 1;
730 return 0; 731 return 0;
731} 732}
@@ -768,9 +769,9 @@ xfs_dir2_leafn_rebalance(
768 } 769 }
769 leaf1 = blk1->bp->data; 770 leaf1 = blk1->bp->data;
770 leaf2 = blk2->bp->data; 771 leaf2 = blk2->bp->data;
771 oldsum = INT_GET(leaf1->hdr.count, ARCH_CONVERT) + INT_GET(leaf2->hdr.count, ARCH_CONVERT); 772 oldsum = be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count);
772#ifdef DEBUG 773#ifdef DEBUG
773 oldstale = INT_GET(leaf1->hdr.stale, ARCH_CONVERT) + INT_GET(leaf2->hdr.stale, ARCH_CONVERT); 774 oldstale = be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale);
774#endif 775#endif
775 mid = oldsum >> 1; 776 mid = oldsum >> 1;
776 /* 777 /*
@@ -780,10 +781,10 @@ xfs_dir2_leafn_rebalance(
780 if (oldsum & 1) { 781 if (oldsum & 1) {
781 xfs_dahash_t midhash; /* middle entry hash value */ 782 xfs_dahash_t midhash; /* middle entry hash value */
782 783
783 if (mid >= INT_GET(leaf1->hdr.count, ARCH_CONVERT)) 784 if (mid >= be16_to_cpu(leaf1->hdr.count))
784 midhash = INT_GET(leaf2->ents[mid - INT_GET(leaf1->hdr.count, ARCH_CONVERT)].hashval, ARCH_CONVERT); 785 midhash = be32_to_cpu(leaf2->ents[mid - be16_to_cpu(leaf1->hdr.count)].hashval);
785 else 786 else
786 midhash = INT_GET(leaf1->ents[mid].hashval, ARCH_CONVERT); 787 midhash = be32_to_cpu(leaf1->ents[mid].hashval);
787 isleft = args->hashval <= midhash; 788 isleft = args->hashval <= midhash;
788 } 789 }
789 /* 790 /*
@@ -797,30 +798,30 @@ xfs_dir2_leafn_rebalance(
797 * Calculate moved entry count. Positive means left-to-right, 798 * Calculate moved entry count. Positive means left-to-right,
798 * negative means right-to-left. Then move the entries. 799 * negative means right-to-left. Then move the entries.
799 */ 800 */
800 count = INT_GET(leaf1->hdr.count, ARCH_CONVERT) - mid + (isleft == 0); 801 count = be16_to_cpu(leaf1->hdr.count) - mid + (isleft == 0);
801 if (count > 0) 802 if (count > 0)
802 xfs_dir2_leafn_moveents(args, blk1->bp, 803 xfs_dir2_leafn_moveents(args, blk1->bp,
803 INT_GET(leaf1->hdr.count, ARCH_CONVERT) - count, blk2->bp, 0, count); 804 be16_to_cpu(leaf1->hdr.count) - count, blk2->bp, 0, count);
804 else if (count < 0) 805 else if (count < 0)
805 xfs_dir2_leafn_moveents(args, blk2->bp, 0, blk1->bp, 806 xfs_dir2_leafn_moveents(args, blk2->bp, 0, blk1->bp,
806 INT_GET(leaf1->hdr.count, ARCH_CONVERT), count); 807 be16_to_cpu(leaf1->hdr.count), count);
807 ASSERT(INT_GET(leaf1->hdr.count, ARCH_CONVERT) + INT_GET(leaf2->hdr.count, ARCH_CONVERT) == oldsum); 808 ASSERT(be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count) == oldsum);
808 ASSERT(INT_GET(leaf1->hdr.stale, ARCH_CONVERT) + INT_GET(leaf2->hdr.stale, ARCH_CONVERT) == oldstale); 809 ASSERT(be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale) == oldstale);
809 /* 810 /*
810 * Mark whether we're inserting into the old or new leaf. 811 * Mark whether we're inserting into the old or new leaf.
811 */ 812 */
812 if (INT_GET(leaf1->hdr.count, ARCH_CONVERT) < INT_GET(leaf2->hdr.count, ARCH_CONVERT)) 813 if (be16_to_cpu(leaf1->hdr.count) < be16_to_cpu(leaf2->hdr.count))
813 state->inleaf = swap; 814 state->inleaf = swap;
814 else if (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > INT_GET(leaf2->hdr.count, ARCH_CONVERT)) 815 else if (be16_to_cpu(leaf1->hdr.count) > be16_to_cpu(leaf2->hdr.count))
815 state->inleaf = !swap; 816 state->inleaf = !swap;
816 else 817 else
817 state->inleaf = 818 state->inleaf =
818 swap ^ (blk1->index <= INT_GET(leaf1->hdr.count, ARCH_CONVERT)); 819 swap ^ (blk1->index <= be16_to_cpu(leaf1->hdr.count));
819 /* 820 /*
820 * Adjust the expected index for insertion. 821 * Adjust the expected index for insertion.
821 */ 822 */
822 if (!state->inleaf) 823 if (!state->inleaf)
823 blk2->index = blk1->index - INT_GET(leaf1->hdr.count, ARCH_CONVERT); 824 blk2->index = blk1->index - be16_to_cpu(leaf1->hdr.count);
824 825
825 /* 826 /*
826 * Finally sanity check just to make sure we are not returning a negative index 827 * Finally sanity check just to make sure we are not returning a negative index
@@ -867,7 +868,7 @@ xfs_dir2_leafn_remove(
867 tp = args->trans; 868 tp = args->trans;
868 mp = dp->i_mount; 869 mp = dp->i_mount;
869 leaf = bp->data; 870 leaf = bp->data;
870 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 871 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
871 /* 872 /*
872 * Point to the entry we're removing. 873 * Point to the entry we're removing.
873 */ 874 */
@@ -875,17 +876,17 @@ xfs_dir2_leafn_remove(
875 /* 876 /*
876 * Extract the data block and offset from the entry. 877 * Extract the data block and offset from the entry.
877 */ 878 */
878 db = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT)); 879 db = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address));
879 ASSERT(dblk->blkno == db); 880 ASSERT(dblk->blkno == db);
880 off = XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT)); 881 off = XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address));
881 ASSERT(dblk->index == off); 882 ASSERT(dblk->index == off);
882 /* 883 /*
883 * Kill the leaf entry by marking it stale. 884 * Kill the leaf entry by marking it stale.
884 * Log the leaf block changes. 885 * Log the leaf block changes.
885 */ 886 */
886 INT_MOD(leaf->hdr.stale, ARCH_CONVERT, +1); 887 be16_add(&leaf->hdr.stale, 1);
887 xfs_dir2_leaf_log_header(tp, bp); 888 xfs_dir2_leaf_log_header(tp, bp);
888 INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR); 889 lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
889 xfs_dir2_leaf_log_ents(tp, bp, index, index); 890 xfs_dir2_leaf_log_ents(tp, bp, index, index);
890 /* 891 /*
891 * Make the data entry free. Keep track of the longest freespace 892 * Make the data entry free. Keep track of the longest freespace
@@ -894,7 +895,7 @@ xfs_dir2_leafn_remove(
894 dbp = dblk->bp; 895 dbp = dblk->bp;
895 data = dbp->data; 896 data = dbp->data;
896 dep = (xfs_dir2_data_entry_t *)((char *)data + off); 897 dep = (xfs_dir2_data_entry_t *)((char *)data + off);
897 longest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT); 898 longest = be16_to_cpu(data->hdr.bestfree[0].length);
898 needlog = needscan = 0; 899 needlog = needscan = 0;
899 xfs_dir2_data_make_free(tp, dbp, off, 900 xfs_dir2_data_make_free(tp, dbp, off,
900 XFS_DIR2_DATA_ENTSIZE(dep->namelen), &needlog, &needscan); 901 XFS_DIR2_DATA_ENTSIZE(dep->namelen), &needlog, &needscan);
@@ -911,7 +912,7 @@ xfs_dir2_leafn_remove(
911 * If the longest data block freespace changes, need to update 912 * If the longest data block freespace changes, need to update
912 * the corresponding freeblock entry. 913 * the corresponding freeblock entry.
913 */ 914 */
914 if (longest < INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) { 915 if (longest < be16_to_cpu(data->hdr.bestfree[0].length)) {
915 int error; /* error return value */ 916 int error; /* error return value */
916 xfs_dabuf_t *fbp; /* freeblock buffer */ 917 xfs_dabuf_t *fbp; /* freeblock buffer */
917 xfs_dir2_db_t fdb; /* freeblock block number */ 918 xfs_dir2_db_t fdb; /* freeblock block number */
@@ -929,15 +930,15 @@ xfs_dir2_leafn_remove(
929 return error; 930 return error;
930 } 931 }
931 free = fbp->data; 932 free = fbp->data;
932 ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); 933 ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
933 ASSERT(INT_GET(free->hdr.firstdb, ARCH_CONVERT) == 934 ASSERT(be32_to_cpu(free->hdr.firstdb) ==
934 XFS_DIR2_MAX_FREE_BESTS(mp) * 935 XFS_DIR2_MAX_FREE_BESTS(mp) *
935 (fdb - XFS_DIR2_FREE_FIRSTDB(mp))); 936 (fdb - XFS_DIR2_FREE_FIRSTDB(mp)));
936 /* 937 /*
937 * Calculate which entry we need to fix. 938 * Calculate which entry we need to fix.
938 */ 939 */
939 findex = XFS_DIR2_DB_TO_FDINDEX(mp, db); 940 findex = XFS_DIR2_DB_TO_FDINDEX(mp, db);
940 longest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT); 941 longest = be16_to_cpu(data->hdr.bestfree[0].length);
941 /* 942 /*
942 * If the data block is now empty we can get rid of it 943 * If the data block is now empty we can get rid of it
943 * (usually). 944 * (usually).
@@ -969,7 +970,7 @@ xfs_dir2_leafn_remove(
969 /* 970 /*
970 * One less used entry in the free table. 971 * One less used entry in the free table.
971 */ 972 */
972 INT_MOD(free->hdr.nused, ARCH_CONVERT, -1); 973 free->hdr.nused = cpu_to_be32(-1);
973 xfs_dir2_free_log_header(tp, fbp); 974 xfs_dir2_free_log_header(tp, fbp);
974 /* 975 /*
975 * If this was the last entry in the table, we can 976 * If this was the last entry in the table, we can
@@ -977,21 +978,21 @@ xfs_dir2_leafn_remove(
977 * entries at the end referring to non-existent 978 * entries at the end referring to non-existent
978 * data blocks, get those too. 979 * data blocks, get those too.
979 */ 980 */
980 if (findex == INT_GET(free->hdr.nvalid, ARCH_CONVERT) - 1) { 981 if (findex == be32_to_cpu(free->hdr.nvalid) - 1) {
981 int i; /* free entry index */ 982 int i; /* free entry index */
982 983
983 for (i = findex - 1; 984 for (i = findex - 1;
984 i >= 0 && INT_GET(free->bests[i], ARCH_CONVERT) == NULLDATAOFF; 985 i >= 0 && be16_to_cpu(free->bests[i]) == NULLDATAOFF;
985 i--) 986 i--)
986 continue; 987 continue;
987 INT_SET(free->hdr.nvalid, ARCH_CONVERT, i + 1); 988 free->hdr.nvalid = cpu_to_be32(i + 1);
988 logfree = 0; 989 logfree = 0;
989 } 990 }
990 /* 991 /*
991 * Not the last entry, just punch it out. 992 * Not the last entry, just punch it out.
992 */ 993 */
993 else { 994 else {
994 INT_SET(free->bests[findex], ARCH_CONVERT, NULLDATAOFF); 995 free->bests[findex] = cpu_to_be16(NULLDATAOFF);
995 logfree = 1; 996 logfree = 1;
996 } 997 }
997 /* 998 /*
@@ -1017,7 +1018,7 @@ xfs_dir2_leafn_remove(
1017 * the new value. 1018 * the new value.
1018 */ 1019 */
1019 else { 1020 else {
1020 INT_SET(free->bests[findex], ARCH_CONVERT, longest); 1021 free->bests[findex] = cpu_to_be16(longest);
1021 logfree = 1; 1022 logfree = 1;
1022 } 1023 }
1023 /* 1024 /*
@@ -1039,7 +1040,7 @@ xfs_dir2_leafn_remove(
1039 *rval = 1040 *rval =
1040 ((uint)sizeof(leaf->hdr) + 1041 ((uint)sizeof(leaf->hdr) +
1041 (uint)sizeof(leaf->ents[0]) * 1042 (uint)sizeof(leaf->ents[0]) *
1042 (INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT))) < 1043 (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale))) <
1043 mp->m_dir_magicpct; 1044 mp->m_dir_magicpct;
1044 return 0; 1045 return 0;
1045} 1046}
@@ -1138,9 +1139,9 @@ xfs_dir2_leafn_toosmall(
1138 */ 1139 */
1139 blk = &state->path.blk[state->path.active - 1]; 1140 blk = &state->path.blk[state->path.active - 1];
1140 info = blk->bp->data; 1141 info = blk->bp->data;
1141 ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 1142 ASSERT(be16_to_cpu(info->magic) == XFS_DIR2_LEAFN_MAGIC);
1142 leaf = (xfs_dir2_leaf_t *)info; 1143 leaf = (xfs_dir2_leaf_t *)info;
1143 count = INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT); 1144 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
1144 bytes = (uint)sizeof(leaf->hdr) + count * (uint)sizeof(leaf->ents[0]); 1145 bytes = (uint)sizeof(leaf->hdr) + count * (uint)sizeof(leaf->ents[0]);
1145 if (bytes > (state->blocksize >> 1)) { 1146 if (bytes > (state->blocksize >> 1)) {
1146 /* 1147 /*
@@ -1160,7 +1161,7 @@ xfs_dir2_leafn_toosmall(
1160 * Make altpath point to the block we want to keep and 1161 * Make altpath point to the block we want to keep and
1161 * path point to the block we want to drop (this one). 1162 * path point to the block we want to drop (this one).
1162 */ 1163 */
1163 forward = info->forw; 1164 forward = (info->forw != 0);
1164 memcpy(&state->altpath, &state->path, sizeof(state->path)); 1165 memcpy(&state->altpath, &state->path, sizeof(state->path));
1165 error = xfs_da_path_shift(state, &state->altpath, forward, 0, 1166 error = xfs_da_path_shift(state, &state->altpath, forward, 0,
1166 &rval); 1167 &rval);
@@ -1176,9 +1177,9 @@ xfs_dir2_leafn_toosmall(
1176 * We prefer coalescing with the lower numbered sibling so as 1177 * We prefer coalescing with the lower numbered sibling so as
1177 * to shrink a directory over time. 1178 * to shrink a directory over time.
1178 */ 1179 */
1179 forward = INT_GET(info->forw, ARCH_CONVERT) < INT_GET(info->back, ARCH_CONVERT); 1180 forward = be32_to_cpu(info->forw) < be32_to_cpu(info->back);
1180 for (i = 0, bp = NULL; i < 2; forward = !forward, i++) { 1181 for (i = 0, bp = NULL; i < 2; forward = !forward, i++) {
1181 blkno = forward ?INT_GET( info->forw, ARCH_CONVERT) : INT_GET(info->back, ARCH_CONVERT); 1182 blkno = forward ? be32_to_cpu(info->forw) : be32_to_cpu(info->back);
1182 if (blkno == 0) 1183 if (blkno == 0)
1183 continue; 1184 continue;
1184 /* 1185 /*
@@ -1194,11 +1195,11 @@ xfs_dir2_leafn_toosmall(
1194 * Count bytes in the two blocks combined. 1195 * Count bytes in the two blocks combined.
1195 */ 1196 */
1196 leaf = (xfs_dir2_leaf_t *)info; 1197 leaf = (xfs_dir2_leaf_t *)info;
1197 count = INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT); 1198 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
1198 bytes = state->blocksize - (state->blocksize >> 2); 1199 bytes = state->blocksize - (state->blocksize >> 2);
1199 leaf = bp->data; 1200 leaf = bp->data;
1200 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 1201 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
1201 count += INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT); 1202 count += be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
1202 bytes -= count * (uint)sizeof(leaf->ents[0]); 1203 bytes -= count * (uint)sizeof(leaf->ents[0]);
1203 /* 1204 /*
1204 * Fits with at least 25% to spare. 1205 * Fits with at least 25% to spare.
@@ -1256,27 +1257,27 @@ xfs_dir2_leafn_unbalance(
1256 ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC); 1257 ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC);
1257 drop_leaf = drop_blk->bp->data; 1258 drop_leaf = drop_blk->bp->data;
1258 save_leaf = save_blk->bp->data; 1259 save_leaf = save_blk->bp->data;
1259 ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 1260 ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
1260 ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 1261 ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
1261 /* 1262 /*
1262 * If there are any stale leaf entries, take this opportunity 1263 * If there are any stale leaf entries, take this opportunity
1263 * to purge them. 1264 * to purge them.
1264 */ 1265 */
1265 if (INT_GET(drop_leaf->hdr.stale, ARCH_CONVERT)) 1266 if (drop_leaf->hdr.stale)
1266 xfs_dir2_leaf_compact(args, drop_blk->bp); 1267 xfs_dir2_leaf_compact(args, drop_blk->bp);
1267 if (INT_GET(save_leaf->hdr.stale, ARCH_CONVERT)) 1268 if (save_leaf->hdr.stale)
1268 xfs_dir2_leaf_compact(args, save_blk->bp); 1269 xfs_dir2_leaf_compact(args, save_blk->bp);
1269 /* 1270 /*
1270 * Move the entries from drop to the appropriate end of save. 1271 * Move the entries from drop to the appropriate end of save.
1271 */ 1272 */
1272 drop_blk->hashval = INT_GET(drop_leaf->ents[INT_GET(drop_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); 1273 drop_blk->hashval = be32_to_cpu(drop_leaf->ents[be16_to_cpu(drop_leaf->hdr.count) - 1].hashval);
1273 if (xfs_dir2_leafn_order(save_blk->bp, drop_blk->bp)) 1274 if (xfs_dir2_leafn_order(save_blk->bp, drop_blk->bp))
1274 xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, 0, 1275 xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, 0,
1275 INT_GET(drop_leaf->hdr.count, ARCH_CONVERT)); 1276 be16_to_cpu(drop_leaf->hdr.count));
1276 else 1277 else
1277 xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, 1278 xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp,
1278 INT_GET(save_leaf->hdr.count, ARCH_CONVERT), INT_GET(drop_leaf->hdr.count, ARCH_CONVERT)); 1279 be16_to_cpu(save_leaf->hdr.count), be16_to_cpu(drop_leaf->hdr.count));
1279 save_blk->hashval = INT_GET(save_leaf->ents[INT_GET(save_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); 1280 save_blk->hashval = be32_to_cpu(save_leaf->ents[be16_to_cpu(save_leaf->hdr.count) - 1].hashval);
1280 xfs_dir2_leafn_check(args->dp, save_blk->bp); 1281 xfs_dir2_leafn_check(args->dp, save_blk->bp);
1281} 1282}
1282 1283
@@ -1378,7 +1379,7 @@ xfs_dir2_node_addname_int(
1378 xfs_mount_t *mp; /* filesystem mount point */ 1379 xfs_mount_t *mp; /* filesystem mount point */
1379 int needlog; /* need to log data header */ 1380 int needlog; /* need to log data header */
1380 int needscan; /* need to rescan data frees */ 1381 int needscan; /* need to rescan data frees */
1381 xfs_dir2_data_off_t *tagp; /* data entry tag pointer */ 1382 __be16 *tagp; /* data entry tag pointer */
1382 xfs_trans_t *tp; /* transaction pointer */ 1383 xfs_trans_t *tp; /* transaction pointer */
1383 1384
1384 dp = args->dp; 1385 dp = args->dp;
@@ -1397,7 +1398,7 @@ xfs_dir2_node_addname_int(
1397 */ 1398 */
1398 ifbno = fblk->blkno; 1399 ifbno = fblk->blkno;
1399 free = fbp->data; 1400 free = fbp->data;
1400 ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); 1401 ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
1401 findex = fblk->index; 1402 findex = fblk->index;
1402 /* 1403 /*
1403 * This means the free entry showed that the data block had 1404 * This means the free entry showed that the data block had
@@ -1405,10 +1406,10 @@ xfs_dir2_node_addname_int(
1405 * Use that data block. 1406 * Use that data block.
1406 */ 1407 */
1407 if (findex >= 0) { 1408 if (findex >= 0) {
1408 ASSERT(findex < INT_GET(free->hdr.nvalid, ARCH_CONVERT)); 1409 ASSERT(findex < be32_to_cpu(free->hdr.nvalid));
1409 ASSERT(INT_GET(free->bests[findex], ARCH_CONVERT) != NULLDATAOFF); 1410 ASSERT(be16_to_cpu(free->bests[findex]) != NULLDATAOFF);
1410 ASSERT(INT_GET(free->bests[findex], ARCH_CONVERT) >= length); 1411 ASSERT(be16_to_cpu(free->bests[findex]) >= length);
1411 dbno = INT_GET(free->hdr.firstdb, ARCH_CONVERT) + findex; 1412 dbno = be32_to_cpu(free->hdr.firstdb) + findex;
1412 } 1413 }
1413 /* 1414 /*
1414 * The data block looked at didn't have enough room. 1415 * The data block looked at didn't have enough room.
@@ -1481,20 +1482,20 @@ xfs_dir2_node_addname_int(
1481 continue; 1482 continue;
1482 } 1483 }
1483 free = fbp->data; 1484 free = fbp->data;
1484 ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); 1485 ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
1485 findex = 0; 1486 findex = 0;
1486 } 1487 }
1487 /* 1488 /*
1488 * Look at the current free entry. Is it good enough? 1489 * Look at the current free entry. Is it good enough?
1489 */ 1490 */
1490 if (INT_GET(free->bests[findex], ARCH_CONVERT) != NULLDATAOFF && 1491 if (be16_to_cpu(free->bests[findex]) != NULLDATAOFF &&
1491 INT_GET(free->bests[findex], ARCH_CONVERT) >= length) 1492 be16_to_cpu(free->bests[findex]) >= length)
1492 dbno = INT_GET(free->hdr.firstdb, ARCH_CONVERT) + findex; 1493 dbno = be32_to_cpu(free->hdr.firstdb) + findex;
1493 else { 1494 else {
1494 /* 1495 /*
1495 * Are we done with the freeblock? 1496 * Are we done with the freeblock?
1496 */ 1497 */
1497 if (++findex == INT_GET(free->hdr.nvalid, ARCH_CONVERT)) { 1498 if (++findex == be32_to_cpu(free->hdr.nvalid)) {
1498 /* 1499 /*
1499 * Drop the block. 1500 * Drop the block.
1500 */ 1501 */
@@ -1608,15 +1609,15 @@ xfs_dir2_node_addname_int(
1608 * its first slot as our empty slot. 1609 * its first slot as our empty slot.
1609 */ 1610 */
1610 free = fbp->data; 1611 free = fbp->data;
1611 INT_SET(free->hdr.magic, ARCH_CONVERT, XFS_DIR2_FREE_MAGIC); 1612 free->hdr.magic = cpu_to_be32(XFS_DIR2_FREE_MAGIC);
1612 INT_SET(free->hdr.firstdb, ARCH_CONVERT, 1613 free->hdr.firstdb = cpu_to_be32(
1613 (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) * 1614 (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) *
1614 XFS_DIR2_MAX_FREE_BESTS(mp)); 1615 XFS_DIR2_MAX_FREE_BESTS(mp));
1615 free->hdr.nvalid = 0; 1616 free->hdr.nvalid = 0;
1616 free->hdr.nused = 0; 1617 free->hdr.nused = 0;
1617 } else { 1618 } else {
1618 free = fbp->data; 1619 free = fbp->data;
1619 ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); 1620 ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
1620 } 1621 }
1621 1622
1622 /* 1623 /*
@@ -1627,20 +1628,20 @@ xfs_dir2_node_addname_int(
1627 * If it's after the end of the current entries in the 1628 * If it's after the end of the current entries in the
1628 * freespace block, extend that table. 1629 * freespace block, extend that table.
1629 */ 1630 */
1630 if (findex >= INT_GET(free->hdr.nvalid, ARCH_CONVERT)) { 1631 if (findex >= be32_to_cpu(free->hdr.nvalid)) {
1631 ASSERT(findex < XFS_DIR2_MAX_FREE_BESTS(mp)); 1632 ASSERT(findex < XFS_DIR2_MAX_FREE_BESTS(mp));
1632 INT_SET(free->hdr.nvalid, ARCH_CONVERT, findex + 1); 1633 free->hdr.nvalid = cpu_to_be32(findex + 1);
1633 /* 1634 /*
1634 * Tag new entry so nused will go up. 1635 * Tag new entry so nused will go up.
1635 */ 1636 */
1636 INT_SET(free->bests[findex], ARCH_CONVERT, NULLDATAOFF); 1637 free->bests[findex] = cpu_to_be16(NULLDATAOFF);
1637 } 1638 }
1638 /* 1639 /*
1639 * If this entry was for an empty data block 1640 * If this entry was for an empty data block
1640 * (this should always be true) then update the header. 1641 * (this should always be true) then update the header.
1641 */ 1642 */
1642 if (INT_GET(free->bests[findex], ARCH_CONVERT) == NULLDATAOFF) { 1643 if (be16_to_cpu(free->bests[findex]) == NULLDATAOFF) {
1643 INT_MOD(free->hdr.nused, ARCH_CONVERT, +1); 1644 be32_add(&free->hdr.nused, 1);
1644 xfs_dir2_free_log_header(tp, fbp); 1645 xfs_dir2_free_log_header(tp, fbp);
1645 } 1646 }
1646 /* 1647 /*
@@ -1649,7 +1650,7 @@ xfs_dir2_node_addname_int(
1649 * change again. 1650 * change again.
1650 */ 1651 */
1651 data = dbp->data; 1652 data = dbp->data;
1652 INT_COPY(free->bests[findex], data->hdr.bestfree[0].length, ARCH_CONVERT); 1653 free->bests[findex] = data->hdr.bestfree[0].length;
1653 logfree = 1; 1654 logfree = 1;
1654 } 1655 }
1655 /* 1656 /*
@@ -1677,12 +1678,12 @@ xfs_dir2_node_addname_int(
1677 data = dbp->data; 1678 data = dbp->data;
1678 logfree = 0; 1679 logfree = 0;
1679 } 1680 }
1680 ASSERT(INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) >= length); 1681 ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) >= length);
1681 /* 1682 /*
1682 * Point to the existing unused space. 1683 * Point to the existing unused space.
1683 */ 1684 */
1684 dup = (xfs_dir2_data_unused_t *) 1685 dup = (xfs_dir2_data_unused_t *)
1685 ((char *)data + INT_GET(data->hdr.bestfree[0].offset, ARCH_CONVERT)); 1686 ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset));
1686 needscan = needlog = 0; 1687 needscan = needlog = 0;
1687 /* 1688 /*
1688 * Mark the first part of the unused space, inuse for us. 1689 * Mark the first part of the unused space, inuse for us.
@@ -1698,7 +1699,7 @@ xfs_dir2_node_addname_int(
1698 dep->namelen = args->namelen; 1699 dep->namelen = args->namelen;
1699 memcpy(dep->name, args->name, dep->namelen); 1700 memcpy(dep->name, args->name, dep->namelen);
1700 tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); 1701 tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep);
1701 INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)data)); 1702 *tagp = cpu_to_be16((char *)dep - (char *)data);
1702 xfs_dir2_data_log_entry(tp, dbp, dep); 1703 xfs_dir2_data_log_entry(tp, dbp, dep);
1703 /* 1704 /*
1704 * Rescan the block for bestfree if needed. 1705 * Rescan the block for bestfree if needed.
@@ -1713,8 +1714,8 @@ xfs_dir2_node_addname_int(
1713 /* 1714 /*
1714 * If the freespace entry is now wrong, update it. 1715 * If the freespace entry is now wrong, update it.
1715 */ 1716 */
1716 if (INT_GET(free->bests[findex], ARCH_CONVERT) != INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) { 1717 if (be16_to_cpu(free->bests[findex]) != be16_to_cpu(data->hdr.bestfree[0].length)) {
1717 INT_COPY(free->bests[findex], data->hdr.bestfree[0].length, ARCH_CONVERT); 1718 free->bests[findex] = data->hdr.bestfree[0].length;
1718 logfree = 1; 1719 logfree = 1;
1719 } 1720 }
1720 /* 1721 /*
@@ -1731,7 +1732,7 @@ xfs_dir2_node_addname_int(
1731 * Return the data block and offset in args, then drop the data block. 1732 * Return the data block and offset in args, then drop the data block.
1732 */ 1733 */
1733 args->blkno = (xfs_dablk_t)dbno; 1734 args->blkno = (xfs_dablk_t)dbno;
1734 args->index = INT_GET(*tagp, ARCH_CONVERT); 1735 args->index = be16_to_cpu(*tagp);
1735 xfs_da_buf_done(dbp); 1736 xfs_da_buf_done(dbp);
1736 return 0; 1737 return 0;
1737} 1738}
@@ -1900,10 +1901,10 @@ xfs_dir2_node_replace(
1900 * Point to the data entry. 1901 * Point to the data entry.
1901 */ 1902 */
1902 data = state->extrablk.bp->data; 1903 data = state->extrablk.bp->data;
1903 ASSERT(INT_GET(data->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC); 1904 ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC);
1904 dep = (xfs_dir2_data_entry_t *) 1905 dep = (xfs_dir2_data_entry_t *)
1905 ((char *)data + 1906 ((char *)data +
1906 XFS_DIR2_DATAPTR_TO_OFF(state->mp, INT_GET(lep->address, ARCH_CONVERT))); 1907 XFS_DIR2_DATAPTR_TO_OFF(state->mp, be32_to_cpu(lep->address)));
1907 ASSERT(inum != INT_GET(dep->inumber, ARCH_CONVERT)); 1908 ASSERT(inum != INT_GET(dep->inumber, ARCH_CONVERT));
1908 /* 1909 /*
1909 * Fill in the new inode number and log the entry. 1910 * Fill in the new inode number and log the entry.
@@ -1966,11 +1967,11 @@ xfs_dir2_node_trim_free(
1966 return 0; 1967 return 0;
1967 } 1968 }
1968 free = bp->data; 1969 free = bp->data;
1969 ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); 1970 ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
1970 /* 1971 /*
1971 * If there are used entries, there's nothing to do. 1972 * If there are used entries, there's nothing to do.
1972 */ 1973 */
1973 if (INT_GET(free->hdr.nused, ARCH_CONVERT) > 0) { 1974 if (be32_to_cpu(free->hdr.nused) > 0) {
1974 xfs_da_brelse(tp, bp); 1975 xfs_da_brelse(tp, bp);
1975 *rvalp = 0; 1976 *rvalp = 0;
1976 return 0; 1977 return 0;