diff options
author | Nathan Scott <nathans@sgi.com> | 2006-03-17 01:28:07 -0500 |
---|---|---|
committer | Nathan Scott <nathans@sgi.com> | 2006-03-17 01:28:07 -0500 |
commit | a818e5de7e21ddaa7352bb8c9fc785c7b4f3019f (patch) | |
tree | 9e2e3f03be8c9b065e019999a66b6d85d7a74f5e /fs/xfs/xfs_dir2_leaf.c | |
parent | e922fffa4188ef6207cd3afef7f4d33bf4a9ca64 (diff) |
[XFS] endianess annotations for xfs_dir2_leaf_hdr_t
SGI-PV: 943272
SGI-Modid: xfs-linux-melb:xfs-kern:25492a
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_dir2_leaf.c')
-rw-r--r-- | fs/xfs/xfs_dir2_leaf.c | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c index 63e81dc2737e..0d366ab4db17 100644 --- a/fs/xfs/xfs_dir2_leaf.c +++ b/fs/xfs/xfs_dir2_leaf.c | |||
@@ -111,14 +111,14 @@ xfs_dir2_block_to_leaf( | |||
111 | /* | 111 | /* |
112 | * Set the counts in the leaf header. | 112 | * Set the counts in the leaf header. |
113 | */ | 113 | */ |
114 | leaf->hdr.count = btp->count; | 114 | leaf->hdr.count = cpu_to_be16(be32_to_cpu(btp->count)); |
115 | leaf->hdr.stale = btp->stale; | 115 | leaf->hdr.stale = cpu_to_be16(be32_to_cpu(btp->stale)); |
116 | /* | 116 | /* |
117 | * Could compact these but I think we always do the conversion | 117 | * Could compact these but I think we always do the conversion |
118 | * after squeezing out stale entries. | 118 | * after squeezing out stale entries. |
119 | */ | 119 | */ |
120 | memcpy(leaf->ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t)); | 120 | memcpy(leaf->ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t)); |
121 | xfs_dir2_leaf_log_ents(tp, lbp, 0, INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1); | 121 | xfs_dir2_leaf_log_ents(tp, lbp, 0, be16_to_cpu(leaf->hdr.count) - 1); |
122 | needscan = 0; | 122 | needscan = 0; |
123 | needlog = 1; | 123 | needlog = 1; |
124 | /* | 124 | /* |
@@ -222,7 +222,7 @@ xfs_dir2_leaf_addname( | |||
222 | * in a data block, improving the lookup of those entries. | 222 | * in a data block, improving the lookup of those entries. |
223 | */ | 223 | */ |
224 | for (use_block = -1, lep = &leaf->ents[index]; | 224 | for (use_block = -1, lep = &leaf->ents[index]; |
225 | index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; | 225 | index < be16_to_cpu(leaf->hdr.count) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; |
226 | index++, lep++) { | 226 | index++, lep++) { |
227 | if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 227 | if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) |
228 | continue; | 228 | continue; |
@@ -266,15 +266,15 @@ xfs_dir2_leaf_addname( | |||
266 | * If we don't have enough free bytes but we can make enough | 266 | * If we don't have enough free bytes but we can make enough |
267 | * by compacting out stale entries, we'll do that. | 267 | * by compacting out stale entries, we'll do that. |
268 | */ | 268 | */ |
269 | if ((char *)bestsp - (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] < needbytes && | 269 | if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] < needbytes && |
270 | INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1) { | 270 | be16_to_cpu(leaf->hdr.stale) > 1) { |
271 | compact = 1; | 271 | compact = 1; |
272 | } | 272 | } |
273 | /* | 273 | /* |
274 | * Otherwise if we don't have enough free bytes we need to | 274 | * Otherwise if we don't have enough free bytes we need to |
275 | * convert to node form. | 275 | * convert to node form. |
276 | */ | 276 | */ |
277 | else if ((char *)bestsp - (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] < | 277 | else if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] < |
278 | needbytes) { | 278 | needbytes) { |
279 | /* | 279 | /* |
280 | * Just checking or no space reservation, give up. | 280 | * Just checking or no space reservation, give up. |
@@ -330,8 +330,8 @@ xfs_dir2_leaf_addname( | |||
330 | * There are stale entries, so we'll need log-low and log-high | 330 | * There are stale entries, so we'll need log-low and log-high |
331 | * impossibly bad values later. | 331 | * impossibly bad values later. |
332 | */ | 332 | */ |
333 | else if (INT_GET(leaf->hdr.stale, ARCH_CONVERT)) { | 333 | else if (be16_to_cpu(leaf->hdr.stale)) { |
334 | lfloglow = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 334 | lfloglow = be16_to_cpu(leaf->hdr.count); |
335 | lfloghigh = -1; | 335 | lfloghigh = -1; |
336 | } | 336 | } |
337 | /* | 337 | /* |
@@ -440,15 +440,15 @@ xfs_dir2_leaf_addname( | |||
440 | /* | 440 | /* |
441 | * lep is still good as the index leaf entry. | 441 | * lep is still good as the index leaf entry. |
442 | */ | 442 | */ |
443 | if (index < INT_GET(leaf->hdr.count, ARCH_CONVERT)) | 443 | if (index < be16_to_cpu(leaf->hdr.count)) |
444 | memmove(lep + 1, lep, | 444 | memmove(lep + 1, lep, |
445 | (INT_GET(leaf->hdr.count, ARCH_CONVERT) - index) * sizeof(*lep)); | 445 | (be16_to_cpu(leaf->hdr.count) - index) * sizeof(*lep)); |
446 | /* | 446 | /* |
447 | * Record low and high logging indices for the leaf. | 447 | * Record low and high logging indices for the leaf. |
448 | */ | 448 | */ |
449 | lfloglow = index; | 449 | lfloglow = index; |
450 | lfloghigh = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 450 | lfloghigh = be16_to_cpu(leaf->hdr.count); |
451 | INT_MOD(leaf->hdr.count, ARCH_CONVERT, +1); | 451 | be16_add(&leaf->hdr.count, 1); |
452 | } | 452 | } |
453 | /* | 453 | /* |
454 | * There are stale entries. | 454 | * There are stale entries. |
@@ -478,7 +478,7 @@ xfs_dir2_leaf_addname( | |||
478 | * lowstale entry would be better. | 478 | * lowstale entry would be better. |
479 | */ | 479 | */ |
480 | for (highstale = index; | 480 | for (highstale = index; |
481 | highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) && | 481 | highstale < be16_to_cpu(leaf->hdr.count) && |
482 | INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != | 482 | INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != |
483 | XFS_DIR2_NULL_DATAPTR && | 483 | XFS_DIR2_NULL_DATAPTR && |
484 | (lowstale < 0 || | 484 | (lowstale < 0 || |
@@ -490,7 +490,7 @@ xfs_dir2_leaf_addname( | |||
490 | * If the low one is better, use it. | 490 | * If the low one is better, use it. |
491 | */ | 491 | */ |
492 | if (lowstale >= 0 && | 492 | if (lowstale >= 0 && |
493 | (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) || | 493 | (highstale == be16_to_cpu(leaf->hdr.count) || |
494 | index - lowstale - 1 < highstale - index)) { | 494 | index - lowstale - 1 < highstale - index)) { |
495 | ASSERT(index - lowstale - 1 >= 0); | 495 | ASSERT(index - lowstale - 1 >= 0); |
496 | ASSERT(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) == | 496 | ASSERT(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) == |
@@ -526,7 +526,7 @@ xfs_dir2_leaf_addname( | |||
526 | lfloglow = MIN(index, lfloglow); | 526 | lfloglow = MIN(index, lfloglow); |
527 | lfloghigh = MAX(highstale, lfloghigh); | 527 | lfloghigh = MAX(highstale, lfloghigh); |
528 | } | 528 | } |
529 | INT_MOD(leaf->hdr.stale, ARCH_CONVERT, -1); | 529 | be16_add(&leaf->hdr.stale, -1); |
530 | } | 530 | } |
531 | /* | 531 | /* |
532 | * Fill in the new leaf entry. | 532 | * Fill in the new leaf entry. |
@@ -569,24 +569,24 @@ xfs_dir2_leaf_check( | |||
569 | * Should factor in the size of the bests table as well. | 569 | * Should factor in the size of the bests table as well. |
570 | * We can deduce a value for that from di_size. | 570 | * We can deduce a value for that from di_size. |
571 | */ | 571 | */ |
572 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); | 572 | ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); |
573 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 573 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
574 | /* | 574 | /* |
575 | * Leaves and bests don't overlap. | 575 | * Leaves and bests don't overlap. |
576 | */ | 576 | */ |
577 | ASSERT((char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] <= | 577 | ASSERT((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <= |
578 | (char *)XFS_DIR2_LEAF_BESTS_P(ltp)); | 578 | (char *)XFS_DIR2_LEAF_BESTS_P(ltp)); |
579 | /* | 579 | /* |
580 | * Check hash value order, count stale entries. | 580 | * Check hash value order, count stale entries. |
581 | */ | 581 | */ |
582 | for (i = stale = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); i++) { | 582 | for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) { |
583 | if (i + 1 < INT_GET(leaf->hdr.count, ARCH_CONVERT)) | 583 | if (i + 1 < be16_to_cpu(leaf->hdr.count)) |
584 | ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <= | 584 | ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <= |
585 | INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT)); | 585 | INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT)); |
586 | if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 586 | if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) |
587 | stale++; | 587 | stale++; |
588 | } | 588 | } |
589 | ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == stale); | 589 | ASSERT(be16_to_cpu(leaf->hdr.stale) == stale); |
590 | } | 590 | } |
591 | #endif /* DEBUG */ | 591 | #endif /* DEBUG */ |
592 | 592 | ||
@@ -611,7 +611,7 @@ xfs_dir2_leaf_compact( | |||
611 | /* | 611 | /* |
612 | * Compress out the stale entries in place. | 612 | * Compress out the stale entries in place. |
613 | */ | 613 | */ |
614 | for (from = to = 0, loglow = -1; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) { | 614 | for (from = to = 0, loglow = -1; from < be16_to_cpu(leaf->hdr.count); from++) { |
615 | if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 615 | if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) |
616 | continue; | 616 | continue; |
617 | /* | 617 | /* |
@@ -627,8 +627,8 @@ xfs_dir2_leaf_compact( | |||
627 | /* | 627 | /* |
628 | * Update and log the header, log the leaf entries. | 628 | * Update and log the header, log the leaf entries. |
629 | */ | 629 | */ |
630 | ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == from - to); | 630 | ASSERT(be16_to_cpu(leaf->hdr.stale) == from - to); |
631 | INT_MOD(leaf->hdr.count, ARCH_CONVERT, -(INT_GET(leaf->hdr.stale, ARCH_CONVERT))); | 631 | be16_add(&leaf->hdr.count, -(be16_to_cpu(leaf->hdr.stale))); |
632 | leaf->hdr.stale = 0; | 632 | leaf->hdr.stale = 0; |
633 | xfs_dir2_leaf_log_header(args->trans, bp); | 633 | xfs_dir2_leaf_log_header(args->trans, bp); |
634 | if (loglow != -1) | 634 | if (loglow != -1) |
@@ -662,7 +662,7 @@ xfs_dir2_leaf_compact_x1( | |||
662 | int to; /* destination copy index */ | 662 | int to; /* destination copy index */ |
663 | 663 | ||
664 | leaf = bp->data; | 664 | leaf = bp->data; |
665 | ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1); | 665 | ASSERT(be16_to_cpu(leaf->hdr.stale) > 1); |
666 | index = *indexp; | 666 | index = *indexp; |
667 | /* | 667 | /* |
668 | * Find the first stale entry before our index, if any. | 668 | * Find the first stale entry before our index, if any. |
@@ -677,7 +677,7 @@ xfs_dir2_leaf_compact_x1( | |||
677 | * Stop if the answer would be worse than lowstale. | 677 | * Stop if the answer would be worse than lowstale. |
678 | */ | 678 | */ |
679 | for (highstale = index; | 679 | for (highstale = index; |
680 | highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) && | 680 | highstale < be16_to_cpu(leaf->hdr.count) && |
681 | INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR && | 681 | INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR && |
682 | (lowstale < 0 || index - lowstale > highstale - index); | 682 | (lowstale < 0 || index - lowstale > highstale - index); |
683 | highstale++) | 683 | highstale++) |
@@ -686,7 +686,7 @@ xfs_dir2_leaf_compact_x1( | |||
686 | * Pick the better of lowstale and highstale. | 686 | * Pick the better of lowstale and highstale. |
687 | */ | 687 | */ |
688 | if (lowstale >= 0 && | 688 | if (lowstale >= 0 && |
689 | (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) || | 689 | (highstale == be16_to_cpu(leaf->hdr.count) || |
690 | index - lowstale <= highstale - index)) | 690 | index - lowstale <= highstale - index)) |
691 | keepstale = lowstale; | 691 | keepstale = lowstale; |
692 | else | 692 | else |
@@ -695,7 +695,7 @@ xfs_dir2_leaf_compact_x1( | |||
695 | * Copy the entries in place, removing all the stale entries | 695 | * Copy the entries in place, removing all the stale entries |
696 | * except keepstale. | 696 | * except keepstale. |
697 | */ | 697 | */ |
698 | for (from = to = 0; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) { | 698 | for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) { |
699 | /* | 699 | /* |
700 | * Notice the new value of index. | 700 | * Notice the new value of index. |
701 | */ | 701 | */ |
@@ -730,8 +730,8 @@ xfs_dir2_leaf_compact_x1( | |||
730 | /* | 730 | /* |
731 | * Adjust the leaf header values. | 731 | * Adjust the leaf header values. |
732 | */ | 732 | */ |
733 | INT_MOD(leaf->hdr.count, ARCH_CONVERT, -(from - to)); | 733 | be16_add(&leaf->hdr.count, -(from - to)); |
734 | INT_SET(leaf->hdr.stale, ARCH_CONVERT, 1); | 734 | leaf->hdr.stale = cpu_to_be16(1); |
735 | /* | 735 | /* |
736 | * Remember the low/high stale value only in the "right" | 736 | * Remember the low/high stale value only in the "right" |
737 | * direction. | 737 | * direction. |
@@ -739,8 +739,8 @@ xfs_dir2_leaf_compact_x1( | |||
739 | if (lowstale >= newindex) | 739 | if (lowstale >= newindex) |
740 | lowstale = -1; | 740 | lowstale = -1; |
741 | else | 741 | else |
742 | highstale = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 742 | highstale = be16_to_cpu(leaf->hdr.count); |
743 | *highlogp = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1; | 743 | *highlogp = be16_to_cpu(leaf->hdr.count) - 1; |
744 | *lowstalep = lowstale; | 744 | *lowstalep = lowstale; |
745 | *highstalep = highstale; | 745 | *highstalep = highstale; |
746 | } | 746 | } |
@@ -1373,7 +1373,7 @@ xfs_dir2_leaf_lookup_int( | |||
1373 | * looking to match the name. | 1373 | * looking to match the name. |
1374 | */ | 1374 | */ |
1375 | for (lep = &leaf->ents[index], dbp = NULL, curdb = -1; | 1375 | for (lep = &leaf->ents[index], dbp = NULL, curdb = -1; |
1376 | index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; | 1376 | index < be16_to_cpu(leaf->hdr.count) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; |
1377 | lep++, index++) { | 1377 | lep++, index++) { |
1378 | /* | 1378 | /* |
1379 | * Skip over stale leaf entries. | 1379 | * Skip over stale leaf entries. |
@@ -1488,7 +1488,7 @@ xfs_dir2_leaf_removename( | |||
1488 | /* | 1488 | /* |
1489 | * We just mark the leaf entry stale by putting a null in it. | 1489 | * We just mark the leaf entry stale by putting a null in it. |
1490 | */ | 1490 | */ |
1491 | INT_MOD(leaf->hdr.stale, ARCH_CONVERT, +1); | 1491 | be16_add(&leaf->hdr.stale, 1); |
1492 | xfs_dir2_leaf_log_header(tp, lbp); | 1492 | xfs_dir2_leaf_log_header(tp, lbp); |
1493 | INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR); | 1493 | INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR); |
1494 | xfs_dir2_leaf_log_ents(tp, lbp, index, index); | 1494 | xfs_dir2_leaf_log_ents(tp, lbp, index, index); |
@@ -1645,7 +1645,7 @@ xfs_dir2_leaf_search_hash( | |||
1645 | * Note, the table cannot be empty, so we have to go through the loop. | 1645 | * Note, the table cannot be empty, so we have to go through the loop. |
1646 | * Binary search the leaf entries looking for our hash value. | 1646 | * Binary search the leaf entries looking for our hash value. |
1647 | */ | 1647 | */ |
1648 | for (lep = leaf->ents, low = 0, high = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1, | 1648 | for (lep = leaf->ents, low = 0, high = be16_to_cpu(leaf->hdr.count) - 1, |
1649 | hashwant = args->hashval; | 1649 | hashwant = args->hashval; |
1650 | low <= high; ) { | 1650 | low <= high; ) { |
1651 | mid = (low + high) >> 1; | 1651 | mid = (low + high) >> 1; |
@@ -1821,7 +1821,7 @@ xfs_dir2_node_to_leaf( | |||
1821 | * If not, release the buffer and give up. | 1821 | * If not, release the buffer and give up. |
1822 | */ | 1822 | */ |
1823 | if ((uint)sizeof(leaf->hdr) + | 1823 | if ((uint)sizeof(leaf->hdr) + |
1824 | (INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)) * (uint)sizeof(leaf->ents[0]) + | 1824 | (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale)) * (uint)sizeof(leaf->ents[0]) + |
1825 | be32_to_cpu(free->hdr.nvalid) * (uint)sizeof(leaf->bests[0]) + | 1825 | be32_to_cpu(free->hdr.nvalid) * (uint)sizeof(leaf->bests[0]) + |
1826 | (uint)sizeof(leaf->tail) > | 1826 | (uint)sizeof(leaf->tail) > |
1827 | mp->m_dirblksize) { | 1827 | mp->m_dirblksize) { |
@@ -1832,7 +1832,7 @@ xfs_dir2_node_to_leaf( | |||
1832 | * If the leaf has any stale entries in it, compress them out. | 1832 | * If the leaf has any stale entries in it, compress them out. |
1833 | * The compact routine will log the header. | 1833 | * The compact routine will log the header. |
1834 | */ | 1834 | */ |
1835 | if (INT_GET(leaf->hdr.stale, ARCH_CONVERT)) | 1835 | if (be16_to_cpu(leaf->hdr.stale)) |
1836 | xfs_dir2_leaf_compact(args, lbp); | 1836 | xfs_dir2_leaf_compact(args, lbp); |
1837 | else | 1837 | else |
1838 | xfs_dir2_leaf_log_header(tp, lbp); | 1838 | xfs_dir2_leaf_log_header(tp, lbp); |