diff options
author | Nathan Scott <nathans@sgi.com> | 2006-03-17 01:27:07 -0500 |
---|---|---|
committer | Nathan Scott <nathans@sgi.com> | 2006-03-17 01:27:07 -0500 |
commit | 0ba962ef7128d9276b8f95196382d5b9e2ad841d (patch) | |
tree | cce64b0b25696619c3060eba63c4d31ad00c12d3 /fs/xfs/xfs_dir2_node.c | |
parent | 70e73f59755867383edf563d5a5cbea614c0fd49 (diff) |
[XFS] endianess annotations for xfs_dir2_free_hdr_t
SGI-PV: 943272
SGI-Modid: xfs-linux-melb:xfs-kern:25485a
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_dir2_node.c')
-rw-r--r-- | fs/xfs/xfs_dir2_node.c | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c index e47bde74eecf..b051e2a09f31 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 | } |
@@ -121,7 +121,7 @@ xfs_dir2_leaf_to_node( | |||
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,10 +149,10 @@ 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(INT_GET(ltp->bestcount, ARCH_CONVERT) <= (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. |
@@ -161,16 +161,16 @@ xfs_dir2_leaf_to_node( | |||
161 | i < INT_GET(ltp->bestcount, ARCH_CONVERT); i++, from++, to++) { | 161 | i < INT_GET(ltp->bestcount, ARCH_CONVERT); i++, from++, to++) { |
162 | if ((off = INT_GET(*from, ARCH_CONVERT)) != NULLDATAOFF) | 162 | if ((off = INT_GET(*from, ARCH_CONVERT)) != 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 | INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, 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; |
@@ -443,7 +443,7 @@ xfs_dir2_leafn_lookup_int( | |||
443 | curdb = -1; | 443 | curdb = -1; |
444 | length = XFS_DIR2_DATA_ENTSIZE(args->namelen); | 444 | length = XFS_DIR2_DATA_ENTSIZE(args->namelen); |
445 | if ((free = (curbp ? curbp->data : NULL))) | 445 | if ((free = (curbp ? curbp->data : NULL))) |
446 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 446 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
447 | } | 447 | } |
448 | /* | 448 | /* |
449 | * For others, it's a data block buffer, get the block number. | 449 | * For others, it's a data block buffer, get the block number. |
@@ -506,15 +506,15 @@ xfs_dir2_leafn_lookup_int( | |||
506 | } | 506 | } |
507 | curfdb = newfdb; | 507 | curfdb = newfdb; |
508 | free = curbp->data; | 508 | free = curbp->data; |
509 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == | 509 | ASSERT(be32_to_cpu(free->hdr.magic) == |
510 | XFS_DIR2_FREE_MAGIC); | 510 | XFS_DIR2_FREE_MAGIC); |
511 | ASSERT((INT_GET(free->hdr.firstdb, ARCH_CONVERT) % | 511 | ASSERT((be32_to_cpu(free->hdr.firstdb) % |
512 | XFS_DIR2_MAX_FREE_BESTS(mp)) == | 512 | XFS_DIR2_MAX_FREE_BESTS(mp)) == |
513 | 0); | 513 | 0); |
514 | ASSERT(INT_GET(free->hdr.firstdb, ARCH_CONVERT) <= curdb); | 514 | ASSERT(be32_to_cpu(free->hdr.firstdb) <= curdb); |
515 | ASSERT(curdb < | 515 | ASSERT(curdb < |
516 | INT_GET(free->hdr.firstdb, ARCH_CONVERT) + | 516 | be32_to_cpu(free->hdr.firstdb) + |
517 | INT_GET(free->hdr.nvalid, ARCH_CONVERT)); | 517 | be32_to_cpu(free->hdr.nvalid)); |
518 | } | 518 | } |
519 | /* | 519 | /* |
520 | * Get the index for our entry. | 520 | * Get the index for our entry. |
@@ -523,12 +523,12 @@ xfs_dir2_leafn_lookup_int( | |||
523 | /* | 523 | /* |
524 | * If it has room, return it. | 524 | * If it has room, return it. |
525 | */ | 525 | */ |
526 | if (unlikely(INT_GET(free->bests[fi], ARCH_CONVERT) == NULLDATAOFF)) { | 526 | if (unlikely(be16_to_cpu(free->bests[fi]) == NULLDATAOFF)) { |
527 | XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int", | 527 | XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int", |
528 | XFS_ERRLEVEL_LOW, mp); | 528 | XFS_ERRLEVEL_LOW, mp); |
529 | return XFS_ERROR(EFSCORRUPTED); | 529 | return XFS_ERROR(EFSCORRUPTED); |
530 | } | 530 | } |
531 | if (INT_GET(free->bests[fi], ARCH_CONVERT) >= length) { | 531 | if (be16_to_cpu(free->bests[fi]) >= length) { |
532 | *indexp = index; | 532 | *indexp = index; |
533 | state->extravalid = 1; | 533 | state->extravalid = 1; |
534 | state->extrablk.bp = curbp; | 534 | state->extrablk.bp = curbp; |
@@ -929,8 +929,8 @@ xfs_dir2_leafn_remove( | |||
929 | return error; | 929 | return error; |
930 | } | 930 | } |
931 | free = fbp->data; | 931 | free = fbp->data; |
932 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 932 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
933 | ASSERT(INT_GET(free->hdr.firstdb, ARCH_CONVERT) == | 933 | ASSERT(be32_to_cpu(free->hdr.firstdb) == |
934 | XFS_DIR2_MAX_FREE_BESTS(mp) * | 934 | XFS_DIR2_MAX_FREE_BESTS(mp) * |
935 | (fdb - XFS_DIR2_FREE_FIRSTDB(mp))); | 935 | (fdb - XFS_DIR2_FREE_FIRSTDB(mp))); |
936 | /* | 936 | /* |
@@ -969,7 +969,7 @@ xfs_dir2_leafn_remove( | |||
969 | /* | 969 | /* |
970 | * One less used entry in the free table. | 970 | * One less used entry in the free table. |
971 | */ | 971 | */ |
972 | INT_MOD(free->hdr.nused, ARCH_CONVERT, -1); | 972 | free->hdr.nused = cpu_to_be32(-1); |
973 | xfs_dir2_free_log_header(tp, fbp); | 973 | xfs_dir2_free_log_header(tp, fbp); |
974 | /* | 974 | /* |
975 | * If this was the last entry in the table, we can | 975 | * If this was the last entry in the table, we can |
@@ -977,21 +977,21 @@ xfs_dir2_leafn_remove( | |||
977 | * entries at the end referring to non-existent | 977 | * entries at the end referring to non-existent |
978 | * data blocks, get those too. | 978 | * data blocks, get those too. |
979 | */ | 979 | */ |
980 | if (findex == INT_GET(free->hdr.nvalid, ARCH_CONVERT) - 1) { | 980 | if (findex == be32_to_cpu(free->hdr.nvalid) - 1) { |
981 | int i; /* free entry index */ | 981 | int i; /* free entry index */ |
982 | 982 | ||
983 | for (i = findex - 1; | 983 | for (i = findex - 1; |
984 | i >= 0 && INT_GET(free->bests[i], ARCH_CONVERT) == NULLDATAOFF; | 984 | i >= 0 && be16_to_cpu(free->bests[i]) == NULLDATAOFF; |
985 | i--) | 985 | i--) |
986 | continue; | 986 | continue; |
987 | INT_SET(free->hdr.nvalid, ARCH_CONVERT, i + 1); | 987 | free->hdr.nvalid = cpu_to_be32(i + 1); |
988 | logfree = 0; | 988 | logfree = 0; |
989 | } | 989 | } |
990 | /* | 990 | /* |
991 | * Not the last entry, just punch it out. | 991 | * Not the last entry, just punch it out. |
992 | */ | 992 | */ |
993 | else { | 993 | else { |
994 | INT_SET(free->bests[findex], ARCH_CONVERT, NULLDATAOFF); | 994 | free->bests[findex] = cpu_to_be16(NULLDATAOFF); |
995 | logfree = 1; | 995 | logfree = 1; |
996 | } | 996 | } |
997 | /* | 997 | /* |
@@ -1017,7 +1017,7 @@ xfs_dir2_leafn_remove( | |||
1017 | * the new value. | 1017 | * the new value. |
1018 | */ | 1018 | */ |
1019 | else { | 1019 | else { |
1020 | INT_SET(free->bests[findex], ARCH_CONVERT, longest); | 1020 | free->bests[findex] = cpu_to_be16(longest); |
1021 | logfree = 1; | 1021 | logfree = 1; |
1022 | } | 1022 | } |
1023 | /* | 1023 | /* |
@@ -1397,7 +1397,7 @@ xfs_dir2_node_addname_int( | |||
1397 | */ | 1397 | */ |
1398 | ifbno = fblk->blkno; | 1398 | ifbno = fblk->blkno; |
1399 | free = fbp->data; | 1399 | free = fbp->data; |
1400 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 1400 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
1401 | findex = fblk->index; | 1401 | findex = fblk->index; |
1402 | /* | 1402 | /* |
1403 | * This means the free entry showed that the data block had | 1403 | * This means the free entry showed that the data block had |
@@ -1405,10 +1405,10 @@ xfs_dir2_node_addname_int( | |||
1405 | * Use that data block. | 1405 | * Use that data block. |
1406 | */ | 1406 | */ |
1407 | if (findex >= 0) { | 1407 | if (findex >= 0) { |
1408 | ASSERT(findex < INT_GET(free->hdr.nvalid, ARCH_CONVERT)); | 1408 | ASSERT(findex < be32_to_cpu(free->hdr.nvalid)); |
1409 | ASSERT(INT_GET(free->bests[findex], ARCH_CONVERT) != NULLDATAOFF); | 1409 | ASSERT(be16_to_cpu(free->bests[findex]) != NULLDATAOFF); |
1410 | ASSERT(INT_GET(free->bests[findex], ARCH_CONVERT) >= length); | 1410 | ASSERT(be16_to_cpu(free->bests[findex]) >= length); |
1411 | dbno = INT_GET(free->hdr.firstdb, ARCH_CONVERT) + findex; | 1411 | dbno = be32_to_cpu(free->hdr.firstdb) + findex; |
1412 | } | 1412 | } |
1413 | /* | 1413 | /* |
1414 | * The data block looked at didn't have enough room. | 1414 | * The data block looked at didn't have enough room. |
@@ -1481,20 +1481,20 @@ xfs_dir2_node_addname_int( | |||
1481 | continue; | 1481 | continue; |
1482 | } | 1482 | } |
1483 | free = fbp->data; | 1483 | free = fbp->data; |
1484 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 1484 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
1485 | findex = 0; | 1485 | findex = 0; |
1486 | } | 1486 | } |
1487 | /* | 1487 | /* |
1488 | * Look at the current free entry. Is it good enough? | 1488 | * Look at the current free entry. Is it good enough? |
1489 | */ | 1489 | */ |
1490 | if (INT_GET(free->bests[findex], ARCH_CONVERT) != NULLDATAOFF && | 1490 | if (be16_to_cpu(free->bests[findex]) != NULLDATAOFF && |
1491 | INT_GET(free->bests[findex], ARCH_CONVERT) >= length) | 1491 | be16_to_cpu(free->bests[findex]) >= length) |
1492 | dbno = INT_GET(free->hdr.firstdb, ARCH_CONVERT) + findex; | 1492 | dbno = be32_to_cpu(free->hdr.firstdb) + findex; |
1493 | else { | 1493 | else { |
1494 | /* | 1494 | /* |
1495 | * Are we done with the freeblock? | 1495 | * Are we done with the freeblock? |
1496 | */ | 1496 | */ |
1497 | if (++findex == INT_GET(free->hdr.nvalid, ARCH_CONVERT)) { | 1497 | if (++findex == be32_to_cpu(free->hdr.nvalid)) { |
1498 | /* | 1498 | /* |
1499 | * Drop the block. | 1499 | * Drop the block. |
1500 | */ | 1500 | */ |
@@ -1608,15 +1608,15 @@ xfs_dir2_node_addname_int( | |||
1608 | * its first slot as our empty slot. | 1608 | * its first slot as our empty slot. |
1609 | */ | 1609 | */ |
1610 | free = fbp->data; | 1610 | free = fbp->data; |
1611 | INT_SET(free->hdr.magic, ARCH_CONVERT, XFS_DIR2_FREE_MAGIC); | 1611 | free->hdr.magic = cpu_to_be32(XFS_DIR2_FREE_MAGIC); |
1612 | INT_SET(free->hdr.firstdb, ARCH_CONVERT, | 1612 | free->hdr.firstdb = cpu_to_be32( |
1613 | (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) * | 1613 | (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) * |
1614 | XFS_DIR2_MAX_FREE_BESTS(mp)); | 1614 | XFS_DIR2_MAX_FREE_BESTS(mp)); |
1615 | free->hdr.nvalid = 0; | 1615 | free->hdr.nvalid = 0; |
1616 | free->hdr.nused = 0; | 1616 | free->hdr.nused = 0; |
1617 | } else { | 1617 | } else { |
1618 | free = fbp->data; | 1618 | free = fbp->data; |
1619 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 1619 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
1620 | } | 1620 | } |
1621 | 1621 | ||
1622 | /* | 1622 | /* |
@@ -1627,20 +1627,20 @@ xfs_dir2_node_addname_int( | |||
1627 | * If it's after the end of the current entries in the | 1627 | * If it's after the end of the current entries in the |
1628 | * freespace block, extend that table. | 1628 | * freespace block, extend that table. |
1629 | */ | 1629 | */ |
1630 | if (findex >= INT_GET(free->hdr.nvalid, ARCH_CONVERT)) { | 1630 | if (findex >= be32_to_cpu(free->hdr.nvalid)) { |
1631 | ASSERT(findex < XFS_DIR2_MAX_FREE_BESTS(mp)); | 1631 | ASSERT(findex < XFS_DIR2_MAX_FREE_BESTS(mp)); |
1632 | INT_SET(free->hdr.nvalid, ARCH_CONVERT, findex + 1); | 1632 | free->hdr.nvalid = cpu_to_be32(findex + 1); |
1633 | /* | 1633 | /* |
1634 | * Tag new entry so nused will go up. | 1634 | * Tag new entry so nused will go up. |
1635 | */ | 1635 | */ |
1636 | INT_SET(free->bests[findex], ARCH_CONVERT, NULLDATAOFF); | 1636 | free->bests[findex] = cpu_to_be16(NULLDATAOFF); |
1637 | } | 1637 | } |
1638 | /* | 1638 | /* |
1639 | * If this entry was for an empty data block | 1639 | * If this entry was for an empty data block |
1640 | * (this should always be true) then update the header. | 1640 | * (this should always be true) then update the header. |
1641 | */ | 1641 | */ |
1642 | if (INT_GET(free->bests[findex], ARCH_CONVERT) == NULLDATAOFF) { | 1642 | if (be16_to_cpu(free->bests[findex]) == NULLDATAOFF) { |
1643 | INT_MOD(free->hdr.nused, ARCH_CONVERT, +1); | 1643 | be32_add(&free->hdr.nused, 1); |
1644 | xfs_dir2_free_log_header(tp, fbp); | 1644 | xfs_dir2_free_log_header(tp, fbp); |
1645 | } | 1645 | } |
1646 | /* | 1646 | /* |
@@ -1713,7 +1713,7 @@ xfs_dir2_node_addname_int( | |||
1713 | /* | 1713 | /* |
1714 | * If the freespace entry is now wrong, update it. | 1714 | * If the freespace entry is now wrong, update it. |
1715 | */ | 1715 | */ |
1716 | if (INT_GET(free->bests[findex], ARCH_CONVERT) != be16_to_cpu(data->hdr.bestfree[0].length)) { | 1716 | if (be16_to_cpu(free->bests[findex]) != be16_to_cpu(data->hdr.bestfree[0].length)) { |
1717 | free->bests[findex] = data->hdr.bestfree[0].length; | 1717 | free->bests[findex] = data->hdr.bestfree[0].length; |
1718 | logfree = 1; | 1718 | logfree = 1; |
1719 | } | 1719 | } |
@@ -1966,11 +1966,11 @@ xfs_dir2_node_trim_free( | |||
1966 | return 0; | 1966 | return 0; |
1967 | } | 1967 | } |
1968 | free = bp->data; | 1968 | free = bp->data; |
1969 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 1969 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
1970 | /* | 1970 | /* |
1971 | * If there are used entries, there's nothing to do. | 1971 | * If there are used entries, there's nothing to do. |
1972 | */ | 1972 | */ |
1973 | if (INT_GET(free->hdr.nused, ARCH_CONVERT) > 0) { | 1973 | if (be32_to_cpu(free->hdr.nused) > 0) { |
1974 | xfs_da_brelse(tp, bp); | 1974 | xfs_da_brelse(tp, bp); |
1975 | *rvalp = 0; | 1975 | *rvalp = 0; |
1976 | return 0; | 1976 | return 0; |