Commit 61a25848 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Tim Shimmin

[XFS] endianess annotations for xfs_inobt_rec_t / xfs_inobt_key_t

SGI-PV: 954580
SGI-Modid: xfs-linux-melb:xfs-kern:26556a
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarNathan Scott <nathans@sgi.com>
Signed-off-by: default avatarTim Shimmin <tes@sgi.com>
parent e2101005
...@@ -170,7 +170,7 @@ xfs_btree_check_key( ...@@ -170,7 +170,7 @@ xfs_btree_check_key(
k1 = ak1; k1 = ak1;
k2 = ak2; k2 = ak2;
ASSERT(INT_GET(k1->ir_startino, ARCH_CONVERT) < INT_GET(k2->ir_startino, ARCH_CONVERT)); ASSERT(be32_to_cpu(k1->ir_startino) < be32_to_cpu(k2->ir_startino));
break; break;
} }
default: default:
...@@ -285,8 +285,8 @@ xfs_btree_check_rec( ...@@ -285,8 +285,8 @@ xfs_btree_check_rec(
r1 = ar1; r1 = ar1;
r2 = ar2; r2 = ar2;
ASSERT(INT_GET(r1->ir_startino, ARCH_CONVERT) + XFS_INODES_PER_CHUNK <= ASSERT(be32_to_cpu(r1->ir_startino) + XFS_INODES_PER_CHUNK <=
INT_GET(r2->ir_startino, ARCH_CONVERT)); be32_to_cpu(r2->ir_startino));
break; break;
} }
default: default:
......
...@@ -145,7 +145,7 @@ typedef struct xfs_btree_cur ...@@ -145,7 +145,7 @@ typedef struct xfs_btree_cur
union { union {
xfs_alloc_rec_incore_t a; xfs_alloc_rec_incore_t a;
xfs_bmbt_irec_t b; xfs_bmbt_irec_t b;
xfs_inobt_rec_t i; xfs_inobt_rec_incore_t i;
} bc_rec; /* current insert/search record value */ } bc_rec; /* current insert/search record value */
struct xfs_buf *bc_bufs[XFS_BTREE_MAXLEVELS]; /* buf ptr per level */ struct xfs_buf *bc_bufs[XFS_BTREE_MAXLEVELS]; /* buf ptr per level */
int bc_ptrs[XFS_BTREE_MAXLEVELS]; /* key/record # */ int bc_ptrs[XFS_BTREE_MAXLEVELS]; /* key/record # */
......
...@@ -529,10 +529,10 @@ xfs_dialloc( ...@@ -529,10 +529,10 @@ xfs_dialloc(
int offset; /* index of inode in chunk */ int offset; /* index of inode in chunk */
xfs_agino_t pagino; /* parent's a.g. relative inode # */ xfs_agino_t pagino; /* parent's a.g. relative inode # */
xfs_agnumber_t pagno; /* parent's allocation group number */ xfs_agnumber_t pagno; /* parent's allocation group number */
xfs_inobt_rec_t rec; /* inode allocation record */ xfs_inobt_rec_incore_t rec; /* inode allocation record */
xfs_agnumber_t tagno; /* testing allocation group number */ xfs_agnumber_t tagno; /* testing allocation group number */
xfs_btree_cur_t *tcur; /* temp cursor */ xfs_btree_cur_t *tcur; /* temp cursor */
xfs_inobt_rec_t trec; /* temp inode allocation record */ xfs_inobt_rec_incore_t trec; /* temp inode allocation record */
if (*IO_agbp == NULL) { if (*IO_agbp == NULL) {
...@@ -945,7 +945,7 @@ xfs_difree( ...@@ -945,7 +945,7 @@ xfs_difree(
int ilen; /* inodes in an inode cluster */ int ilen; /* inodes in an inode cluster */
xfs_mount_t *mp; /* mount structure for filesystem */ xfs_mount_t *mp; /* mount structure for filesystem */
int off; /* offset of inode in inode chunk */ int off; /* offset of inode in inode chunk */
xfs_inobt_rec_t rec; /* btree record */ xfs_inobt_rec_incore_t rec; /* btree record */
mp = tp->t_mountp; mp = tp->t_mountp;
......
...@@ -568,7 +568,7 @@ xfs_inobt_insrec( ...@@ -568,7 +568,7 @@ xfs_inobt_insrec(
/* /*
* Make a key out of the record data to be inserted, and save it. * Make a key out of the record data to be inserted, and save it.
*/ */
key.ir_startino = recp->ir_startino; /* INT_: direct copy */ key.ir_startino = recp->ir_startino;
optr = ptr = cur->bc_ptrs[level]; optr = ptr = cur->bc_ptrs[level];
/* /*
* If we're off the left edge, return failure. * If we're off the left edge, return failure.
...@@ -641,7 +641,7 @@ xfs_inobt_insrec( ...@@ -641,7 +641,7 @@ xfs_inobt_insrec(
return error; return error;
#endif #endif
ptr = cur->bc_ptrs[level]; ptr = cur->bc_ptrs[level];
nrec.ir_startino = nkey.ir_startino; /* INT_: direct copy */ nrec.ir_startino = nkey.ir_startino;
} else { } else {
/* /*
* Otherwise the insert fails. * Otherwise the insert fails.
...@@ -950,12 +950,12 @@ xfs_inobt_lookup( ...@@ -950,12 +950,12 @@ xfs_inobt_lookup(
xfs_inobt_key_t *kkp; xfs_inobt_key_t *kkp;
kkp = kkbase + keyno - 1; kkp = kkbase + keyno - 1;
startino = INT_GET(kkp->ir_startino, ARCH_CONVERT); startino = be32_to_cpu(kkp->ir_startino);
} else { } else {
xfs_inobt_rec_t *krp; xfs_inobt_rec_t *krp;
krp = krbase + keyno - 1; krp = krbase + keyno - 1;
startino = INT_GET(krp->ir_startino, ARCH_CONVERT); startino = be32_to_cpu(krp->ir_startino);
} }
/* /*
* Compute difference to get next direction. * Compute difference to get next direction.
...@@ -1160,7 +1160,7 @@ xfs_inobt_lshift( ...@@ -1160,7 +1160,7 @@ xfs_inobt_lshift(
} else { } else {
memmove(rrp, rrp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); memmove(rrp, rrp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
key.ir_startino = rrp->ir_startino; /* INT_: direct copy */ key.ir_startino = rrp->ir_startino;
rkp = &key; rkp = &key;
} }
/* /*
...@@ -1301,9 +1301,9 @@ xfs_inobt_newroot( ...@@ -1301,9 +1301,9 @@ xfs_inobt_newroot(
kp[1] = *XFS_INOBT_KEY_ADDR(right, 1, cur); /* INT_: struct copy */ kp[1] = *XFS_INOBT_KEY_ADDR(right, 1, cur); /* INT_: struct copy */
} else { } else {
rp = XFS_INOBT_REC_ADDR(left, 1, cur); rp = XFS_INOBT_REC_ADDR(left, 1, cur);
INT_COPY(kp[0].ir_startino, rp->ir_startino, ARCH_CONVERT); kp[0].ir_startino = rp->ir_startino;
rp = XFS_INOBT_REC_ADDR(right, 1, cur); rp = XFS_INOBT_REC_ADDR(right, 1, cur);
INT_COPY(kp[1].ir_startino, rp->ir_startino, ARCH_CONVERT); kp[1].ir_startino = rp->ir_startino;
} }
xfs_inobt_log_keys(cur, nbp, 1, 2); xfs_inobt_log_keys(cur, nbp, 1, 2);
/* /*
...@@ -1420,7 +1420,7 @@ xfs_inobt_rshift( ...@@ -1420,7 +1420,7 @@ xfs_inobt_rshift(
memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
*rrp = *lrp; *rrp = *lrp;
xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
key.ir_startino = rrp->ir_startino; /* INT_: direct copy */ key.ir_startino = rrp->ir_startino;
rkp = &key; rkp = &key;
} }
/* /*
...@@ -1559,7 +1559,7 @@ xfs_inobt_split( ...@@ -1559,7 +1559,7 @@ xfs_inobt_split(
rrp = XFS_INOBT_REC_ADDR(right, 1, cur); rrp = XFS_INOBT_REC_ADDR(right, 1, cur);
memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
keyp->ir_startino = rrp->ir_startino; /* INT_: direct copy */ keyp->ir_startino = rrp->ir_startino;
} }
/* /*
* Find the left block number by looking in the buffer. * Find the left block number by looking in the buffer.
...@@ -1813,9 +1813,9 @@ xfs_inobt_get_rec( ...@@ -1813,9 +1813,9 @@ xfs_inobt_get_rec(
* Point to the record and extract its data. * Point to the record and extract its data.
*/ */
rec = XFS_INOBT_REC_ADDR(block, ptr, cur); rec = XFS_INOBT_REC_ADDR(block, ptr, cur);
*ino = INT_GET(rec->ir_startino, ARCH_CONVERT); *ino = be32_to_cpu(rec->ir_startino);
*fcnt = INT_GET(rec->ir_freecount, ARCH_CONVERT); *fcnt = be32_to_cpu(rec->ir_freecount);
*free = INT_GET(rec->ir_free, ARCH_CONVERT); *free = be64_to_cpu(rec->ir_free);
*stat = 1; *stat = 1;
return 0; return 0;
} }
...@@ -1930,9 +1930,9 @@ xfs_inobt_insert( ...@@ -1930,9 +1930,9 @@ xfs_inobt_insert(
level = 0; level = 0;
nbno = NULLAGBLOCK; nbno = NULLAGBLOCK;
INT_SET(nrec.ir_startino, ARCH_CONVERT, cur->bc_rec.i.ir_startino); nrec.ir_startino = cpu_to_be32(cur->bc_rec.i.ir_startino);
INT_SET(nrec.ir_freecount, ARCH_CONVERT, cur->bc_rec.i.ir_freecount); nrec.ir_freecount = cpu_to_be32(cur->bc_rec.i.ir_freecount);
INT_SET(nrec.ir_free, ARCH_CONVERT, cur->bc_rec.i.ir_free); nrec.ir_free = cpu_to_be64(cur->bc_rec.i.ir_free);
ncur = (xfs_btree_cur_t *)0; ncur = (xfs_btree_cur_t *)0;
pcur = cur; pcur = cur;
/* /*
...@@ -2060,9 +2060,9 @@ xfs_inobt_update( ...@@ -2060,9 +2060,9 @@ xfs_inobt_update(
/* /*
* Fill in the new contents and log them. * Fill in the new contents and log them.
*/ */
INT_SET(rp->ir_startino, ARCH_CONVERT, ino); rp->ir_startino = cpu_to_be32(ino);
INT_SET(rp->ir_freecount, ARCH_CONVERT, fcnt); rp->ir_freecount = cpu_to_be32(fcnt);
INT_SET(rp->ir_free, ARCH_CONVERT, free); rp->ir_free = cpu_to_be64(free);
xfs_inobt_log_recs(cur, bp, ptr, ptr); xfs_inobt_log_recs(cur, bp, ptr, ptr);
/* /*
* Updating first record in leaf. Pass new key value up to our parent. * Updating first record in leaf. Pass new key value up to our parent.
...@@ -2070,7 +2070,7 @@ xfs_inobt_update( ...@@ -2070,7 +2070,7 @@ xfs_inobt_update(
if (ptr == 1) { if (ptr == 1) {
xfs_inobt_key_t key; /* key containing [ino] */ xfs_inobt_key_t key; /* key containing [ino] */
INT_SET(key.ir_startino, ARCH_CONVERT, ino); key.ir_startino = cpu_to_be32(ino);
if ((error = xfs_inobt_updkey(cur, &key, 1))) if ((error = xfs_inobt_updkey(cur, &key, 1)))
return error; return error;
} }
......
...@@ -47,19 +47,24 @@ static inline xfs_inofree_t xfs_inobt_maskn(int i, int n) ...@@ -47,19 +47,24 @@ static inline xfs_inofree_t xfs_inobt_maskn(int i, int n)
/* /*
* Data record structure * Data record structure
*/ */
typedef struct xfs_inobt_rec typedef struct xfs_inobt_rec {
{ __be32 ir_startino; /* starting inode number */
__be32 ir_freecount; /* count of free inodes (set bits) */
__be64 ir_free; /* free inode mask */
} xfs_inobt_rec_t;
typedef struct xfs_inobt_rec_incore {
xfs_agino_t ir_startino; /* starting inode number */ xfs_agino_t ir_startino; /* starting inode number */
__int32_t ir_freecount; /* count of free inodes (set bits) */ __int32_t ir_freecount; /* count of free inodes (set bits) */
xfs_inofree_t ir_free; /* free inode mask */ xfs_inofree_t ir_free; /* free inode mask */
} xfs_inobt_rec_t; } xfs_inobt_rec_incore_t;
/* /*
* Key structure * Key structure
*/ */
typedef struct xfs_inobt_key typedef struct xfs_inobt_key {
{ __be32 ir_startino; /* starting inode number */
xfs_agino_t ir_startino; /* starting inode number */
} xfs_inobt_key_t; } xfs_inobt_key_t;
/* btree pointer type */ /* btree pointer type */
...@@ -77,7 +82,7 @@ typedef struct xfs_btree_sblock xfs_inobt_block_t; ...@@ -77,7 +82,7 @@ typedef struct xfs_btree_sblock xfs_inobt_block_t;
#define XFS_INOBT_IS_FREE(rp,i) \ #define XFS_INOBT_IS_FREE(rp,i) \
(((rp)->ir_free & XFS_INOBT_MASK(i)) != 0) (((rp)->ir_free & XFS_INOBT_MASK(i)) != 0)
#define XFS_INOBT_IS_FREE_DISK(rp,i) \ #define XFS_INOBT_IS_FREE_DISK(rp,i) \
((INT_GET((rp)->ir_free,ARCH_CONVERT) & XFS_INOBT_MASK(i)) != 0) ((be64_to_cpu((rp)->ir_free) & XFS_INOBT_MASK(i)) != 0)
#define XFS_INOBT_SET_FREE(rp,i) ((rp)->ir_free |= XFS_INOBT_MASK(i)) #define XFS_INOBT_SET_FREE(rp,i) ((rp)->ir_free |= XFS_INOBT_MASK(i))
#define XFS_INOBT_CLR_FREE(rp,i) ((rp)->ir_free &= ~XFS_INOBT_MASK(i)) #define XFS_INOBT_CLR_FREE(rp,i) ((rp)->ir_free &= ~XFS_INOBT_MASK(i))
......
...@@ -395,9 +395,9 @@ xfs_bulkstat( ...@@ -395,9 +395,9 @@ xfs_bulkstat(
gcnt++; gcnt++;
} }
gfree |= XFS_INOBT_MASKN(0, chunkidx); gfree |= XFS_INOBT_MASKN(0, chunkidx);
INT_SET(irbp->ir_startino, ARCH_CONVERT, gino); irbp->ir_startino = cpu_to_be32(gino);
INT_SET(irbp->ir_freecount, ARCH_CONVERT, gcnt); irbp->ir_freecount = cpu_to_be32(gcnt);
INT_SET(irbp->ir_free, ARCH_CONVERT, gfree); irbp->ir_free = cpu_to_be64(gfree);
irbp++; irbp++;
agino = gino + XFS_INODES_PER_CHUNK; agino = gino + XFS_INODES_PER_CHUNK;
icount = XFS_INODES_PER_CHUNK - gcnt; icount = XFS_INODES_PER_CHUNK - gcnt;
...@@ -453,9 +453,9 @@ xfs_bulkstat( ...@@ -453,9 +453,9 @@ xfs_bulkstat(
* If this chunk has any allocated inodes, save it. * If this chunk has any allocated inodes, save it.
*/ */
if (gcnt < XFS_INODES_PER_CHUNK) { if (gcnt < XFS_INODES_PER_CHUNK) {
INT_SET(irbp->ir_startino, ARCH_CONVERT, gino); irbp->ir_startino = cpu_to_be32(gino);
INT_SET(irbp->ir_freecount, ARCH_CONVERT, gcnt); irbp->ir_freecount = cpu_to_be32(gcnt);
INT_SET(irbp->ir_free, ARCH_CONVERT, gfree); irbp->ir_free = cpu_to_be64(gfree);
irbp++; irbp++;
icount += XFS_INODES_PER_CHUNK - gcnt; icount += XFS_INODES_PER_CHUNK - gcnt;
} }
...@@ -488,14 +488,14 @@ xfs_bulkstat( ...@@ -488,14 +488,14 @@ xfs_bulkstat(
* inodes in that cluster. * inodes in that cluster.
*/ */
for (agbno = XFS_AGINO_TO_AGBNO(mp, for (agbno = XFS_AGINO_TO_AGBNO(mp,
INT_GET(irbp[1].ir_startino, ARCH_CONVERT)), be32_to_cpu(irbp[1].ir_startino)),
chunkidx = 0; chunkidx = 0;
chunkidx < XFS_INODES_PER_CHUNK; chunkidx < XFS_INODES_PER_CHUNK;
chunkidx += nicluster, chunkidx += nicluster,
agbno += nbcluster) { agbno += nbcluster) {
if (XFS_INOBT_MASKN(chunkidx, if (XFS_INOBT_MASKN(chunkidx,
nicluster) & nicluster) &
~(INT_GET(irbp[1].ir_free, ARCH_CONVERT))) ~(be64_to_cpu(irbp[1].ir_free)))
xfs_btree_reada_bufs(mp, agno, xfs_btree_reada_bufs(mp, agno,
agbno, nbcluster); agbno, nbcluster);
} }
...@@ -503,9 +503,9 @@ xfs_bulkstat( ...@@ -503,9 +503,9 @@ xfs_bulkstat(
/* /*
* Now process this chunk of inodes. * Now process this chunk of inodes.
*/ */
for (agino = INT_GET(irbp->ir_startino, ARCH_CONVERT), chunkidx = 0, clustidx = 0; for (agino = be32_to_cpu(irbp->ir_startino), chunkidx = 0, clustidx = 0;
ubleft > 0 && ubleft > 0 &&
INT_GET(irbp->ir_freecount, ARCH_CONVERT) < XFS_INODES_PER_CHUNK; be32_to_cpu(irbp->ir_freecount) < XFS_INODES_PER_CHUNK;
chunkidx++, clustidx++, agino++) { chunkidx++, clustidx++, agino++) {
ASSERT(chunkidx < XFS_INODES_PER_CHUNK); ASSERT(chunkidx < XFS_INODES_PER_CHUNK);
/* /*
...@@ -525,7 +525,7 @@ xfs_bulkstat( ...@@ -525,7 +525,7 @@ xfs_bulkstat(
*/ */
if ((chunkidx & (nicluster - 1)) == 0) { if ((chunkidx & (nicluster - 1)) == 0) {
agbno = XFS_AGINO_TO_AGBNO(mp, agbno = XFS_AGINO_TO_AGBNO(mp,
INT_GET(irbp->ir_startino, ARCH_CONVERT)) + be32_to_cpu(irbp->ir_startino)) +
((chunkidx & nimask) >> ((chunkidx & nimask) >>
mp->m_sb.sb_inopblog); mp->m_sb.sb_inopblog);
...@@ -564,13 +564,13 @@ xfs_bulkstat( ...@@ -564,13 +564,13 @@ xfs_bulkstat(
/* /*
* Skip if this inode is free. * Skip if this inode is free.
*/ */
if (XFS_INOBT_MASK(chunkidx) & INT_GET(irbp->ir_free, ARCH_CONVERT)) if (XFS_INOBT_MASK(chunkidx) & be64_to_cpu(irbp->ir_free))
continue; continue;
/* /*
* Count used inodes as free so we can tell * Count used inodes as free so we can tell
* when the chunk is used up. * when the chunk is used up.
*/ */
INT_MOD(irbp->ir_freecount, ARCH_CONVERT, +1); be32_add(&irbp->ir_freecount, 1);
ino = XFS_AGINO_TO_INO(mp, agno, agino); ino = XFS_AGINO_TO_INO(mp, agno, agino);
bno = XFS_AGB_TO_DADDR(mp, agno, agbno); bno = XFS_AGB_TO_DADDR(mp, agno, agbno);
if (flags & BULKSTAT_FG_QUICK) { if (flags & BULKSTAT_FG_QUICK) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment